extension.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  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.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 } 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. };
  112. },
  113. onLoad(options) {},
  114. onShow() {
  115. this.loadData();
  116. },
  117. methods: {
  118. // 页面跳转
  119. navto(e) {
  120. uni.navigateTo({
  121. url: e
  122. });
  123. },
  124. //获取推广人数信息
  125. async loadData(source) {
  126. //这里是将订单挂载到tab列表下
  127. let index = this.tabCurrentIndex;
  128. let navItem = this.navList[index];
  129. let state = navItem.state;
  130. if (source === 'tabChange' && navItem.loaded === true) {
  131. //tab切换只有第一次需要加载数据
  132. return;
  133. }
  134. if (navItem.loadingType === 'loading') {
  135. //防止重复加载
  136. return;
  137. }
  138. if (navItem.loadingType === 'noMore') {
  139. //防止重复加载
  140. return;
  141. }
  142. // 修改当前对象状态为加载中
  143. navItem.loadingType = 'loading';
  144. getExtensionData(
  145. {
  146. page: navItem.page,
  147. limit: navItem.limit,
  148. keyword:'',
  149. sort:'uid desc',
  150. grade:state
  151. },
  152. )
  153. .then(({ data }) => {
  154. console.log(data);
  155. this.total = data.total;
  156. this.totalLevel =data.totalLevel;
  157. this.all = this.total + this.totalLevel;
  158. if (data.list.length > 0) {
  159. this.list = data.list;
  160. navItem.orderList = navItem.orderList.concat(data.list);
  161. navItem.page++;
  162. }
  163. this.$nextTick(function(){
  164. if (navItem.limit == data.list.length) {
  165. //判断是否还有数据, 有改为 more, 没有改为noMore
  166. navItem.loadingType = 'more';
  167. return;
  168. } else {
  169. //判断是否还有数据, 有改为 more, 没有改为noMore
  170. navItem.loadingType = 'noMore';
  171. }
  172. })
  173. this.$set(navItem, 'loaded', true);
  174. })
  175. .catch(e => {
  176. console.log(e);
  177. });
  178. },
  179. //swiper 切换
  180. changeTab(e) {
  181. this.tabCurrentIndex = e.target.current;
  182. this.loadData('tabChange');
  183. },
  184. //顶部tab点击
  185. tabClick(index) {
  186. this.tabCurrentIndex = index;
  187. },
  188. // 点击返回 我的页面
  189. toBack(){
  190. uni.switchTab({
  191. url:'/pages/user/user'
  192. })
  193. }
  194. }
  195. };
  196. </script>
  197. <style lang="scss">
  198. page {
  199. background: #ffffff;
  200. height: 100%;
  201. }
  202. .content-money {
  203. padding-bottom: 30rpx;
  204. background: $page-color-base;
  205. .buttom-box {
  206. position: relative;
  207. background-color: #ffffff;
  208. text-align: center;
  209. margin: 0 30rpx;
  210. padding: 30rpx 0;
  211. box-shadow: 0px 0px 20px 0px rgba(50, 50, 52, 0.06);
  212. border-radius: $border-radius-sm;
  213. margin-top: -60rpx;
  214. .buttom {
  215. flex-grow: 1;
  216. }
  217. .money{
  218. font-size: 32rpx;
  219. font-weight: bold;
  220. color: #921a23;
  221. }
  222. .text {
  223. padding-bottom: 26rpx;
  224. font-size: 28rpx;
  225. font-weight: 500;
  226. color: #666666;
  227. &.current {
  228. border-bottom: 2px solid #921a23;
  229. }
  230. }
  231. .icon {
  232. height: 50rpx;
  233. width: 48rpx;
  234. margin: 0 auto;
  235. .icon-img {
  236. width: 100%;
  237. height: 100%;
  238. }
  239. }
  240. }
  241. }
  242. .money-box {
  243. // background: $base-color;
  244. height: 380rpx;
  245. color: #ffffff;
  246. text-align: center;
  247. font-size: 35rpx;
  248. position: relative;
  249. // padding-top: 60rpx;
  250. .header{
  251. position: absolute;
  252. left: 0;
  253. top: 0;
  254. width: 100%;
  255. height: 80rpx;
  256. font-size: 36rpx;
  257. font-weight: bold;
  258. z-index: 99;
  259. display: flex;
  260. justify-content: center;
  261. align-items: center;
  262. }
  263. .goback-box{
  264. position: absolute;
  265. left: 29rpx;
  266. top: 0;
  267. height: 80rpx;
  268. display: flex;
  269. align-items: center;
  270. }
  271. .goback{
  272. z-index: 100;
  273. width: 34rpx;
  274. height: 34rpx;
  275. }
  276. .tuiguang_bg {
  277. width: 100%;
  278. height: 400rpx;
  279. position: relative;
  280. }
  281. .money_img{
  282. width: 100%;
  283. height: 120rpx;
  284. text-align: center;
  285. padding-top: 50rpx;
  286. padding-bottom: 135rpx;
  287. image{
  288. width:120rpx;
  289. height: 120rpx;
  290. border: 4rpx solid #FD5F6F;
  291. border-radius: 50%;
  292. }
  293. }
  294. .money-frame {
  295. position: absolute;
  296. top: 0;
  297. width: 100%;
  298. padding-top: 120rpx;
  299. // left: 30rpx;
  300. // height: 460rpx;
  301. // display: flex;
  302. // align-items: flex-start;
  303. // flex-direction: column;
  304. // justify-content: center;
  305. }
  306. .money_name{
  307. width: 100%;
  308. text-align: center;
  309. font-size: 32rpx;
  310. font-family: PingFang SC;
  311. font-weight: bold;
  312. color: #FFFFFF;
  313. }
  314. .money_num {
  315. font-size: 72rpx;
  316. font-family: PingFang SC;
  317. font-weight: bold;
  318. color: #FFFFFF;
  319. .money_ren {
  320. font-size: 36rpx;
  321. }
  322. }
  323. }
  324. // 列表
  325. .swiper-box {
  326. padding-top: 10rpx;
  327. .order-item {
  328. padding: 20rpx 30rpx;
  329. line-height: 1.5;
  330. .title-box {
  331. width: 100%;
  332. .title-avatar{
  333. width: 100rpx;
  334. height: 100rpx;
  335. margin-right: 25rpx;
  336. image{
  337. width: 100%;
  338. height: 100%;
  339. border-radius: 100%;
  340. }
  341. }
  342. .list_tpl{
  343. width: 85%;
  344. .title {
  345. font-size: $font-lg;
  346. color: $font-color-base;
  347. overflow:hidden; //超出的文本隐藏
  348. text-overflow:ellipsis; //溢出用省略号显示
  349. white-space:nowrap;
  350. }
  351. .time {
  352. margin-top: 15rpx;
  353. font-size: 22rpx;
  354. color: $font-color-light;
  355. }
  356. }
  357. }
  358. .money {
  359. color: #DB1935;
  360. font-size: $font-lg;
  361. }
  362. }
  363. }
  364. .list-scroll-content {
  365. height: 100%;
  366. }
  367. .content {
  368. height: 100%;
  369. .empty-content {
  370. background-color: #ffffff;
  371. }
  372. }
  373. </style>