yongjin.vue 5.8 KB

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