extension.vue 9.6 KB

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