yue.vue 11 KB

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