extension.vue 7.4 KB

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