team.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="status_bar">
  5. <!-- 这里是状态栏 -->
  6. </view>
  7. <view class="body-title">
  8. <view class="goback-box" @click="toBack">
  9. <image class="goback" src="../../static/icon/fanhui.png" mode=""></image>
  10. </view>
  11. <view class="header">我的推广</view>
  12. </view>
  13. <view class="content-bg">
  14. <image src="../../static/img/tg-bg.png" mode=""></image>
  15. </view>
  16. <view class="money-box">
  17. <view class="money">{{ totalLevel + all|| '0' }}</view>
  18. <view>我的团队</view>
  19. </view>
  20. <!-- <view class="money-box" style="padding-top: 20rpx;" v-if="order*1 > 0">
  21. <view>直推:{{zt_order}}单</view>
  22. <view>间推:{{jt_order}}单</view>
  23. </view> -->
  24. </view>
  25. <view class="flex buttom-box">
  26. <view class="buttom" @click="tabClick(0)">
  27. <view class="money">{{all || 0}}</view>
  28. <text class="text" :class="{ current: tabCurrentIndex === 0 }">一级推广</text>
  29. </view>
  30. <view class="buttom" @click="tabClick(1)">
  31. <view class="money">{{totalLevel || 0}}</view>
  32. <text class="text" :class="{ current: tabCurrentIndex === 1 }">团队推广</text>
  33. </view>
  34. </view>
  35. <swiper :current="tabCurrentIndex" :style="{ height: maxheight }" class="swiper-box" duration="300"
  36. @change="changeTab">
  37. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  38. <scroll-view class="list-scroll-content" :style="{ height: maxheight }" scroll-y
  39. @scrolltolower="loadData">
  40. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  41. <view v-for="(item, index) in tabItem.orderList" :key="index" class="order-item flex">
  42. <view class="title-box flex_item">
  43. <view class="title-avatar">
  44. <image :src="item.avatar"></image>
  45. </view>
  46. <view class="list_tpl">
  47. <view class="title">
  48. <view class="title-name clamp">{{ item.nickname }}</view>
  49. </view>
  50. <view class="flex star" v-if="item.zero_level >= 7">
  51. <image src="../../static/icon/star.png" mode="" v-for="item in (item.zero_level*1 - 6)"></image>
  52. </view>
  53. <!-- <view class="time">
  54. <text>{{ item.phone }} ({{ showLevel(item)}})</text>
  55. </view> -->
  56. <view class="time">
  57. <text>{{ item.time }}</text>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  63. </scroll-view>
  64. </swiper-item>
  65. </swiper>
  66. </view>
  67. </template>
  68. <script>
  69. import {
  70. myspread,
  71. getLevelList
  72. } from '@/api/user.js';
  73. import empty from '@/components/empty';
  74. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  75. import {
  76. mapState,
  77. mapMutations
  78. } from 'vuex';
  79. export default {
  80. components: {
  81. empty,
  82. uniLoadMore
  83. },
  84. onReady(res) {
  85. var _this = this;
  86. uni.getSystemInfo({
  87. success: resu => {
  88. const query = uni.createSelectorQuery();
  89. query.select('.swiper-box').boundingClientRect();
  90. query.exec(function(res) {
  91. _this.maxheight = resu.windowHeight - res[0].top + 'px';
  92. console.log('打印页面的剩余高度', _this.height);
  93. });
  94. },
  95. fail: res => {}
  96. });
  97. },
  98. data() {
  99. return {
  100. // 头部图高度
  101. maxheight: '',
  102. tabCurrentIndex: 0,
  103. navList: [{
  104. state: 0,
  105. text: '直接推荐',
  106. loadingType: 'more',
  107. orderList: [],
  108. page: 1, //当前页数
  109. limit: 10 //每次信息条数
  110. },
  111. {
  112. state: 1,
  113. text: '间接推荐',
  114. loadingType: 'more',
  115. orderList: [],
  116. page: 1, //当前页数
  117. limit: 10 //每次信息条数
  118. }],
  119. all: '',
  120. list: '',
  121. totalLevel: '',
  122. order: '',
  123. zt_order: '',
  124. jt_order: '',
  125. listList: []
  126. };
  127. },
  128. computed: {
  129. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin']),
  130. ...mapState(['baseURL'])
  131. },
  132. onLoad(options) {},
  133. onShow() {
  134. this.loadData();
  135. getLevelList().then(res => {
  136. console.log(res);
  137. this.listList = res.data.list
  138. })
  139. },
  140. methods: {
  141. showLevel(val) {
  142. let data = this.listList.find(item => item.grade == val.level)
  143. if(data) {
  144. return data.name
  145. }else {
  146. if(val.orderCount > 0) {
  147. return '会员'
  148. }else {
  149. return '粉丝'
  150. }
  151. }
  152. },
  153. // 页面跳转
  154. navto(e) {
  155. uni.navigateTo({
  156. url: e
  157. });
  158. },
  159. //获取收入支出信息
  160. async loadData(source) {
  161. //这里是将订单挂载到tab列表下
  162. let index = this.tabCurrentIndex;
  163. let navItem = this.navList[index];
  164. let state = navItem.state;
  165. if (source === 'tabChange' && navItem.loaded === true) {
  166. //tab切换只有第一次需要加载数据
  167. return;
  168. }
  169. if (navItem.loadingType === 'loading') {
  170. //防止重复加载
  171. return;
  172. }
  173. if (navItem.loadingType === 'noMore') {
  174. //防止重复加载
  175. return;
  176. }
  177. // 修改当前对象状态为加载中
  178. navItem.loadingType = 'loading';
  179. myspread({
  180. page: navItem.page,
  181. limit: navItem.limit,
  182. grade:state,
  183. uid: this.userInfo.uid
  184. })
  185. .then(({
  186. data
  187. }) => {
  188. console.log(data,'的');
  189. this.order = data.order
  190. this.zt_order = data.zt_order
  191. this.jt_order = data.jt_order
  192. this.all = data.total;
  193. this.totalLevel = data.totalLevel
  194. if (data.list.length > 0) {
  195. this.list = data.list;
  196. navItem.orderList = navItem.orderList.concat(data.list);
  197. navItem.page++;
  198. }
  199. this.$nextTick(function() {
  200. if (navItem.limit == data.list.length) {
  201. //判断是否还有数据, 有改为 more, 没有改为noMore
  202. navItem.loadingType = 'more';
  203. return;
  204. } else {
  205. //判断是否还有数据, 有改为 more, 没有改为noMore
  206. navItem.loadingType = 'noMore';
  207. }
  208. });
  209. this.$set(navItem, 'loaded', true);
  210. })
  211. .catch(e => {
  212. console.log(e);
  213. });
  214. },
  215. //swiper 切换
  216. changeTab(e) {
  217. this.tabCurrentIndex = e.target.current;
  218. this.loadData('tabChange');
  219. },
  220. //顶部tab点击
  221. tabClick(index) {
  222. this.tabCurrentIndex = index;
  223. },
  224. // 点击返回 我的页面
  225. toBack() {
  226. uni.switchTab({
  227. url: '/pages/user/user'
  228. });
  229. }
  230. }
  231. };
  232. </script>
  233. <style lang="scss">
  234. page {
  235. background: #f8f8f8;
  236. height: 100%;
  237. }
  238. .status_bar {
  239. height: var(--status-bar-height);
  240. width: 100%;
  241. background: #5dbc7c;
  242. }
  243. .content-money {
  244. position: relative;
  245. height: 480rpx;
  246. .content-bg {
  247. position: absolute;
  248. top: 0;
  249. left: 0;
  250. right: 0;
  251. width: 750rpx;
  252. height: 480rpx;
  253. image {
  254. width: 100%;
  255. height: 100%;
  256. }
  257. }
  258. .body-title {
  259. height: 80rpx;
  260. text-align: center;
  261. font-size: 35rpx;
  262. position: relative;
  263. .header {
  264. position: absolute;
  265. left: 0;
  266. top: 0;
  267. width: 100%;
  268. font-size: 36rpx;
  269. font-family: PingFang SC;
  270. font-weight: bold;
  271. color: $base-color;
  272. height: 80rpx;
  273. font-size: 36rpx;
  274. font-weight: 700;
  275. z-index: 9;
  276. display: flex;
  277. justify-content: center;
  278. align-items: center;
  279. }
  280. .goback-box {
  281. position: absolute;
  282. left: 18rpx;
  283. top: 0;
  284. height: 80rpx;
  285. display: flex;
  286. align-items: center;
  287. }
  288. .goback {
  289. z-index: 100;
  290. width: 34rpx;
  291. height: 34rpx;
  292. }
  293. }
  294. }
  295. .money-box {
  296. position: relative;
  297. z-index: 2;
  298. padding-top: 90rpx;
  299. color: $base-color;
  300. text-align: center;
  301. .money {
  302. font-size: 72rpx;
  303. font-family: PingFang SC;
  304. font-weight: bold;
  305. color: $base-color
  306. }
  307. .text {
  308. font-size: 30rpx;
  309. }
  310. }
  311. .order-item {
  312. padding: 20rpx 30rpx;
  313. line-height: 1.5;
  314. background-color: #fff;
  315. .title-box {
  316. width: 100%;
  317. .title-avatar {
  318. flex-shrink: 0;
  319. width: 100rpx;
  320. height: 100rpx;
  321. margin-right: 25rpx;
  322. border-radius: 100%;
  323. image {
  324. width: 100%;
  325. height: 100%;
  326. border-radius: 100%;
  327. }
  328. }
  329. .list_tpl {
  330. width: 85%;
  331. .title {
  332. display: flex;
  333. justify-content: flex-start;
  334. font-size: $font-lg;
  335. color: $font-color-base;
  336. overflow: hidden; //超出的文本隐藏
  337. text-overflow: ellipsis; //溢出用省略号显示
  338. white-space: nowrap;
  339. line-height: 1;
  340. text-align: center;
  341. .title-name {
  342. max-width: 40%;
  343. }
  344. .dl {
  345. margin-left: 10rpx;
  346. width: 93rpx;
  347. height: 32rpx;
  348. border-radius: 16rpx;
  349. image {
  350. width: 93rpx;
  351. height: 32rpx;
  352. border-radius: 16rpx;
  353. }
  354. }
  355. .class {
  356. display: inline-block;
  357. margin-left: 10rpx;
  358. padding: 6rpx;
  359. text-align: center;
  360. border: 1px solid #2e58ff;
  361. border-radius: 16rpx;
  362. font-size: 20rpx;
  363. font-family: PingFang SC;
  364. font-weight: 500;
  365. color: #2e58ff;
  366. }
  367. }
  368. .time {
  369. font-size: $font-lg;
  370. color: $font-color-light;
  371. }
  372. .star {
  373. justify-content: flex-start;
  374. image {
  375. width: 36rpx;
  376. height: 36rpx;
  377. }
  378. }
  379. }
  380. }
  381. .money {
  382. width: 50%;
  383. text-align: right;
  384. color: #db1935;
  385. font-size: $font-lg;
  386. }
  387. }
  388. .yeji {
  389. position: relative;
  390. margin: -72rpx auto 0;
  391. width: 690rpx;
  392. height: 143rpx;
  393. background: #ffffff;
  394. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
  395. border-radius: 10rpx;
  396. display: flex;
  397. align-items: center;
  398. .yeji-a {
  399. width: 50%;
  400. display: flex;
  401. flex-direction: column;
  402. justify-content: center;
  403. align-items: center;
  404. .yeji-top {
  405. font-size: 28rpx;
  406. font-family: PingFang SC;
  407. font-weight: bold;
  408. color: #333333;
  409. }
  410. .yeji-buttom {
  411. font-size: 42rpx;
  412. font-family: PingFang SC;
  413. font-weight: bold;
  414. color: #333333;
  415. }
  416. }
  417. .border {
  418. width: 1rpx;
  419. height: 51rpx;
  420. background: #dddddd;
  421. }
  422. }
  423. .buttom-box {
  424. position: relative;
  425. background-color: #ffffff;
  426. text-align: center;
  427. padding: 30rpx 0;
  428. .buttom {
  429. flex-grow: 1;
  430. }
  431. .money{
  432. font-size: 32rpx;
  433. font-weight: bold;
  434. color: $base-color;
  435. }
  436. .text {
  437. padding-bottom: 26rpx;
  438. font-size: 28rpx;
  439. font-weight: 500;
  440. color: #666666;
  441. &.current {
  442. border-bottom: 2px solid $base-color;
  443. }
  444. }
  445. .icon {
  446. height: 50rpx;
  447. width: 48rpx;
  448. margin: 0 auto;
  449. .icon-img {
  450. width: 100%;
  451. height: 100%;
  452. }
  453. }
  454. }
  455. </style>