xfIntegral.vue 7.7 KB

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