extension.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="money-box">
  5. <!-- <view class="goback-box" @click="toBack">
  6. <image class="goback" src="https://37shop.liuniu946.com/front/img/fanhui.png" mode=""></image>
  7. </view>
  8. <view class="header">我的推广</view> -->
  9. <image class="tuiguang_bg" src="../../static/img/tgbg.png"></image>
  10. <view class="money-frame">
  11. <!-- <view class="money_name">我的推广</view> -->
  12. <view class="money_num">
  13. {{userInfo.spread_count || '0'}}
  14. <text class="money_ren">人</text>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="flex buttom-box">
  19. <view class="buttom" @click="tabClick(0)">
  20. <view class="money">{{total || 0}}</view>
  21. <text class="text" :class="{ current: tabCurrentIndex === 0 }">一级推广</text>
  22. </view>
  23. <view class="buttom" @click="tabClick(1)">
  24. <view class="money">{{totalLevel || 0}}</view>
  25. <text class="text" :class="{ current: tabCurrentIndex === 1 }">二级推广</text>
  26. </view>
  27. </view>
  28. </view>
  29. <swiper :current="tabCurrentIndex" :style="{ height: maxheight + 'px' }" class="swiper-box" duration="300"
  30. @change="changeTab">
  31. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  32. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  33. <!-- 空白页 -->
  34. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  35. <!-- 订单列表 -->
  36. <view v-for="(item, index) in tabItem.orderList" :key="index" class="order-item flex">
  37. <view class="title-box flex_item">
  38. <view class="title-avatar">
  39. <image :src="item.avatar"></image>
  40. </view>
  41. <view class="list_tpl">
  42. <view class="title">
  43. <text>{{ item.nickname }}</text>
  44. </view>
  45. <view class="time">
  46. <text>{{ item.spread_time }}</text>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  52. </scroll-view>
  53. </swiper-item>
  54. </swiper>
  55. </view>
  56. </template>
  57. <script>
  58. import {
  59. getExtensionData,
  60. getUserInfo,
  61. getSpreadPeople
  62. } from '@/api/user.js';
  63. import {
  64. mapState,
  65. mapMutations
  66. } from 'vuex';
  67. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  68. import empty from '@/components/empty';
  69. export default {
  70. components: {
  71. empty,
  72. uniLoadMore,
  73. },
  74. onReady() {
  75. // 初始化获取页面宽度
  76. uni.createSelectorQuery()
  77. .select('.content')
  78. .fields({
  79. size: true
  80. },
  81. data => {
  82. // console.log(data);
  83. // console.log(Math.floor((data.width / 750) * 300));
  84. // 保存头部高度
  85. this.maxheight = data.height - Math.floor((data.width / 750) * 470) - 44;
  86. // console.log(this.maxheight);
  87. }
  88. )
  89. .exec();
  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. };
  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.total = data.total;
  168. this.totalLevel = data.totalLevel;
  169. // this.all = this.total + this.totalLevel;
  170. if (data.list.length > 0) {
  171. this.list = data.list;
  172. navItem.orderList = navItem.orderList.concat(data.list);
  173. navItem.page++;
  174. }
  175. this.$nextTick(function() {
  176. if (navItem.limit == data.list.length) {
  177. //判断是否还有数据, 有改为 more, 没有改为noMore
  178. navItem.loadingType = 'more';
  179. return;
  180. } else {
  181. //判断是否还有数据, 有改为 more, 没有改为noMore
  182. navItem.loadingType = 'noMore';
  183. }
  184. })
  185. this.$set(navItem, 'loaded', true);
  186. })
  187. .catch(e => {
  188. console.log(e);
  189. });
  190. },
  191. //swiper 切换
  192. changeTab(e) {
  193. this.tabCurrentIndex = e.target.current;
  194. this.loadData('tabChange');
  195. },
  196. //顶部tab点击
  197. tabClick(index) {
  198. this.tabCurrentIndex = index;
  199. },
  200. // 点击返回 我的页面
  201. toBack() {
  202. uni.switchTab({
  203. url: '/pages/user/user'
  204. })
  205. },
  206. loadAll() {
  207. getUserInfo().then(res => {
  208. this.userInfo = res.data
  209. console.log(res, '6666666666666666666')
  210. });
  211. }
  212. }
  213. };
  214. </script>
  215. <style lang="scss">
  216. page {
  217. background: #ffffff;
  218. height: 100%;
  219. }
  220. .content-money {
  221. padding-bottom: 30rpx;
  222. background: $page-color-base;
  223. .buttom-box {
  224. position: relative;
  225. background-color: #ffffff;
  226. text-align: center;
  227. margin: 0 30rpx;
  228. padding: 30rpx 0;
  229. box-shadow: 0px 0px 20px 0px rgba(50, 50, 52, 0.06);
  230. border-radius: $border-radius-sm;
  231. margin-top: -60rpx;
  232. .buttom {
  233. flex-grow: 1;
  234. }
  235. .money {
  236. font-size: 32rpx;
  237. font-weight: bold;
  238. color: #921a23;
  239. }
  240. .text {
  241. padding-bottom: 26rpx;
  242. font-size: 28rpx;
  243. font-weight: 500;
  244. color: #666666;
  245. &.current {
  246. border-bottom: 2px solid #921a23;
  247. }
  248. }
  249. .icon {
  250. height: 50rpx;
  251. width: 48rpx;
  252. margin: 0 auto;
  253. .icon-img {
  254. width: 100%;
  255. height: 100%;
  256. }
  257. }
  258. }
  259. }
  260. .money-box {
  261. // background: $base-color;
  262. height: 380rpx;
  263. color: #ffffff;
  264. text-align: center;
  265. font-size: 35rpx;
  266. position: relative;
  267. // padding-top: 60rpx;
  268. .header {
  269. position: absolute;
  270. left: 0;
  271. top: 0;
  272. width: 100%;
  273. height: 80rpx;
  274. font-size: 36rpx;
  275. font-weight: bold;
  276. z-index: 99;
  277. display: flex;
  278. justify-content: center;
  279. align-items: center;
  280. }
  281. .goback-box {
  282. position: absolute;
  283. left: 29rpx;
  284. top: 0;
  285. height: 80rpx;
  286. display: flex;
  287. align-items: center;
  288. }
  289. .goback {
  290. z-index: 100;
  291. width: 34rpx;
  292. height: 34rpx;
  293. }
  294. .tuiguang_bg {
  295. width: 100%;
  296. height: 400rpx;
  297. position: relative;
  298. }
  299. .money_img {
  300. width: 100%;
  301. height: 120rpx;
  302. text-align: center;
  303. padding-top: 50rpx;
  304. padding-bottom: 135rpx;
  305. image {
  306. width: 120rpx;
  307. height: 120rpx;
  308. border: 4rpx solid #FD5F6F;
  309. border-radius: 50%;
  310. }
  311. }
  312. .money-frame {
  313. position: absolute;
  314. top: 0;
  315. width: 100%;
  316. padding-top: 120rpx;
  317. // left: 30rpx;
  318. // height: 460rpx;
  319. // display: flex;
  320. // align-items: flex-start;
  321. // flex-direction: column;
  322. // justify-content: center;
  323. }
  324. .money_name {
  325. width: 100%;
  326. text-align: center;
  327. font-size: 32rpx;
  328. font-family: PingFang SC;
  329. font-weight: bold;
  330. color: #FFFFFF;
  331. }
  332. .money_num {
  333. font-size: 72rpx;
  334. font-family: PingFang SC;
  335. font-weight: bold;
  336. color: #FFFFFF;
  337. .money_ren {
  338. font-size: 36rpx;
  339. }
  340. }
  341. }
  342. // 列表
  343. .swiper-box {
  344. padding-top: 10rpx;
  345. .order-item {
  346. padding: 20rpx 30rpx;
  347. line-height: 1.5;
  348. .title-box {
  349. width: 100%;
  350. .title-avatar {
  351. width: 100rpx;
  352. height: 100rpx;
  353. margin-right: 25rpx;
  354. image {
  355. width: 100%;
  356. height: 100%;
  357. border-radius: 100%;
  358. }
  359. }
  360. .list_tpl {
  361. width: 85%;
  362. .title {
  363. font-size: $font-lg;
  364. color: $font-color-base;
  365. overflow: hidden; //超出的文本隐藏
  366. text-overflow: ellipsis; //溢出用省略号显示
  367. white-space: nowrap;
  368. }
  369. .time {
  370. margin-top: 15rpx;
  371. font-size: 22rpx;
  372. color: $font-color-light;
  373. }
  374. }
  375. }
  376. .money {
  377. color: #DB1935;
  378. font-size: $font-lg;
  379. }
  380. }
  381. }
  382. .list-scroll-content {
  383. height: 100%;
  384. }
  385. .content {
  386. height: 100%;
  387. .empty-content {
  388. background-color: #ffffff;
  389. }
  390. }
  391. </style>