extension.vue 12 KB

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