team.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <view class="content">
  3. <!-- <view class="navbar coupon">
  4. <view class="nav-item grenn" v-if="tabCurrentIndex == 0">
  5. 一级总业绩:
  6. <text>{{ one_price }}</text>
  7. </view>
  8. <view class="nav-item black" v-if="tabCurrentIndex == 1">
  9. 二级总业绩:
  10. <text>{{ two_price }}</text>
  11. </view>
  12. </view> -->
  13. <view class="navbar">
  14. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}:{{item.number}}人</view>
  15. </view>
  16. <swiper :current="tabCurrentIndex" :style="{ height: maxheight + 'px' }" class="swiper-box" duration="300" @change="changeTab">
  17. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  18. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  19. <!-- 空白页 -->
  20. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  21. <!-- 订单列表 -->
  22. <view v-for="(item, index) in tabItem.orderList" :key="index" class="order-item flex">
  23. <view class="title-box flex_item">
  24. <view class="title-avatar"><image :src="item.avatar"></image></view>
  25. <view style="width: 80%;">
  26. <view class="title flex">
  27. <view class="clamp" style="width: 350rpx;overflow: hidden;">{{ item.nickname }}</view>
  28. <view class="clamp time" style="width: 280rpx;overflow: hidden;text-align: right;">总消费:{{ item.numberCount || 0.0 }}</view>
  29. </view>
  30. <view class="time flex">
  31. <!-- <view>{{ item.time }}</view> -->
  32. <view class="phone">{{ item.phone ? item.phone : '暂无手机号' }}</view>
  33. <view class="text">{{ item.lastTime | lastTime }}</view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  39. </scroll-view>
  40. </swiper-item>
  41. </swiper>
  42. </view>
  43. </template>
  44. <script>
  45. import { spread_people } from '@/api/team.js';
  46. import { mapState, mapMutations } from 'vuex';
  47. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  48. import empty from '@/components/empty';
  49. import { getTime } from '@/utils/rocessor.js';
  50. // 获取当前时间的秒数
  51. const time = Math.floor(new Date().getTime() / 1000);
  52. export default {
  53. components: {
  54. empty,
  55. uniLoadMore
  56. },
  57. filters: {
  58. lastTime: function(value) {
  59. const day = Math.floor((time - value) / 60 / 60 / 24);
  60. return day == 0 ? '今天登陆' : day + '天前登陆';
  61. }
  62. },
  63. onReady() {
  64. // 初始化获取页面宽度
  65. uni.createSelectorQuery()
  66. .select('.content')
  67. .fields(
  68. {
  69. size: true
  70. },
  71. data => {
  72. console.log(data);
  73. // console.log(Math.floor((data.width / 750) * 300));
  74. // 保存头部高度
  75. this.maxheight = data.height - Math.floor((data.width / 750) * 220);
  76. console.log(this.maxheight);
  77. }
  78. )
  79. .exec();
  80. },
  81. data() {
  82. return {
  83. // 头部图高度
  84. maxheight: '',
  85. tabCurrentIndex: 0,
  86. navList: [
  87. {
  88. state: 0,
  89. text: '一级',
  90. loadingType: 'more',
  91. orderList: [],
  92. number:0,
  93. page: 1, //当前页数
  94. limit: 10 //每次信息条数
  95. },
  96. {
  97. state: 1,
  98. text: '二级',
  99. loadingType: 'more',
  100. number:0,
  101. orderList: [],
  102. page: 1, //当前页数
  103. limit: 10 //每次信息条数
  104. }
  105. ],
  106. all: '',
  107. list: '',
  108. total: '',
  109. totalLevel: '',
  110. img: 'http://kaifa.crmeb.net/uploads/attach/2019/08/20190807/723adbdd4e49a0f9394dfc700ab5dba3.png',
  111. one_price: '', //一级总金额
  112. two_price: '' //二级总金额
  113. };
  114. },
  115. onLoad(options) {},
  116. onShow() {
  117. this.loadData();
  118. },
  119. methods: {
  120. // 页面跳转
  121. navto(e) {
  122. uni.navigateTo({
  123. url: e
  124. });
  125. },
  126. //获取收入支出信息
  127. async loadData(source) {
  128. let obj = this;
  129. //这里是将订单挂载到tab列表下
  130. let index = this.tabCurrentIndex;
  131. let navItem = this.navList[index];
  132. let state = navItem.state;
  133. if (source === 'tabChange' && navItem.loaded === true) {
  134. //tab切换只有第一次需要加载数据
  135. return;
  136. }
  137. if (navItem.loadingType === 'loading') {
  138. //防止重复加载
  139. return;
  140. }
  141. // 修改当前对象状态为加载中
  142. navItem.loadingType = 'loading';
  143. spread_people({
  144. page: navItem.page,
  145. limit: navItem.limit,
  146. keyword: '',
  147. sort: 'lastTime desc',
  148. grade: state
  149. })
  150. .then(({ data }) => {
  151. obj.navList[0].number = data.total;
  152. obj.navList[1].number = data.totalLevel;
  153. obj.one_price = data.one_price; //一级总金额
  154. obj.two_price = data.two_price; //二级总金额
  155. let arr = data.list.map(e => {
  156. e.lastTimeString = getTime(e.lastTime);
  157. return e;
  158. });
  159. console.log(arr,'arr')
  160. navItem.orderList = navItem.orderList.concat(data.list);
  161. navItem.page++;
  162. console.log(navItem.page,'page')
  163. console.log(navItem.limit,arr.length,'11')
  164. if (navItem.limit == data.length) {
  165. //判断是否还有数据, 有改为 more, 没有改为noMore
  166. navItem.loadingType = 'more';
  167. return;
  168. } else {
  169. //判断是否还有数据, 有改为 more, 没有改为noMore
  170. navItem.loadingType = 'noMore';
  171. }
  172. this.$set(navItem, 'loaded', true);
  173. })
  174. .catch(e => {
  175. console.log(e);
  176. });
  177. },
  178. //swiper 切换
  179. changeTab(e) {
  180. this.tabCurrentIndex = e.target.current;
  181. this.loadData('tabChange');
  182. },
  183. //顶部tab点击
  184. tabClick(index) {
  185. this.tabCurrentIndex = index;
  186. }
  187. }
  188. };
  189. </script>
  190. <style lang="scss">
  191. page {
  192. background: #ffffff;
  193. height: 100%;
  194. }
  195. .content-money {
  196. padding-bottom: 30rpx;
  197. background: $page-color-base;
  198. .buttom-box {
  199. background-color: #ffffff;
  200. text-align: center;
  201. margin: 0 30rpx;
  202. padding: 30rpx 0;
  203. border-radius: $border-radius-sm;
  204. margin-top: -60rpx;
  205. .buttom {
  206. font-size: $font-lg;
  207. flex-grow: 1;
  208. .money {
  209. font-weight: bold;
  210. font-size: 32rpx;
  211. color: #db1935;
  212. }
  213. }
  214. .text {
  215. color: #666666;
  216. }
  217. .interval {
  218. width: 2rpx;
  219. height: 60rpx;
  220. background-color: #eeeeee;
  221. }
  222. .icon {
  223. height: 50rpx;
  224. width: 48rpx;
  225. margin: 0 auto;
  226. .icon-img {
  227. width: 100%;
  228. height: 100%;
  229. }
  230. }
  231. }
  232. }
  233. .money-box {
  234. background: #bc253a;
  235. height: 320rpx;
  236. color: #ffffff;
  237. text-align: center;
  238. font-size: 35rpx;
  239. padding-top: 60rpx;
  240. .money_img {
  241. width: 100%;
  242. height: 120rpx;
  243. text-align: center;
  244. padding-top: 50rpx;
  245. padding-bottom: 135rpx;
  246. image {
  247. width: 120rpx;
  248. height: 120rpx;
  249. border: 4rpx solid #fd5f6f;
  250. border-radius: 50%;
  251. }
  252. }
  253. .money_name {
  254. width: 100%;
  255. text-align: center;
  256. font-size: 40rpx;
  257. padding-bottom: 25rpx;
  258. }
  259. }
  260. .navbar {
  261. display: flex;
  262. height: 40px;
  263. padding: 0 5px;
  264. background: #fff;
  265. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  266. position: relative;
  267. z-index: 10;
  268. .nav-item {
  269. flex: 1;
  270. display: flex;
  271. justify-content: center;
  272. align-items: center;
  273. height: 100%;
  274. font-size: 15px;
  275. color: $font-color-dark;
  276. position: relative;
  277. &.current {
  278. color: $font-color;
  279. background-color: #dcdfe6;
  280. // color: #FC2A3F;
  281. // &:after {
  282. // content: '';
  283. // position: absolute;
  284. // left: 50%;
  285. // bottom: 0;
  286. // transform: translateX(-50%);
  287. // width: 44px;
  288. // height: 0;
  289. // border-bottom: 2px solid #FC2A3F;
  290. // }
  291. }
  292. }
  293. .grenn {
  294. background: #2fbd5b;
  295. }
  296. .black {
  297. background: #434343;
  298. }
  299. .grenn,
  300. .black {
  301. color: #ffffff;
  302. text-align: left;
  303. }
  304. }
  305. // 列表
  306. .swiper-box {
  307. padding-top: 10rpx;
  308. height: calc(100% - 80px);
  309. .order-item {
  310. padding: 20rpx 30rpx;
  311. line-height: 1.5;
  312. .title-box {
  313. width: 100%;
  314. .title-avatar {
  315. width: 100rpx;
  316. height: 100rpx;
  317. margin-right: 25rpx;
  318. image {
  319. width: 100%;
  320. height: 100%;
  321. border-radius: 100%;
  322. }
  323. }
  324. .title {
  325. font-size: $font-lg;
  326. color: $font-color-base;
  327. }
  328. .time {
  329. font-size: $font-base;
  330. color: $font-color-light;
  331. }
  332. }
  333. .money {
  334. color: #db1935;
  335. font-size: $font-lg;
  336. }
  337. }
  338. }
  339. .list-scroll-content {
  340. height: 100%;
  341. }
  342. .content {
  343. height: 100%;
  344. .empty-content {
  345. background-color: #ffffff;
  346. }
  347. }
  348. </style>