xfIntegral.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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/anchor12.png"></image>
  8. <view class="money">{{ userInfo.point | 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 { xfjf, 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. import { getTime } from '@/utils/rocessor.js';
  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. xfjf(
  127. {
  128. page: navItem.page,
  129. limit: navItem.limit
  130. },
  131. state
  132. )
  133. .then(({ data }) => {
  134. data.list.forEach(e =>{
  135. e.add_time = getTime(e.add_time)
  136. })
  137. navItem.orderList = navItem.orderList.concat(data.list);
  138. console.log(navItem.orderList,'12345648972165')
  139. navItem.page++;
  140. if (navItem.limit == data.list.length) {
  141. //判断是否还有数据, 有改为 more, 没有改为noMore
  142. navItem.loadingType = 'more';
  143. return;
  144. } else {
  145. //判断是否还有数据, 有改为 more, 没有改为noMore
  146. navItem.loadingType = 'noMore';
  147. }
  148. uni.hideLoading();
  149. this.$set(navItem, 'loaded', true);
  150. })
  151. .catch(e => {
  152. console.log(e);
  153. });
  154. },
  155. //swiper 切换
  156. changeTab(e) {
  157. this.tabCurrentIndex = e.target.current;
  158. this.loadData('tabChange');
  159. },
  160. //顶部tab点击
  161. tabClick(index) {
  162. this.tabCurrentIndex = index;
  163. },
  164. // 点击返回 我的页面
  165. toBack() {
  166. uni.switchTab({
  167. url: '/pages/user/user'
  168. });
  169. }
  170. }
  171. };
  172. </script>
  173. <style lang="scss">
  174. page {
  175. background: #ffffff;
  176. height: 100%;
  177. }
  178. .content-money {
  179. padding-bottom: 30rpx;
  180. background: $page-color-base;
  181. // border: 2px solid #ffffff;
  182. // padding-top: var(--status-bar-height);
  183. .moneyTx {
  184. position: absolute;
  185. top: 120rpx;
  186. right: 0rpx;
  187. // width: 150rpx;
  188. padding: 10rpx 10rpx;
  189. border: 2px solid #ffffff;
  190. border-top-left-radius: 15rpx;
  191. border-bottom-left-radius: 15rpx;
  192. line-height: 1;
  193. font-size: $font-base;
  194. background: #ffffff;
  195. }
  196. .buttom-box {
  197. background-color: #ffffff;
  198. text-align: center;
  199. margin: 0 30rpx;
  200. padding: 20rpx 0;
  201. border-radius: $border-radius-sm;
  202. margin-top: -60rpx;
  203. .buttom {
  204. font-size: $font-lg;
  205. flex-grow: 1;
  206. }
  207. .interval {
  208. width: 2px;
  209. height: 60rpx;
  210. background-color: #eeeeee;
  211. }
  212. .icon {
  213. height: 36rpx;
  214. width: 36rpx;
  215. margin: 0 auto;
  216. .icon-img {
  217. width: 100%;
  218. height: 100%;
  219. }
  220. }
  221. }
  222. }
  223. .money-box {
  224. color: #ffffff;
  225. text-align: center;
  226. position: relative;
  227. .header {
  228. position: absolute;
  229. left: 0;
  230. top: 0;
  231. width: 100%;
  232. height: 80rpx;
  233. font-size: 32rpx;
  234. font-weight: 700;
  235. z-index: 99;
  236. display: flex;
  237. justify-content: center;
  238. align-items: center;
  239. }
  240. .goback-box {
  241. position: absolute;
  242. left: 18rpx;
  243. top: 0;
  244. height: 80rpx;
  245. display: flex;
  246. align-items: center;
  247. }
  248. .goback {
  249. z-index: 100;
  250. width: 34rpx;
  251. height: 34rpx;
  252. }
  253. .money_bg {
  254. width: 100%;
  255. height: 360rpx;
  256. display: block;
  257. }
  258. .text {
  259. padding-top: 80rpx;
  260. font-size: $font-lg;
  261. }
  262. .money {
  263. position: absolute;
  264. top: 0;
  265. width: 100%;
  266. padding-top: 186rpx;
  267. font-size: 60rpx;
  268. font-weight: bold;
  269. &::before {
  270. content: '¥';
  271. font-size: 30rpx;
  272. }
  273. }
  274. }
  275. .navbar {
  276. display: flex;
  277. height: 40px;
  278. padding: 0 5px;
  279. background: #fff;
  280. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  281. position: relative;
  282. z-index: 10;
  283. .nav-item {
  284. flex: 1;
  285. display: flex;
  286. justify-content: center;
  287. align-items: center;
  288. height: 100%;
  289. font-size: 15px;
  290. color: #999999;
  291. position: relative;
  292. &.current {
  293. color: #000000;
  294. &:after {
  295. content: '';
  296. position: absolute;
  297. left: 50%;
  298. bottom: 0;
  299. transform: translateX(-50%);
  300. width: 44px;
  301. height: 0;
  302. border-bottom: 2px solid #27d4dd;
  303. }
  304. }
  305. }
  306. }
  307. // 列表
  308. .swiper-box {
  309. padding-top: 10rpx;
  310. .order-item {
  311. padding: 20rpx 30rpx;
  312. line-height: 1.5;
  313. .title-box {
  314. .title {
  315. font-size: $font-lg;
  316. color: $font-color-base;
  317. }
  318. .time {
  319. font-size: $font-base;
  320. color: $font-color-light;
  321. }
  322. }
  323. .money {
  324. color: #ff0000;
  325. font-size: $font-lg;
  326. }
  327. }
  328. }
  329. .list-scroll-content {
  330. height: 100%;
  331. }
  332. .wallet-btn {
  333. width: 674rpx;
  334. height: 88rpx;
  335. background: linear-gradient(90deg, #08c4e6, #50ead2);
  336. border-radius: 44rpx;
  337. font-size: $font-lg;
  338. font-family: PingFang SC;
  339. font-weight: 500;
  340. color: #ffffff;
  341. display: flex;
  342. align-items: center;
  343. justify-content: center;
  344. position: fixed;
  345. left: 38rpx;
  346. bottom: 50rpx;
  347. }
  348. .content {
  349. height: 100%;
  350. .empty-content {
  351. background-color: #ffffff;
  352. }
  353. }
  354. </style>