scoreAccumulate.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="money-box">
  5. <view class="text">
  6. 我的积分
  7. </view>
  8. <view class="money">{{ userInfo.integral | getMoneyStyle }}</view>
  9. </view>
  10. </view>
  11. <view class="navbar">
  12. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  13. </view>
  14. <swiper :current="tabCurrentIndex" :style="{ height: maxheight }" class="swiper-box" duration="300" @change="changeTab">
  15. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  16. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  17. <!-- 空白页 -->
  18. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  19. <!-- 订单列表 -->
  20. <template>
  21. <view v-for="(item, i) in tabItem.orderList" class="order-item flex">
  22. <view class="title-box">
  23. <view class="title">
  24. <text>{{ item.title }}</text>
  25. </view>
  26. <view class="time">
  27. <text>{{ item.add_time }}</text>
  28. </view>
  29. </view>
  30. <view class="money">
  31. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  32. </view>
  33. </view>
  34. </template>
  35. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  36. </scroll-view>
  37. </swiper-item>
  38. </swiper>
  39. </view>
  40. </template>
  41. <script>
  42. import { integral, userBalance } from '@/api/wallet.js';
  43. import { mapState, mapMutations } from 'vuex';
  44. import { getMoneyStyle } from '@/utils/rocessor.js';
  45. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  46. import empty from '@/components/empty';
  47. export default {
  48. filters: {
  49. getMoneyStyle
  50. },
  51. components: {
  52. empty,
  53. uniLoadMore
  54. },
  55. onReady(res) {
  56. // 初始化获取页面宽度
  57. var _this = this;
  58. uni.getSystemInfo({
  59. success: resu => {
  60. const query = uni.createSelectorQuery();
  61. query.select('.swiper-box').boundingClientRect();
  62. query.exec(function(res) {
  63. _this.maxheight = resu.windowHeight - res[0].top + 'px';
  64. console.log('打印页面的剩余高度', _this.height);
  65. });
  66. },
  67. fail: res => {}
  68. });
  69. },
  70. data() {
  71. return {
  72. // 头部图高度
  73. maxheight: '',
  74. tabCurrentIndex: 0,
  75. navList: [
  76. {
  77. state: 1,
  78. text: '收入',
  79. loadingType: 'more',
  80. orderList: [],
  81. page: 1, //当前页数
  82. limit: 10 //每次信息条数
  83. },
  84. {
  85. state: 0,
  86. text: '支出',
  87. loadingType: 'more',
  88. orderList: [],
  89. page: 1, //当前页数
  90. limit: 10 //每次信息条数
  91. }
  92. ],
  93. money: ''
  94. };
  95. },
  96. onLoad(options) {
  97. this.loadData();
  98. },
  99. computed: {
  100. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  101. },
  102. methods: {
  103. // 页面跳转
  104. navto(e) {
  105. uni.navigateTo({
  106. url: e
  107. });
  108. },
  109. //获取收入支出信息
  110. async loadData(source) {
  111. //这里是将订单挂载到tab列表下
  112. let index = this.tabCurrentIndex;
  113. let navItem = this.navList[index];
  114. let state = navItem.state;
  115. if (source === 'tabChange' && navItem.loaded === true) {
  116. //tab切换只有第一次需要加载数据
  117. return;
  118. }
  119. if (navItem.loadingType === 'noMore') {
  120. //防止重复加载
  121. return;
  122. }
  123. // 修改当前对象状态为加载中
  124. navItem.loadingType = 'loading';
  125. integral(
  126. {
  127. page: navItem.page,
  128. limit: navItem.limit,
  129. pm: state
  130. }
  131. )
  132. .then(({ data }) => {
  133. console.log(data)
  134. navItem.orderList = navItem.orderList.concat(data);
  135. console.log(navItem.orderList,'123465')
  136. navItem.page++;
  137. if (navItem.limit == data.length) {
  138. //判断是否还有数据, 有改为 more, 没有改为noMore
  139. navItem.loadingType = 'more';
  140. return;
  141. } else {
  142. //判断是否还有数据, 有改为 more, 没有改为noMore
  143. navItem.loadingType = 'noMore';
  144. }
  145. uni.hideLoading();
  146. this.$set(navItem, 'loaded', true);
  147. })
  148. .catch(e => {
  149. console.log(e);
  150. });
  151. },
  152. //swiper 切换
  153. changeTab(e) {
  154. this.tabCurrentIndex = e.target.current;
  155. this.loadData('tabChange');
  156. },
  157. //顶部tab点击
  158. tabClick(index) {
  159. this.tabCurrentIndex = index;
  160. },
  161. // 点击返回 我的页面
  162. toBack() {
  163. uni.switchTab({
  164. url: '/pages/user/user'
  165. });
  166. }
  167. }
  168. };
  169. </script>
  170. <style lang="scss">
  171. page {
  172. background: #ffffff;
  173. height: 100%;
  174. }
  175. .content-money {
  176. padding-bottom: 30rpx;
  177. background: $page-color-base;
  178. // border: 2px solid #ffffff;
  179. // padding-top: var(--status-bar-height);
  180. .money-box {
  181. background-color: $base-color;
  182. padding-top: var(--status-bar-height);
  183. height: 368rpx;
  184. color: #ffffff;
  185. text-align: center;
  186. .text {
  187. padding-top: 147rpx;
  188. font-size: $font-sm;
  189. }
  190. .money {
  191. font-size: 56rpx;
  192. }
  193. }
  194. }
  195. .navbar {
  196. display: flex;
  197. height: 40px;
  198. padding: 0 5px;
  199. background: #fff;
  200. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  201. position: relative;
  202. z-index: 10;
  203. .nav-item {
  204. flex: 1;
  205. display: flex;
  206. justify-content: center;
  207. align-items: center;
  208. height: 100%;
  209. font-size: 15px;
  210. color: #999999;
  211. position: relative;
  212. &.current {
  213. color: #5dbc7c;
  214. &:after {
  215. content: '';
  216. position: absolute;
  217. left: 50%;
  218. bottom: 0;
  219. transform: translateX(-50%);
  220. width: 44px;
  221. height: 0;
  222. border-bottom: 2px solid #5dbc7c;
  223. }
  224. }
  225. }
  226. }
  227. // 列表
  228. .swiper-box {
  229. padding-top: 10rpx;
  230. .order-item {
  231. padding: 20rpx 30rpx;
  232. line-height: 1.5;
  233. .title-box {
  234. .title {
  235. font-size: $font-lg;
  236. color: $font-color-base;
  237. }
  238. .time {
  239. font-size: $font-base;
  240. color: $font-color-light;
  241. }
  242. }
  243. .money {
  244. color: #ff0000;
  245. font-size: $font-lg;
  246. }
  247. }
  248. }
  249. .list-scroll-content {
  250. height: 100%;
  251. }
  252. .wallet-btn {
  253. width: 674rpx;
  254. height: 88rpx;
  255. background: linear-gradient(90deg, #08c4e6, #50ead2);
  256. border-radius: 44rpx;
  257. font-size: $font-lg;
  258. font-family: PingFang SC;
  259. font-weight: 500;
  260. color: #ffffff;
  261. display: flex;
  262. align-items: center;
  263. justify-content: center;
  264. position: fixed;
  265. left: 38rpx;
  266. bottom: 50rpx;
  267. }
  268. .content {
  269. height: 100%;
  270. .empty-content {
  271. background-color: #ffffff;
  272. }
  273. }
  274. </style>