extension.vue 11 KB

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