extension.vue 9.2 KB

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