extension.vue 7.9 KB

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