jinquan.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="money-box">
  5. <view class="goback-box" @click="toBack"><image class="goback" src="../../static/img/fanhui.png" mode=""></image></view>
  6. <view class="header">我的金券</view>
  7. <image class="money_bg" src="../../static/img/anchor10.png"></image>
  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 v-for="(ls, index) in tabItem.orderList">
  21. <view v-for="(item, i) in ls.list" class="order-item flex">
  22. <view class="title-box">
  23. <view class="title">
  24. <text>{{ item.mark }}</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 { integralList, 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. async loadData(source) {
  105. //这里是将订单挂载到tab列表下
  106. let index = this.tabCurrentIndex;
  107. let navItem = this.navList[index];
  108. let state = navItem.state;
  109. if (source === 'tabChange' && navItem.loaded === true) {
  110. //tab切换只有第一次需要加载数据
  111. return;
  112. }
  113. if (navItem.loadingType === 'noMore') {
  114. //防止重复加载
  115. return;
  116. }
  117. // 修改当前对象状态为加载中
  118. navItem.loadingType = 'loading';
  119. integralList(
  120. {
  121. page: navItem.page,
  122. limit: navItem.limit,
  123. pm: state
  124. },
  125. )
  126. .then(({ data }) => {
  127. navItem.orderList = navItem.orderList.concat(data);
  128. navItem.page++;
  129. if (navItem.limit == data.length) {
  130. //判断是否还有数据, 有改为 more, 没有改为noMore
  131. navItem.loadingType = 'more';
  132. return;
  133. } else {
  134. //判断是否还有数据, 有改为 more, 没有改为noMore
  135. navItem.loadingType = 'noMore';
  136. }
  137. uni.hideLoading();
  138. this.$set(navItem, 'loaded', true);
  139. })
  140. .catch(e => {
  141. console.log(e);
  142. });
  143. },
  144. //swiper 切换
  145. changeTab(e) {
  146. this.tabCurrentIndex = e.target.current;
  147. this.loadData('tabChange');
  148. },
  149. //顶部tab点击
  150. tabClick(index) {
  151. this.tabCurrentIndex = index;
  152. },
  153. // 点击返回 我的页面
  154. toBack() {
  155. uni.switchTab({
  156. url: '/pages/user/user'
  157. });
  158. }
  159. }
  160. };
  161. </script>
  162. <style lang="scss">
  163. page {
  164. background: #ffffff;
  165. height: 100%;
  166. }
  167. .content-money {
  168. padding-bottom: 30rpx;
  169. background: $page-color-base;
  170. // border: 2px solid #ffffff;
  171. // padding-top: var(--status-bar-height);
  172. .moneyTx {
  173. position: absolute;
  174. top: 120rpx;
  175. right: 0rpx;
  176. // width: 150rpx;
  177. padding: 10rpx 10rpx;
  178. border: 2px solid #ffffff;
  179. border-top-left-radius: 15rpx;
  180. border-bottom-left-radius: 15rpx;
  181. line-height: 1;
  182. font-size: $font-base;
  183. background: #ffffff;
  184. }
  185. .buttom-box {
  186. background-color: #ffffff;
  187. text-align: center;
  188. margin: 0 30rpx;
  189. padding: 20rpx 0;
  190. border-radius: $border-radius-sm;
  191. margin-top: -60rpx;
  192. .buttom {
  193. font-size: $font-lg;
  194. flex-grow: 1;
  195. }
  196. .interval {
  197. width: 2px;
  198. height: 60rpx;
  199. background-color: #eeeeee;
  200. }
  201. .icon {
  202. height: 36rpx;
  203. width: 36rpx;
  204. margin: 0 auto;
  205. .icon-img {
  206. width: 100%;
  207. height: 100%;
  208. }
  209. }
  210. }
  211. }
  212. .money-box {
  213. color: #ffffff;
  214. text-align: center;
  215. position: relative;
  216. background-color: pink;
  217. .header {
  218. position: absolute;
  219. left: 0;
  220. top: 0;
  221. width: 100%;
  222. height: 80rpx;
  223. font-size: 32rpx;
  224. font-weight: 700;
  225. z-index: 99;
  226. display: flex;
  227. justify-content: center;
  228. align-items: center;
  229. }
  230. .goback-box {
  231. position: absolute;
  232. left: 18rpx;
  233. top: 0;
  234. height: 80rpx;
  235. display: flex;
  236. align-items: center;
  237. }
  238. .goback {
  239. z-index: 100;
  240. width: 34rpx;
  241. height: 34rpx;
  242. }
  243. .money_bg {
  244. width: 100%;
  245. height: 400rpx;
  246. display: block;
  247. }
  248. .text {
  249. padding-top: 80rpx;
  250. font-size: $font-lg;
  251. }
  252. .money {
  253. position: absolute;
  254. top: 0;
  255. width: 100%;
  256. padding-top: 186rpx;
  257. font-size: 72rpx;
  258. font-weight: bold;
  259. }
  260. }
  261. .navbar {
  262. display: flex;
  263. height: 40px;
  264. padding: 0 5px;
  265. background: #fff;
  266. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  267. position: relative;
  268. z-index: 10;
  269. .nav-item {
  270. flex: 1;
  271. display: flex;
  272. justify-content: center;
  273. align-items: center;
  274. height: 100%;
  275. font-size: 15px;
  276. color: #999999;
  277. position: relative;
  278. &.current {
  279. color: #000000;
  280. &:after {
  281. content: '';
  282. position: absolute;
  283. left: 50%;
  284. bottom: 0;
  285. transform: translateX(-50%);
  286. width: 44px;
  287. height: 0;
  288. border-bottom: 2px solid #FF4C4C;
  289. }
  290. }
  291. }
  292. }
  293. // 列表
  294. .swiper-box {
  295. padding-top: 10rpx;
  296. .order-item {
  297. padding: 20rpx 30rpx;
  298. line-height: 1.5;
  299. .title-box {
  300. .title {
  301. font-size: $font-lg;
  302. color: $font-color-base;
  303. }
  304. .time {
  305. font-size: $font-base;
  306. color: $font-color-light;
  307. }
  308. }
  309. .money {
  310. color: #ff0000;
  311. font-size: $font-lg;
  312. }
  313. }
  314. }
  315. .list-scroll-content {
  316. height: 100%;
  317. }
  318. .content {
  319. height: 100%;
  320. .empty-content {
  321. background-color: #ffffff;
  322. }
  323. }
  324. </style>