integral.vue 7.6 KB

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