jifen.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <view class="content">
  3. <!-- <view class="navbar">
  4. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  5. </view> -->
  6. <view class="header">
  7. <image src="../../static/user/shopping.png" mode=""></image>
  8. <view class="integral">
  9. {{ integral || '0.00' }}
  10. </view>
  11. <navigator url="/pages/money/conversionIntegral"><view class="right">转换USDT</view></navigator>
  12. </view>
  13. <view class="navbar">
  14. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  15. </view>
  16. <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
  17. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  18. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  19. <!-- 空白页 -->
  20. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  21. <!-- 订单列表 -->
  22. <view v-for="(item, index) in tabItem.orderList" :key="index" class="order-item flex">
  23. <view class="title-box">
  24. <view class="title">
  25. <text>{{ item.mark }}</text>
  26. </view>
  27. <view class="time">
  28. <text>{{ item.add_time }}</text>
  29. </view>
  30. </view>
  31. <view class="money">
  32. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  33. </view>
  34. </view>
  35. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  36. </scroll-view>
  37. </swiper-item>
  38. </swiper>
  39. <!-- <view class="button">
  40. <navigator url="/pages/user/integralTransforms" class="b-left">积分转账</navigator>
  41. <navigator url="/pages/user/exchangeIntegral" class="b-right">转换购物积分</navigator>
  42. </view> -->
  43. </view>
  44. </template>
  45. <script>
  46. import { integrallist } from '@/api/functionalUnit.js';
  47. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  48. import empty from '@/components/empty';
  49. export default {
  50. components: {
  51. empty,
  52. uniLoadMore
  53. },
  54. onReady() {
  55. },
  56. data() {
  57. return {
  58. tabCurrentIndex: 0,
  59. navList: [
  60. {
  61. state: 0,
  62. text: '收入',
  63. loadingType: 'more',
  64. orderList: [],
  65. page: 1, //当前页数
  66. limit: 10 //每次信息条数
  67. },
  68. {
  69. state: 1,
  70. text: '支出',
  71. loadingType: 'more',
  72. orderList: [],
  73. page: 1, //当前页数
  74. limit: 10 //每次信息条数
  75. },
  76. ],
  77. };
  78. },
  79. onShow() {
  80. // 载入积分数据
  81. this.loadData();
  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. integrallist(
  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);
  116. navItem.page++;
  117. }
  118. if (navItem.limit == data.length) {
  119. //判断是否还有数据, 有改为 more, 没有改为noMore
  120. navItem.loadingType = 'more';
  121. return;
  122. } else {
  123. //判断是否还有数据, 有改为 more, 没有改为noMore
  124. navItem.loadingType = 'noMore';
  125. }
  126. uni.hideLoading();
  127. this.$set(navItem, 'loaded', true);
  128. })
  129. .catch(e => {
  130. console.log(e);
  131. });
  132. },
  133. //swiper 切换
  134. changeTab(e) {
  135. this.tabCurrentIndex = e.target.current;
  136. this.loadData('tabChange');
  137. },
  138. //顶部tab点击
  139. tabClick(index) {
  140. this.tabCurrentIndex = index;
  141. }
  142. },
  143. computed: {
  144. //积分
  145. integral() {
  146. return this.$store.state.user.userInfo.integral
  147. }
  148. },
  149. };
  150. </script>
  151. <style lang="scss">
  152. page {
  153. background: #ffffff;
  154. height: 100%;
  155. }
  156. .header {
  157. image {
  158. width: 100%;
  159. height: 400rpx;
  160. }
  161. .integral {
  162. width: 100%;
  163. text-align: center;
  164. position: absolute;
  165. top: 160rpx;
  166. color: #fff;
  167. font-size: 80rpx;
  168. font-weight: bold;
  169. }
  170. .right {
  171. position: absolute;
  172. top: 120rpx;
  173. right: 0;
  174. background-color: #fff;
  175. border-radius: 10rpx 0 0 10rpx;
  176. color: #438BED;
  177. padding: 5rpx 15rpx;
  178. font-size: 28rpx;
  179. }
  180. }
  181. .navbar {
  182. display: flex;
  183. height: 40px;
  184. padding: 0 5px;
  185. background: #fff;
  186. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  187. position: relative;
  188. z-index: 10;
  189. .nav-item {
  190. flex: 1;
  191. display: flex;
  192. justify-content: center;
  193. align-items: center;
  194. height: 100%;
  195. font-size: 15px;
  196. color: $font-color-dark;
  197. position: relative;
  198. &.current {
  199. color: #438BED;
  200. &:after {
  201. content: '';
  202. position: absolute;
  203. left: 50%;
  204. bottom: 0;
  205. transform: translateX(-50%);
  206. width: 44px;
  207. height: 0;
  208. border-bottom: 2px solid #438BED;
  209. }
  210. }
  211. }
  212. }
  213. // 列表
  214. .swiper-box {
  215. height: calc(100% - 180rpx - 400rpx);
  216. padding-top: 10rpx;
  217. .order-item {
  218. padding: 20rpx 30rpx;
  219. line-height: 1.5;
  220. .title-box {
  221. .title {
  222. font-size: $font-lg;
  223. color: $font-color-base;
  224. }
  225. .time {
  226. font-size: $font-base;
  227. color: $font-color-light;
  228. }
  229. }
  230. .money {
  231. color: #EF3A55;
  232. font-size: $font-lg;
  233. }
  234. }
  235. }
  236. .list-scroll-content {
  237. height: 100%;
  238. }
  239. .content {
  240. height: 100%;
  241. .empty-content {
  242. background-color: #ffffff;
  243. }
  244. }
  245. .button {
  246. height: 180rpx;
  247. width: 100%;
  248. display: flex;
  249. position: absolute;
  250. padding: 40rpx 30rpx 60rpx 30rpx;
  251. bottom: 0;
  252. text-align: center;
  253. .b-left,.b-right {
  254. flex: 1;
  255. height: 80rpx;
  256. line-height: 80rpx;
  257. margin: 0 30rpx;
  258. border-radius: 50rpx;
  259. }
  260. .b-left {
  261. color: #438BED;
  262. border: solid 1rpx #438BED;
  263. }
  264. .b-right {
  265. background: linear-gradient(90deg, #438BED 0%, #44BFEC 100%);
  266. color: #fff;
  267. }
  268. }
  269. </style>