mytg.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  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/zhihuanjuan.png" mode=""></image>
  15. </view>
  16. <view class="money-box">
  17. <view class="" style="width: 50%;">
  18. <view class="money">{{ total || '0' }}</view>
  19. <view>我的推广人数</view>
  20. </view>
  21. <view class="" style="width: 50%;">
  22. <view class="money">{{ order_count || '0' }}</view>
  23. <view>团队业绩</view>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="navbar">
  28. <view v-for="(item, index) in navList" :key="index" class="nav-item"
  29. :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  30. </view>
  31. <swiper :current="tabCurrentIndex" :style="{ height: maxheight + 'px' }" class="swiper-box" duration="300"
  32. @change="changeTab">
  33. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  34. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  35. <!-- 空白页 -->
  36. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  37. <!-- 订单列表 -->
  38. <view v-for="(item, index) in tabItem.orderList" :key="index" class="order-item flex">
  39. <view class="title-box flex_item">
  40. <view class="title-avatar">
  41. <image :src="item.avatar"></image>
  42. </view>
  43. <view class="list_tpl">
  44. <view class="title">
  45. <text>{{ item.phone || '' }}</text>
  46. </view>
  47. <view class="time">
  48. <text>业绩:{{ item.numberCount || '0' }}</text>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  54. </scroll-view>
  55. </swiper-item>
  56. </swiper>
  57. </view>
  58. </template>
  59. <script>
  60. import {
  61. getExtensionData,
  62. getUserInfo,
  63. getSpreadPeople
  64. } from '@/api/user.js';
  65. import {
  66. mapState,
  67. mapMutations
  68. } from 'vuex';
  69. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  70. import empty from '@/components/empty';
  71. export default {
  72. components: {
  73. empty,
  74. uniLoadMore,
  75. },
  76. onReady() {
  77. // 初始化获取页面宽度
  78. var obj = this;
  79. uni.getSystemInfo({
  80. success: resu => {
  81. const query = uni.createSelectorQuery();
  82. query.select('.swiper-box').boundingClientRect();
  83. query.exec(function(res) {
  84. obj.maxheight = resu.windowHeight - res[0].top;
  85. });
  86. },
  87. fail: res => {}
  88. });
  89. },
  90. data() {
  91. return {
  92. // 头部图高度
  93. maxheight: '',
  94. tabCurrentIndex: 0,
  95. navList: [{
  96. state: 0,
  97. text: '直接推广',
  98. loadingType: 'more',
  99. orderList: [],
  100. page: 1, //当前页数
  101. limit: 10 //每次信息条数
  102. },
  103. {
  104. state: 1,
  105. text: '我的团队',
  106. loadingType: 'more',
  107. orderList: [],
  108. page: 1, //当前页数
  109. limit: 10 //每次信息条数
  110. }
  111. ],
  112. all: '',
  113. list: '',
  114. total: '',
  115. totalLevel: '',
  116. img: 'http://kaifa.crmeb.net/uploads/attach/2019/08/20190807/723adbdd4e49a0f9394dfc700ab5dba3.png',
  117. userInfo: {},
  118. order_count: '',
  119. };
  120. },
  121. onLoad(options) {},
  122. onShow() {
  123. this.loadData();
  124. this.loadAll()
  125. },
  126. methods: {
  127. // 页面跳转
  128. navto(e) {
  129. uni.navigateTo({
  130. url: e
  131. });
  132. },
  133. //获取推广人数信息
  134. async loadData(source) {
  135. //这里是将订单挂载到tab列表下
  136. let index = this.tabCurrentIndex;
  137. let navItem = this.navList[index];
  138. let state = navItem.state;
  139. if (source === 'tabChange' && navItem.loaded === true) {
  140. //tab切换只有第一次需要加载数据
  141. return;
  142. }
  143. if (navItem.loadingType === 'loading') {
  144. //防止重复加载
  145. return;
  146. }
  147. if (navItem.loadingType === 'noMore') {
  148. //防止重复加载
  149. return;
  150. }
  151. // 修改当前对象状态为加载中
  152. navItem.loadingType = 'loading';
  153. getSpreadPeople({
  154. page: navItem.page,
  155. limit: navItem.limit,
  156. keyword: '',
  157. // sort: 'ASC/DESC',
  158. // level: index,
  159. // sort:'uid desc'
  160. // sort: 'pay_price ASC'
  161. grade: state
  162. }, )
  163. .then(({
  164. data
  165. }) => {
  166. console.log(data);
  167. this.order_count = data.order_count
  168. this.total = data.total;
  169. this.totalLevel = data.totalLevel;
  170. // this.all = this.total + this.totalLevel;
  171. if (data.list.length > 0) {
  172. this.list = data.list;
  173. navItem.orderList = navItem.orderList.concat(data.list);
  174. navItem.page++;
  175. }
  176. this.$nextTick(function() {
  177. if (navItem.limit == data.list.length) {
  178. //判断是否还有数据, 有改为 more, 没有改为noMore
  179. navItem.loadingType = 'more';
  180. return;
  181. } else {
  182. //判断是否还有数据, 有改为 more, 没有改为noMore
  183. navItem.loadingType = 'noMore';
  184. }
  185. })
  186. this.$set(navItem, 'loaded', true);
  187. })
  188. .catch(e => {
  189. console.log(e);
  190. });
  191. },
  192. //swiper 切换
  193. changeTab(e) {
  194. this.tabCurrentIndex = e.target.current;
  195. this.loadData('tabChange');
  196. },
  197. //顶部tab点击
  198. tabClick(index) {
  199. this.tabCurrentIndex = index;
  200. },
  201. // 点击返回 我的页面
  202. toBack() {
  203. uni.switchTab({
  204. url: '/pages/user/user'
  205. })
  206. },
  207. loadAll() {
  208. getUserInfo().then(res => {
  209. this.userInfo = res.data
  210. console.log(res, '6666666666666666666')
  211. });
  212. }
  213. }
  214. };
  215. </script>
  216. <style lang="scss">
  217. page {
  218. background: #ffffff;
  219. height: 100%;
  220. }
  221. .status_bar {
  222. height: var(--status-bar-height);
  223. width: 100%;
  224. }
  225. .content-money {
  226. position: relative;
  227. height: 480rpx;
  228. .content-bg {
  229. position: absolute;
  230. top: 0;
  231. left: 0;
  232. right: 0;
  233. width: 750rpx;
  234. height: 480rpx;
  235. image {
  236. width: 100%;
  237. height: 100%;
  238. }
  239. }
  240. .body-title {
  241. height: 80rpx;
  242. text-align: center;
  243. font-size: 35rpx;
  244. position: relative;
  245. .header {
  246. position: absolute;
  247. left: 0;
  248. top: 0;
  249. width: 100%;
  250. font-size: 36rpx;
  251. font-family: PingFang SC;
  252. font-weight: bold;
  253. color: #fffeff;
  254. height: 80rpx;
  255. font-size: 36rpx;
  256. font-weight: 700;
  257. z-index: 9;
  258. display: flex;
  259. justify-content: center;
  260. align-items: center;
  261. }
  262. .goback-box {
  263. position: absolute;
  264. left: 18rpx;
  265. top: 0;
  266. height: 80rpx;
  267. display: flex;
  268. align-items: center;
  269. }
  270. .goback {
  271. z-index: 100;
  272. width: 34rpx;
  273. height: 34rpx;
  274. }
  275. }
  276. }
  277. .money-box {
  278. position: relative;
  279. z-index: 2;
  280. /* #ifdef H5 */
  281. padding-top: 80rpx;
  282. /* #endif */
  283. color: #ffffff;
  284. text-align: center;
  285. /* #ifdef APP-PLUS */
  286. height: 250rpx;
  287. display: flex;
  288. flex-direction: column;
  289. justify-content: center;
  290. /* #endif */
  291. display: flex;
  292. justify-content: center;
  293. .money {
  294. font-size: 72rpx;
  295. font-family: PingFang SC;
  296. font-weight: bold;
  297. color: #ffffff;
  298. }
  299. .text {
  300. font-size: 30rpx;
  301. }
  302. }
  303. // 列表
  304. .swiper-box {
  305. padding-top: 10rpx;
  306. .order-item {
  307. padding: 20rpx 30rpx;
  308. line-height: 1.5;
  309. .title-box {
  310. width: 100%;
  311. .title-avatar {
  312. width: 100rpx;
  313. height: 100rpx;
  314. margin-right: 25rpx;
  315. image {
  316. width: 100%;
  317. height: 100%;
  318. border-radius: 100%;
  319. }
  320. }
  321. .list_tpl {
  322. width: 85%;
  323. .title {
  324. font-size: $font-lg;
  325. color: $font-color-base;
  326. overflow: hidden; //超出的文本隐藏
  327. text-overflow: ellipsis; //溢出用省略号显示
  328. white-space: nowrap;
  329. }
  330. .time {
  331. margin-top: 15rpx;
  332. font-size: 22rpx;
  333. color: $font-color-light;
  334. }
  335. }
  336. }
  337. .money {
  338. color: #DB1935;
  339. font-size: $font-lg;
  340. }
  341. }
  342. }
  343. .list-scroll-content {
  344. height: 100%;
  345. }
  346. .content {
  347. height: 100%;
  348. .empty-content {
  349. background-color: #ffffff;
  350. }
  351. }
  352. .navbar {
  353. margin-top: 20rpx;
  354. display: flex;
  355. height: 88rpx;
  356. padding: 0 5px;
  357. background: #fff;
  358. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  359. position: relative;
  360. z-index: 10;
  361. .nav-item {
  362. flex: 1;
  363. display: flex;
  364. justify-content: center;
  365. align-items: center;
  366. height: 100%;
  367. font-size: 15px;
  368. color: #999999;
  369. position: relative;
  370. &.current {
  371. color: #000;
  372. &:after {
  373. content: '';
  374. position: absolute;
  375. left: 50%;
  376. bottom: 0;
  377. transform: translateX(-50%);
  378. width: 44px;
  379. height: 0;
  380. border-bottom: 2px solid #fe5b38;
  381. }
  382. }
  383. }
  384. }
  385. </style>