mytg.vue 9.0 KB

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