balance.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <view class="content">
  3. <view class="header">
  4. <image src="../../static/user/yue.png" mode=""></image>
  5. <view class="integral">{{ userInfo.now_money * 1 }}</view>
  6. </view>
  7. <view class="navbar">
  8. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  9. </view>
  10. <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
  11. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  12. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  13. <!-- 空白页 -->
  14. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  15. <!-- 订单列表 -->
  16. <view v-for="(item, index) in tabItem.orderList" :key="index" class="order-item flex">
  17. <view class="title-box">
  18. <view class="title">
  19. <text>{{ item.title }}</text>
  20. </view>
  21. <view class="time">
  22. <text>{{ item.add_time }}</text>
  23. </view>
  24. </view>
  25. <view class="money">
  26. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  27. </view>
  28. </view>
  29. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  30. </scroll-view>
  31. </swiper-item>
  32. </swiper>
  33. <!-- <view class="button">
  34. <navigator url="/pages/user/integralTransforms" class="b-left">积分转账</navigator>
  35. <navigator url="/pages/user/exchangeIntegral" class="b-right">转换购物积分</navigator>
  36. </view> -->
  37. <button type="default" class="button" @click="navto('/pages/money/recharge')">立即充值</button>
  38. </view>
  39. </template>
  40. <script>
  41. import { spreadCommission, userBalance } from '@/api/wallet.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() {},
  51. data() {
  52. return {
  53. tabCurrentIndex: 0,
  54. navList: [
  55. {
  56. state: 2,
  57. text: '收入',
  58. loadingType: 'more',
  59. orderList: [],
  60. page: 1, //当前页数
  61. limit: 10 //每次信息条数
  62. },
  63. {
  64. state: 1,
  65. text: '支出',
  66. loadingType: 'more',
  67. orderList: [],
  68. page: 1, //当前页数
  69. limit: 10 //每次信息条数
  70. }
  71. ]
  72. };
  73. },
  74. onShow() {
  75. // 载入积分数据
  76. this.loadData();
  77. },
  78. methods: {
  79. // 页面跳转
  80. navto(e) {
  81. uni.navigateTo({
  82. url: e
  83. });
  84. },
  85. //获取收入支出信息
  86. async loadData(source) {
  87. //这里是将订单挂载到tab列表下
  88. let index = this.tabCurrentIndex;
  89. let navItem = this.navList[index];
  90. let state = navItem.state + 3;
  91. if (source === 'tabChange' && navItem.loaded === true) {
  92. //tab切换只有第一次需要加载数据
  93. return;
  94. }
  95. if (navItem.loadingType === 'loading') {
  96. //防止重复加载
  97. return;
  98. }
  99. // 修改当前对象状态为加载中
  100. navItem.loadingType = 'loading';
  101. spreadCommission(
  102. {
  103. page: navItem.page,
  104. limit: navItem.limit
  105. },
  106. state
  107. )
  108. .then(({ data }) => {
  109. if (data.length > 0) {
  110. navItem.orderList = navItem.orderList.concat(data[0].list);
  111. console.log(navItem.orderList);
  112. navItem.page++;
  113. }
  114. if (navItem.limit == data.length) {
  115. //判断是否还有数据, 有改为 more, 没有改为noMore
  116. navItem.loadingType = 'more';
  117. return;
  118. } else {
  119. //判断是否还有数据, 有改为 more, 没有改为noMore
  120. navItem.loadingType = 'noMore';
  121. }
  122. uni.hideLoading();
  123. this.$set(navItem, 'loaded', true);
  124. })
  125. .catch(e => {
  126. console.log(e);
  127. });
  128. },
  129. //swiper 切换
  130. changeTab(e) {
  131. console.log(e, '1111');
  132. this.tabCurrentIndex = e.target.current;
  133. this.loadData('tabChange');
  134. },
  135. //顶部tab点击
  136. tabClick(index) {
  137. this.tabCurrentIndex = index;
  138. }
  139. },
  140. computed: {
  141. //积分
  142. integral() {
  143. return this.$store.state.user.userInfo.integral;
  144. }
  145. }
  146. };
  147. </script>
  148. <style lang="scss">
  149. page {
  150. background: #ffffff;
  151. height: 100%;
  152. }
  153. .header {
  154. image {
  155. width: 100%;
  156. height: 400rpx;
  157. }
  158. .integral {
  159. width: 100%;
  160. text-align: center;
  161. position: absolute;
  162. top: 160rpx;
  163. color: #fff;
  164. font-size: 80rpx;
  165. font-weight: bold;
  166. }
  167. .right {
  168. position: absolute;
  169. top: 120rpx;
  170. right: 0;
  171. background-color: #fff;
  172. border-radius: 10rpx 0 0 10rpx;
  173. color: #438BED;
  174. padding: 5rpx 15rpx;
  175. font-size: 28rpx;
  176. }
  177. }
  178. .navbar {
  179. display: flex;
  180. height: 40px;
  181. padding: 0 5px;
  182. background: #fff;
  183. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  184. position: relative;
  185. z-index: 10;
  186. .nav-item {
  187. flex: 1;
  188. display: flex;
  189. justify-content: center;
  190. align-items: center;
  191. height: 100%;
  192. font-size: 15px;
  193. color: $font-color-dark;
  194. position: relative;
  195. &.current {
  196. color: #438BED;
  197. &:after {
  198. content: '';
  199. position: absolute;
  200. left: 50%;
  201. bottom: 0;
  202. transform: translateX(-50%);
  203. width: 44px;
  204. height: 0;
  205. border-bottom: 2px solid #438BED;
  206. }
  207. }
  208. }
  209. }
  210. // 列表
  211. .swiper-box {
  212. height: calc(100% - 180rpx - 400rpx);
  213. padding-top: 10rpx;
  214. .order-item {
  215. padding: 20rpx 30rpx;
  216. line-height: 1.5;
  217. .title-box {
  218. .title {
  219. font-size: $font-lg;
  220. color: $font-color-base;
  221. }
  222. .time {
  223. font-size: $font-base;
  224. color: $font-color-light;
  225. }
  226. }
  227. .money {
  228. color: #EF3A55;
  229. font-size: $font-lg;
  230. }
  231. }
  232. }
  233. .list-scroll-content {
  234. height: 100%;
  235. }
  236. .content {
  237. height: 100%;
  238. .empty-content {
  239. height: 100%;
  240. background-color: #ffffff;
  241. }
  242. }
  243. .button {
  244. position: relative;
  245. bottom: 0;
  246. bottom: 50rpx;
  247. width: 674rpx;
  248. height: 88rpx;
  249. background: linear-gradient(90deg, #44BFEC, #438BED);
  250. border-radius: 44rpx;
  251. font-size: 36rpx;
  252. font-family: PingFang SC;
  253. font-weight: 500;
  254. color: #FFFFFF;
  255. }
  256. </style>