yongjin.vue 5.7 KB

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