money.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="status_bar"><!-- 这里是状态栏 --></view>
  5. <view class="body-title">
  6. <view class="goback-box" @click="toBack">
  7. <image class="goback" src="../../static/icon/fanhui.png" mode=""></image>
  8. </view>
  9. <view class="header">我的余额</view>
  10. </view>
  11. <view class="content-bg">
  12. <image src="../../static/img/break-bg.png" mode=""></image>
  13. </view>
  14. <view class="money-box">
  15. <view class="money">{{ userInfo.money || 0 }}</view>
  16. <view>我的余额</view>
  17. </view>
  18. <view class="moneybtn-box">
  19. <view class="money-btn" @click="navto('/pages/user/yjzye')">
  20. <image class="money-btn-icon" src="../../static/img/tr.png" mode=""></image>
  21. <view class="money-font">
  22. 转换消费积分
  23. </view>
  24. </view>
  25. <view class="money-btn" @click="navto('/pages/money/wallet')">
  26. <image class="money-btn-icon" src="../../static/img/tr.png" mode=""></image>
  27. <view class="money-font">
  28. 余额互转
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- <view class="info-box flex">
  34. <view class="info-item">
  35. <view class="info-font">累计收入</view>
  36. <view class="info-num">{{ recharge || '0' }}</view>
  37. </view>
  38. <view class="shu"></view>
  39. <view class="info-item">
  40. <view class="info-font">累计支出</view>
  41. <view class="info-num">{{ orderStatusSum || '0' }}</view>
  42. </view>
  43. </view> -->
  44. <view class="navbar">
  45. <view v-for="(item, index) in navList" :key="index" class="nav-item"
  46. :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  47. </view>
  48. <swiper :current="tabCurrentIndex" :style="{ height: height }" class="swiper-box" duration="300"
  49. @change="changeTab">
  50. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  51. <scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="loadData">
  52. <!-- 空白页 -->
  53. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  54. <!-- 订单列表 -->
  55. <view>
  56. <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index">
  57. <view class="title-box">
  58. <view class="title">
  59. <text>{{ item.mark }}</text>
  60. </view>
  61. <view class="time">
  62. <text>{{ item.add_time }}</text>
  63. </view>
  64. </view>
  65. <view class="money">
  66. <view>{{ (item.pm == 0 ? '-' : '+') + item.number }}</view>
  67. </view>
  68. </view>
  69. </view>
  70. <uni-load-more :status="tabItem.loadingType"
  71. v-if="!(tabItem.orderList.length == 0 && tabItem.loaded)"></uni-load-more>
  72. </scroll-view>
  73. </swiper-item>
  74. </swiper>
  75. </view>
  76. </template>
  77. <script>
  78. import {
  79. mapState,
  80. mapMutations
  81. } from 'vuex';
  82. import {
  83. getMoneyStyle
  84. } from '@/utils/rocessor.js';
  85. import {
  86. mapGetters
  87. } from 'vuex';
  88. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  89. import empty from '@/components/empty';
  90. import {
  91. extractBank,
  92. integral,
  93. money
  94. } from '@/api/wallet.js';
  95. export default {
  96. filters: {
  97. getMoneyStyle
  98. },
  99. components: {
  100. empty,
  101. uniLoadMore
  102. },
  103. computed: {
  104. ...mapState('user', ['userInfo'])
  105. },
  106. onReady(res) {
  107. var _this = this;
  108. console.log(_this.userInfo);
  109. uni.getSystemInfo({
  110. success: resu => {
  111. const query = uni.createSelectorQuery();
  112. query.select('.swiper-box').boundingClientRect();
  113. query.exec(function(res) {
  114. _this.height = resu.windowHeight - res[0].top + 'px';
  115. console.log('打印页面的剩余高度', _this.height);
  116. });
  117. },
  118. fail: res => {}
  119. });
  120. },
  121. data() {
  122. return {
  123. yj: '',
  124. height: '',
  125. // 头部图高度
  126. maxheight: '',
  127. tabCurrentIndex: 0,
  128. orderStatusSum: 0,
  129. recharge: 0,
  130. navList: [{
  131. state: 1,
  132. text: '收入',
  133. loadingType: 'more',
  134. orderList: [],
  135. page: 1, //当前页数
  136. limit: 10 //每次信息条数
  137. },
  138. {
  139. state: 0,
  140. text: '支出',
  141. loadingType: 'more',
  142. orderList: [],
  143. page: 1, //当前页数
  144. limit: 10 //每次信息条数
  145. }
  146. ],
  147. money: ''
  148. };
  149. },
  150. onLoad(options) {},
  151. onShow() {
  152. this.extractBank();
  153. this.loadData();
  154. },
  155. methods: {
  156. extractBank() {
  157. extractBank().then(res => {
  158. console.log(res);
  159. this.yj = res.data.brokerage_price;
  160. });
  161. },
  162. toBack() {
  163. uni.switchTab({
  164. url: '/pages/user/user'
  165. });
  166. },
  167. // 页面跳转
  168. navto(e) {
  169. uni.navigateTo({
  170. url: e
  171. });
  172. },
  173. //获取收入支出信息
  174. async loadData(source) {
  175. //这里时将订单挂载到tab列表下
  176. let index = this.tabCurrentIndex;
  177. let navItem = this.navList[index];
  178. let state = navItem.state;
  179. if (source === 'tabChange' && navItem.loaded === true) {
  180. //tab切换只有第一次需要加载数据
  181. return;
  182. }
  183. if (navItem.loadingType === 'loading') {
  184. //防止重复加载
  185. return;
  186. }
  187. //修改当前对象状态为加载中
  188. navItem.loadingType = 'loading';
  189. money({
  190. page: navItem.page,
  191. limit: navItem.limit,
  192. pm: state
  193. })
  194. .then(({
  195. data
  196. }) => {
  197. if (data.length > 0) {
  198. navItem.orderList = navItem.orderList.concat(data);
  199. navItem.page++;
  200. }
  201. //判断是否还有数据, 有改为more, 没有改为noMore
  202. if (navItem.limit == data.length) {
  203. navItem.loadingType = 'more';
  204. return;
  205. } else {
  206. navItem.loadingType = 'noMore';
  207. }
  208. uni.hideLoading();
  209. this.$set(navItem, 'loaded', true);
  210. })
  211. .catch(e => {
  212. console.log(e);
  213. });
  214. },
  215. //swiper 切换
  216. changeTab(e) {
  217. this.tabCurrentIndex = e.target.current;
  218. this.loadData('tabChange');
  219. },
  220. //顶部tab点击
  221. tabClick(index) {
  222. this.tabCurrentIndex = index;
  223. }
  224. }
  225. };
  226. </script>
  227. <style lang="scss">
  228. page {
  229. background: #f1f1f1;
  230. height: 100%;
  231. }
  232. .status_bar {
  233. height: var(--status-bar-height);
  234. width: 100%;
  235. }
  236. .content-money {
  237. position: relative;
  238. height: 480rpx;
  239. .content-bg {
  240. position: absolute;
  241. top: 0;
  242. left: 0;
  243. right: 0;
  244. width: 750rpx;
  245. height: 480rpx;
  246. image {
  247. width: 100%;
  248. height: 100%;
  249. }
  250. }
  251. .body-title {
  252. height: 80rpx;
  253. text-align: center;
  254. font-size: 35rpx;
  255. position: relative;
  256. .header {
  257. position: absolute;
  258. left: 0;
  259. top: 0;
  260. width: 100%;
  261. font-size: 36rpx;
  262. font-family: PingFang SC;
  263. font-weight: bold;
  264. color: #fffeff;
  265. height: 80rpx;
  266. font-size: 36rpx;
  267. font-weight: 700;
  268. z-index: 9;
  269. display: flex;
  270. justify-content: center;
  271. align-items: center;
  272. }
  273. .goback-box {
  274. position: absolute;
  275. left: 18rpx;
  276. top: 0;
  277. height: 80rpx;
  278. display: flex;
  279. align-items: center;
  280. }
  281. .goback {
  282. z-index: 100;
  283. width: 34rpx;
  284. height: 34rpx;
  285. }
  286. }
  287. }
  288. .info-box {
  289. width: 670rpx;
  290. height: 186rpx;
  291. background: #ffffff;
  292. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  293. border-radius: 20rpx;
  294. margin: -80rpx auto 0;
  295. position: relative;
  296. z-index: 2;
  297. .info-item {
  298. width: 50%;
  299. display: flex;
  300. flex-direction: column;
  301. align-items: center;
  302. line-height: 1;
  303. .info-font {
  304. font-size: 30rpx;
  305. font-family: PingFang SC;
  306. font-weight: bold;
  307. color: #999999;
  308. }
  309. .info-num {
  310. margin-top: 30rpx;
  311. font-size: 30rpx;
  312. font-family: PingFang SC;
  313. font-weight: bold;
  314. color: #181818;
  315. }
  316. }
  317. .shu {
  318. width: 2rpx;
  319. height: 74rpx;
  320. background: #dcdfe6;
  321. }
  322. }
  323. .money-box {
  324. position: relative;
  325. z-index: 2;
  326. /* #ifdef H5 */
  327. padding-top: 90rpx;
  328. /* #endif */
  329. color: #ffffff;
  330. text-align: center;
  331. /* #ifdef APP-PLUS */
  332. height: 200rpx;
  333. display: flex;
  334. flex-direction: column;
  335. justify-content: center;
  336. /* #endif */
  337. /* #ifdef MP-WEIXIN */
  338. padding-top: 40rpx;
  339. /* #endif */
  340. .money {
  341. font-size: 72rpx;
  342. font-family: PingFang SC;
  343. font-weight: bold;
  344. color: #ffffff;
  345. }
  346. .text {
  347. font-size: 30rpx;
  348. }
  349. }
  350. .moneybtn-box {
  351. display: flex;
  352. justify-content: space-between;
  353. position: relative;
  354. z-index: 2;
  355. color: #ffffff;
  356. padding: 0rpx 50rpx;
  357. font-size: 30rpx;
  358. font-family: PingFang SC;
  359. font-weight: bold;
  360. .money-btn {
  361. display: flex;
  362. align-items: center;
  363. .money-btn-icon {
  364. width: 40rpx;
  365. height: 40rpx;
  366. }
  367. .money-font {
  368. margin-left: 10rpx;
  369. }
  370. }
  371. }
  372. .navbar {
  373. margin-top: 20rpx;
  374. display: flex;
  375. height: 88rpx;
  376. padding: 0 5px;
  377. background: #fff;
  378. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  379. position: relative;
  380. z-index: 10;
  381. .nav-item {
  382. flex: 1;
  383. display: flex;
  384. justify-content: center;
  385. align-items: center;
  386. height: 100%;
  387. font-size: 15px;
  388. color: #999999;
  389. position: relative;
  390. &.current {
  391. color: #000;
  392. &:after {
  393. content: '';
  394. position: absolute;
  395. left: 50%;
  396. bottom: 0;
  397. transform: translateX(-50%);
  398. width: 50rpx;
  399. height: 6rpx;
  400. background: linear-gradient(90deg, #CA57DC, #65B2E9);
  401. border-radius: 4rpx;
  402. }
  403. }
  404. }
  405. }
  406. //列表
  407. .swiper-box {
  408. .order-item:last-child {
  409. margin-bottom: 60rpx;
  410. }
  411. .order-item {
  412. padding: 20rpx 30rpx;
  413. line-height: 1.5;
  414. .title-box {
  415. .title {
  416. font-size: $font-lg;
  417. color: $font-color-base;
  418. }
  419. .time {
  420. font-size: $font-base;
  421. color: $font-color-light;
  422. }
  423. }
  424. .money {
  425. color: #fd5b23;
  426. font-size: $font-lg;
  427. text-align: right;
  428. .status {
  429. color: $font-color-light;
  430. }
  431. }
  432. }
  433. }
  434. .list-scroll-content {
  435. background: #ffffff;
  436. height: 100%;
  437. }
  438. .content {
  439. height: 100%;
  440. .empty-content {
  441. background-color: #ffffff;
  442. }
  443. }
  444. .btn-box {
  445. width: 674rpx;
  446. height: 88rpx;
  447. background: linear-gradient(0deg, #2e58ff, #32c6ff);
  448. border-radius: 44rpx;
  449. font-size: 36rpx;
  450. font-family: PingFang SC;
  451. font-weight: 500;
  452. color: #ffffff;
  453. text-align: center;
  454. line-height: 88rpx;
  455. position: fixed;
  456. bottom: 48rpx;
  457. left: 0;
  458. right: 0;
  459. margin: 0 auto;
  460. }
  461. </style>