mytg.vue 9.0 KB

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