mytg.vue 8.7 KB

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