mallPoints.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="content-bg"><image src="../../static/img/user-award.png" mode=""></image></view>
  5. <view class="money-box">
  6. <view class="money"> 2000 </view>
  7. </view>
  8. </view>
  9. <view class="navbar">
  10. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  11. </view>
  12. <swiper :current="tabCurrentIndex" :style="{ height: maxheight }" class="swiper-box" duration="300" @change="changeTab">
  13. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  14. <scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="loadData">
  15. <!-- 空白页 -->
  16. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  17. <!-- 订单列表 -->
  18. <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index">
  19. <view class="title-box">
  20. <view class="title">
  21. <text>{{ item.title }}</text>
  22. </view>
  23. <view class="time">
  24. <text>{{ item.add_time }}</text>
  25. </view>
  26. </view>
  27. <view class="money">
  28. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  29. </view>
  30. </view>
  31. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  32. </scroll-view>
  33. </swiper-item>
  34. </swiper>
  35. </view>
  36. </template>
  37. <script>
  38. import { spreadCommission, userBalance,USDT,getWallet } from '@/api/wallet.js';
  39. import { mapState, mapMutations } from 'vuex';
  40. import uniLoadMore from '@/uview-ui/components/u-loadmore/u-loadmore.vue';
  41. import empty from '@/uview-ui/components/u-empty/u-empty.vue';
  42. export default {
  43. components: {
  44. empty,
  45. uniLoadMore
  46. },
  47. onReady(res) {
  48. var _this = this;
  49. uni.getSystemInfo({
  50. success: resu => {
  51. const query = uni.createSelectorQuery();
  52. query.select('.swiper-box').boundingClientRect();
  53. query.exec(function(res) {
  54. _this.maxheight = resu.windowHeight - res[0].top + 'px';
  55. console.log('打印页面的剩余高度', _this.height);
  56. });
  57. },
  58. fail: res => {}
  59. });
  60. },
  61. data() {
  62. return {
  63. // 头部图高度
  64. maxheight: '',
  65. tabCurrentIndex: 0,
  66. navList: [
  67. {
  68. state: 0,
  69. text: '收入',
  70. loadingType: 'more',
  71. orderList: [],
  72. page: 1, //当前页面
  73. limit: 10 //每次信息条数
  74. },
  75. {
  76. state: 1,
  77. text: '支出',
  78. loadingType: 'more',
  79. orderList: [],
  80. page: 1, //当前页面
  81. limit: 10 //每次信息条数
  82. }
  83. ],
  84. money: 0
  85. };
  86. },
  87. onLoad(options) {},
  88. onShow() {
  89. this.loadData();
  90. this.getRecord()
  91. //获取用户余额
  92. userBalance({}).then(({ data }) => {
  93. console.log(data)
  94. this.money = data.now_money;
  95. });
  96. this.getMoneyLog()
  97. this.getUSDT()
  98. },
  99. methods: {
  100. async loadData(source) {
  101. //这里时将订单挂载到tab列表下
  102. let index = this.tabCurrentIndex;
  103. let navItem = this.navList[index];
  104. let state = navItem.state + 3;
  105. if (source === 'tabChange' && navItem.loaded === true) {
  106. //tab切换只有第一次需要加载数据
  107. return;
  108. }
  109. if (navItem.loadingType === 'loading') {
  110. //防止重复加载
  111. return;
  112. }
  113. //修改当前对象状态为加载中
  114. navItem.loadingType = 'loading';
  115. spreadCommission(
  116. {
  117. page: navItem.page,
  118. limit: navItem.limit
  119. },
  120. state
  121. )
  122. .then(({ data }) => {
  123. if (data.length > 0) {
  124. navItem.orderList = navItem.orderList.concat(data[0].list);
  125. console.log(navItem.orderList);
  126. navItem.page++;
  127. }
  128. //判断是否还有数据, 有改为more, 没有改为noMore
  129. if (navItem.limit == data.length) {
  130. navItem.loadingType = 'more';
  131. return;
  132. } else {
  133. navItem.loadingType = 'noMore';
  134. }
  135. uni.hideLoading();
  136. this.$set(navItem, 'loaded', true);
  137. })
  138. .catch(e => {
  139. console.log(e);
  140. });
  141. },
  142. //swiper 切换
  143. changeTab(e) {
  144. this.tabCurrentIndex = e.target.current;
  145. this.loadData('tabChange');
  146. },
  147. //顶部tab点击
  148. tabClick(index) {
  149. this.tabCurrentIndex = index;
  150. }
  151. }
  152. };
  153. </script>
  154. <style lang="scss">
  155. page {
  156. background: #f1f1f1;
  157. height: 100%;
  158. }
  159. .content-money {
  160. padding-bottom: 30rpx;
  161. position: relative;
  162. height: 400rpx;
  163. .content-bg {
  164. position: absolute;
  165. top: 0;
  166. left: 0;
  167. right: 0;
  168. width: 750rpx;
  169. height: 400rpx;
  170. image {
  171. width: 100%;
  172. height: 100%;
  173. }
  174. }
  175. }
  176. .money-box {
  177. position: relative;
  178. z-index: 100;
  179. padding-top: 150rpx;
  180. color: #ffffff;
  181. text-align: center;
  182. .money {
  183. font-size: 86rpx;
  184. font-family: PingFang SC;
  185. font-weight: bold;
  186. color: #FFFFFF;
  187. }
  188. }
  189. .navbar {
  190. margin-top: 20rpx;
  191. display: flex;
  192. height: 88rpx;
  193. padding: 0 5px;
  194. background: #fff;
  195. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  196. position: relative;
  197. z-index: 10;
  198. .nav-item {
  199. flex: 1;
  200. display: flex;
  201. justify-content: center;
  202. align-items: center;
  203. height: 100%;
  204. font-size: 15px;
  205. color: $font-color-dark;
  206. position: relative;
  207. &.current {
  208. color: $base-color;
  209. &:after {
  210. content: '';
  211. position: absolute;
  212. left: 50%;
  213. bottom: 0;
  214. transform: translateX(-50%);
  215. width: 44px;
  216. height: 0;
  217. border-bottom: 2px solid $base-color;
  218. }
  219. }
  220. }
  221. }
  222. //列表
  223. .swiper-box {
  224. .order-item {
  225. padding: 20rpx 30rpx;
  226. line-height: 1.5;
  227. .title-box {
  228. .title {
  229. font-size: $font-lg;
  230. color: $font-color-base;
  231. }
  232. .time {
  233. font-size: $font-base;
  234. color: $font-color-light;
  235. }
  236. }
  237. .money {
  238. color: #EF3A55;
  239. font-size: $font-lg + 5rpx;
  240. }
  241. }
  242. }
  243. .list-scroll-content {
  244. background: #ffffff;
  245. height: 100%;
  246. }
  247. .content {
  248. height: 100%;
  249. .empty-content {
  250. background-color: #ffffff;
  251. }
  252. }
  253. .btn-box {
  254. width: 674rpx;
  255. height: 88rpx;
  256. background: linear-gradient(0deg, #2E58FF, #32C6FF);
  257. border-radius: 44rpx;
  258. font-size: 36rpx;
  259. font-family: PingFang SC;
  260. font-weight: 500;
  261. color: #FFFFFF;
  262. text-align: center;
  263. line-height: 88rpx;
  264. position: fixed;
  265. bottom: 48rpx;
  266. left: 0;
  267. right: 0;
  268. margin: 0 auto;
  269. }
  270. </style>