extension.vue 10 KB

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