yongjin.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <view class="content">
  3. <view class="header">
  4. <image src="../../static/user/yongjin.png" mode=""></image>
  5. <view class="integral">
  6. {{ integral || '0.00' }}
  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" class="swiper-box" duration="300" @change="changeTab">
  13. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  14. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  15. <!-- 空白页 -->
  16. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  17. <!-- 订单列表 -->
  18. <view v-for="(item, index) in tabItem.orderList" :key="index" class="order-item flex">
  19. <view class="title-box">
  20. <view class="title">
  21. <text>{{ item.mark }}</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 class="button">
  36. <navigator url="/pages/user/integralTransforms" class="b-left">积分转账</navigator>
  37. <navigator url="/pages/user/exchangeIntegral" class="b-right">转换购物积分</navigator>
  38. </view> -->
  39. <button type="default" class="button" @click="navto('/pages/money/withdraw')">立即提现</button>
  40. </view>
  41. </template>
  42. <script>
  43. import { integrallist } from '@/api/functionalUnit.js';
  44. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  45. import empty from '@/components/empty';
  46. export default {
  47. components: {
  48. empty,
  49. uniLoadMore
  50. },
  51. onReady() {
  52. },
  53. data() {
  54. return {
  55. tabCurrentIndex: 0,
  56. navList: [
  57. {
  58. state: 0,
  59. text: '收入',
  60. loadingType: 'more',
  61. orderList: [],
  62. page: 1, //当前页数
  63. limit: 10 //每次信息条数
  64. },
  65. {
  66. state: 1,
  67. text: '支出',
  68. loadingType: 'more',
  69. orderList: [],
  70. page: 1, //当前页数
  71. limit: 10 //每次信息条数
  72. },
  73. ],
  74. };
  75. },
  76. onShow() {
  77. // 载入积分数据
  78. this.loadData();
  79. },
  80. methods: {
  81. // 页面跳转
  82. navto(e) {
  83. uni.navigateTo({
  84. url: e
  85. });
  86. },
  87. //获取收入支出信息
  88. async loadData(source) {
  89. //这里是将订单挂载到tab列表下
  90. let index = this.tabCurrentIndex;
  91. let navItem = this.navList[index];
  92. let state = navItem.state;
  93. if (source === 'tabChange' && navItem.loaded === true) {
  94. //tab切换只有第一次需要加载数据
  95. return;
  96. }
  97. if (navItem.loadingType === 'loading') {
  98. //防止重复加载
  99. return;
  100. }
  101. // 修改当前对象状态为加载中
  102. navItem.loadingType = 'loading';
  103. integrallist(
  104. {
  105. page: navItem.page,
  106. limit: navItem.limit
  107. },
  108. state
  109. )
  110. .then(({ data }) => {
  111. if (data.length > 0) {
  112. navItem.orderList = navItem.orderList.concat(data);
  113. navItem.page++;
  114. }
  115. if (navItem.limit == data.length) {
  116. //判断是否还有数据, 有改为 more, 没有改为noMore
  117. navItem.loadingType = 'more';
  118. return;
  119. } else {
  120. //判断是否还有数据, 有改为 more, 没有改为noMore
  121. navItem.loadingType = 'noMore';
  122. }
  123. uni.hideLoading();
  124. this.$set(navItem, 'loaded', true);
  125. })
  126. .catch(e => {
  127. console.log(e);
  128. });
  129. },
  130. //swiper 切换
  131. changeTab(e) {
  132. console.log(e,'1111')
  133. this.tabCurrentIndex = e.target.current;
  134. this.loadData('tabChange');
  135. },
  136. //顶部tab点击
  137. tabClick(index) {
  138. this.tabCurrentIndex = index;
  139. }
  140. },
  141. computed: {
  142. //积分
  143. integral() {
  144. return this.$store.state.user.userInfo.integral
  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>