team.vue 11 KB

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