extension.vue 7.4 KB

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