extension.vue 11 KB

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