yue.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="content-money">
  5. <view class="status_bar"><!-- 这里是状态栏 --></view>
  6. <view class="body-title">
  7. <!-- <view class="goback-box" @click="toBack"><image class="goback" src="../../static/icon/fanhui.png" mode=""></image></view> -->
  8. <view class="header">我的余额</view>
  9. </view>
  10. <view class="content-bg"><image src="../../static/img/user-bg.png" mode=""></image></view>
  11. <view class="money-box">
  12. <view class="money">{{ userInfo.now_money || '0.00'}}</view>
  13. <view>当前余额</view>
  14. </view>
  15. <view class="moneybtn-box">
  16. <!-- <view class="money-btn" style="text-decoration: underline;" @click="navto('/pages/money/freeze')">冻结记录</view> -->
  17. <view class="money-btn" style="text-decoration: underline;"></view>
  18. <view class="money-btn" @click="navto('/pages/user/yjzz?type=1')">余额互转</view>
  19. <!-- <view class="money-btn" @click="openkf()">充值</view> -->
  20. </view>
  21. </view>
  22. </view>
  23. <!-- <view class="info-box flex">
  24. <view class="shu"></view>
  25. <view class="info-item">
  26. <view class="info-font">累计充值</view>
  27. <view class="info-num">{{ userInfo.recharge || '0' }}</view>
  28. </view>
  29. <view class="shu"></view>
  30. <view class="info-item">
  31. <view class="info-font">累计支出</view>
  32. <view class="info-num">{{ userInfo.orderStatusSum || '0'}}</view>
  33. </view>
  34. </view> -->
  35. <view class="navbar">
  36. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  37. </view>
  38. <swiper :current="tabCurrentIndex" :style="{ height: maxheight }" class="swiper-box" duration="300" @change="changeTab">
  39. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  40. <scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="loadData">
  41. <!-- 空白页 -->
  42. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  43. <!-- 订单列表 -->
  44. <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index">
  45. <view class="title-box">
  46. <view class="title">
  47. <text>{{ item.mark||item.title }}</text>
  48. </view>
  49. <view class="time">
  50. <text>{{ item.add_time }}</text>
  51. </view>
  52. </view>
  53. <view class="money">
  54. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  55. </view>
  56. </view>
  57. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  58. </scroll-view>
  59. </swiper-item>
  60. </swiper>
  61. <uni-popup ref="popupkf" type="center">
  62. <view class="popup-box">
  63. <view class="img">
  64. <image src="../../static/img/img009.png" mode=""></image>
  65. </view>
  66. <view class="mian">
  67. <view class="delivery">
  68. <view class="title">已经为您定制专属客服</view>
  69. <image src="../../static/img/img010.png" mode=""></image>
  70. </view>
  71. <view class="nocancel">客服VX:{{ text }}</view>
  72. <view class="comfirm-box">
  73. <view class="cancel" @click="cancel">取消</view>
  74. <view class="comfirm" @click="comfirm(text)">复制微信</view>
  75. </view>
  76. </view>
  77. </view>
  78. </uni-popup>
  79. </view>
  80. </template>
  81. <script>
  82. import { spreadCommission, userBalance, yue } from '@/api/wallet.js';
  83. import { mapState, mapMutations } from 'vuex';
  84. import { getMoneyStyle } from '@/utils/rocessor.js';
  85. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  86. import empty from '@/components/empty';
  87. import { getUserInfo } from '@/api/user.js';
  88. export default {
  89. filters: {
  90. getMoneyStyle
  91. },
  92. components: {
  93. empty,
  94. uniLoadMore
  95. },
  96. onReady(res) {
  97. var _this = this;
  98. uni.getSystemInfo({
  99. success: resu => {
  100. const query = uni.createSelectorQuery();
  101. query.select('.swiper-box').boundingClientRect();
  102. query.exec(function(res) {
  103. _this.maxheight = resu.windowHeight - res[0].top + 'px';
  104. console.log('打印页面的剩余高度', _this.maxheight);
  105. });
  106. },
  107. fail: res => {}
  108. });
  109. },
  110. data() {
  111. return {
  112. text: '',
  113. userInfo: {},
  114. // 头部图高度
  115. maxheight: '',
  116. tabCurrentIndex: 0,
  117. sr: '',
  118. zc: '',
  119. navList: [
  120. {
  121. state: 2,
  122. text: '收入',
  123. loadingType: 'more',
  124. orderList: [],
  125. page: 1, //当前页面
  126. limit: 10 //每次信息条数
  127. },
  128. {
  129. state: 1,
  130. text: '支出',
  131. loadingType: 'more',
  132. orderList: [],
  133. page: 1, //当前页面
  134. limit: 10 //每次信息条数
  135. }
  136. ],
  137. money: ''
  138. };
  139. },
  140. onLoad(options) {},
  141. onShow() {
  142. this.getUserInfo();
  143. this.loadData('re');
  144. //获取用户余额
  145. // userBalance({}).then(({ data }) => {
  146. // this.money = data.commissionCount;
  147. // });
  148. },
  149. methods: {
  150. ...mapMutations('user', ['setUserInfo']),
  151. // 打开客服
  152. openkf() {
  153. this.$refs.popupkf.open();
  154. },
  155. cancel() {
  156. this.$refs.popupkf.close();
  157. },
  158. comfirm(text) {
  159. console.log(text);
  160. const result = this.uniCopy(text);
  161. if (result === false) {
  162. uni.showToast({
  163. title: '不支持'
  164. });
  165. } else {
  166. uni.showToast({
  167. title: '复制成功',
  168. icon: 'none'
  169. });
  170. }
  171. this.$refs.popupkf.close();
  172. },
  173. uniCopy(content) {
  174. /**
  175. * 小程序端 和 app端的复制逻辑
  176. */
  177. //#ifndef H5
  178. uni.setClipboardData({
  179. data: content,
  180. success: function() {
  181. console.log('success');
  182. return true;
  183. }
  184. });
  185. //#endif
  186. /**
  187. * H5端的复制逻辑
  188. */
  189. // #ifdef H5
  190. if (!document.queryCommandSupported('copy')) {
  191. //为了兼容有些浏览器 queryCommandSupported 的判断
  192. // 不支持
  193. return false;
  194. }
  195. let textarea = document.createElement('textarea');
  196. textarea.value = content;
  197. textarea.readOnly = 'readOnly';
  198. document.body.appendChild(textarea);
  199. textarea.select(); // 选择对象
  200. textarea.setSelectionRange(0, content.length); //核心
  201. let result = document.execCommand('copy'); // 执行浏览器复制命令
  202. textarea.remove();
  203. return result;
  204. // #endif
  205. },
  206. navto(e) {
  207. uni.navigateTo({
  208. url: e
  209. });
  210. },
  211. getUserInfo() {
  212. getUserInfo({}).then(({ data }) => {
  213. this.userInfo = data
  214. });
  215. },
  216. async loadData(source) {
  217. const obj = this;
  218. //这里时将订单挂载到tab列表下
  219. let index = this.tabCurrentIndex;
  220. let navItem = this.navList[index];
  221. let state = navItem.state ;
  222. if(source == 're' ) {
  223. navItem.orderList = []
  224. navItem.loadingType = 'more'
  225. navItem.page = 1
  226. }
  227. if (source === 'tabChange' && navItem.loaded === true) {
  228. //tab切换只有第一次需要加载数据
  229. return;
  230. }
  231. if (navItem.loadingType === 'loading' || navItem.loadingType === 'noMore') {
  232. //防止重复加载
  233. return;
  234. }
  235. //修改当前对象状态为加载中
  236. navItem.loadingType = 'loading';
  237. spreadCommission(
  238. {
  239. page: navItem.page,
  240. limit: navItem.limit,
  241. },state
  242. )
  243. .then(({ data }) => {
  244. if (data.length > 0) {
  245. let arr = []
  246. data.forEach(item => {
  247. arr = arr.concat(item.list)
  248. console.log(arr);
  249. })
  250. navItem.orderList = navItem.orderList.concat(arr);
  251. }
  252. if (navItem.limit == data.length) {
  253. //判断是否还有数据, 有改为 more, 没有改为noMore
  254. navItem.loadingType = 'more';
  255. } else {
  256. //判断是否还有数据, 有改为 more, 没有改为noMore
  257. navItem.loadingType = 'noMore';
  258. }
  259. navItem.page++
  260. uni.hideLoading();
  261. this.$set(navItem, 'loaded', true);
  262. })
  263. .catch(e => {
  264. console.log(e);
  265. });
  266. },
  267. //swiper 切换
  268. changeTab(e) {
  269. this.tabCurrentIndex = e.target.current;
  270. this.loadData('tabChange');
  271. },
  272. //顶部tab点击
  273. tabClick(index) {
  274. this.tabCurrentIndex = index;
  275. },
  276. toBack() {
  277. uni.navigateBack({
  278. fail() {
  279. uni.switchTab({
  280. url: '/pages/user/user'
  281. })
  282. }
  283. });
  284. }
  285. }
  286. };
  287. </script>
  288. <style lang="scss" scoped>
  289. $base-btn-color:#847360;
  290. page {
  291. background: #f2f5f4;
  292. height: 100%;
  293. }
  294. .status_bar {
  295. height: var(--status-bar-height);
  296. width: 100%;
  297. }
  298. .content-money {
  299. position: relative;
  300. height: 480rpx;
  301. .content-bg {
  302. position: absolute;
  303. top: 0;
  304. left: 0;
  305. right: 0;
  306. width: 750rpx;
  307. height: 480rpx;
  308. image {
  309. width: 100%;
  310. height: 100%;
  311. }
  312. }
  313. .body-title {
  314. height: 80rpx;
  315. text-align: center;
  316. font-size: 35rpx;
  317. position: relative;
  318. .header {
  319. position: absolute;
  320. left: 0;
  321. top: 0;
  322. width: 100%;
  323. font-size: 36rpx;
  324. font-family: PingFang SC;
  325. font-weight: bold;
  326. color: $base-btn-color;
  327. height: 80rpx;
  328. font-size: 36rpx;
  329. font-weight: 700;
  330. z-index: 9;
  331. display: flex;
  332. justify-content: center;
  333. align-items: center;
  334. }
  335. .goback-box {
  336. position: absolute;
  337. left: 18rpx;
  338. top: 0;
  339. height: 80rpx;
  340. display: flex;
  341. align-items: center;
  342. }
  343. .goback {
  344. z-index: 100;
  345. width: 34rpx;
  346. height: 34rpx;
  347. }
  348. }
  349. }
  350. .money-box {
  351. position: relative;
  352. z-index: 2;
  353. padding-top: 90rpx;
  354. color: $base-btn-color;
  355. text-align: center;
  356. .money {
  357. font-size: 72rpx;
  358. font-family: PingFang SC;
  359. font-weight: bold;
  360. color: $base-btn-color;
  361. }
  362. .text {
  363. font-size: 30rpx;
  364. }
  365. }
  366. .moneybtn-box {
  367. display: flex;
  368. justify-content: space-between;
  369. position: relative;
  370. z-index: 2;
  371. color:$base-btn-color;
  372. padding: 20rpx 50rpx;
  373. font-size: 30rpx;
  374. font-weight: bold;
  375. }
  376. .navbar {
  377. margin-top: 25rpx;
  378. display: flex;
  379. height: 40px;
  380. padding: 0 5px;
  381. background: #fff;
  382. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  383. position: relative;
  384. z-index: 10;
  385. .nav-item {
  386. flex: 1;
  387. display: flex;
  388. justify-content: center;
  389. align-items: center;
  390. height: 100%;
  391. font-size: 15px;
  392. color: $font-color-dark;
  393. position: relative;
  394. &.current {
  395. color: #000;
  396. font-weight: bold;
  397. &:after {
  398. content: '';
  399. position: absolute;
  400. left: 50%;
  401. bottom: 0;
  402. transform: translateX(-50%);
  403. width: 44px;
  404. height: 0;
  405. border-bottom: 2px solid #FF4C4C;
  406. }
  407. }
  408. }
  409. }
  410. //列表
  411. .swiper-box {
  412. .order-item {
  413. padding: 20rpx 30rpx;
  414. line-height: 1.5;
  415. .title-box {
  416. .title {
  417. font-size: $font-lg;
  418. color: $font-color-base;
  419. }
  420. .time {
  421. font-size: $font-base;
  422. color: $font-color-light;
  423. }
  424. }
  425. .money {
  426. color: rgba(239, 58, 85, 1);
  427. font-size: $font-lg;
  428. }
  429. }
  430. }
  431. .info-box {
  432. width: 670rpx;
  433. height: 186rpx;
  434. background: #ffffff;
  435. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  436. border-radius: 20rpx;
  437. margin: -100rpx auto 0;
  438. position: relative;
  439. z-index: 2;
  440. .info-item {
  441. width: 50%;
  442. display: flex;
  443. flex-direction: column;
  444. align-items: center;
  445. line-height: 1;
  446. .info-font {
  447. font-size: 30rpx;
  448. font-family: PingFang SC;
  449. font-weight: bold;
  450. color: #999999;
  451. }
  452. .info-num {
  453. margin-top: 30rpx;
  454. font-size: 30rpx;
  455. font-family: PingFang SC;
  456. font-weight: bold;
  457. color: #181818;
  458. }
  459. }
  460. .shu {
  461. width: 2rpx;
  462. height: 74rpx;
  463. background: #dcdfe6;
  464. }
  465. }
  466. .list-scroll-content {
  467. background-color: #ffffff;
  468. height: 100%;
  469. }
  470. .content {
  471. height: 100%;
  472. .empty-content {
  473. background-color: #ffffff;
  474. }
  475. }
  476. .btm-wrap {
  477. height: 140rpx;
  478. width: 750rpx;
  479. position: fixed;
  480. bottom: 0;
  481. left: 0;
  482. background-color: #fff;
  483. .btn {
  484. width: 674rpx;
  485. height: 88rpx;
  486. line-height: 88rpx;
  487. margin: auto;
  488. background: linear-gradient(-22deg, #9a5e19, #9a5e19);
  489. border-radius: 44rpx;
  490. text-align: center;
  491. font-size: 36rpx;
  492. font-family: PingFang SC;
  493. font-weight: 500;
  494. color: #ffffff;
  495. }
  496. }
  497. .popup-box {
  498. width: 522rpx;
  499. height: 605rpx;
  500. background-color: #ffffff;
  501. border-radius: 20rpx;
  502. position: relative;
  503. .img {
  504. position: relative;
  505. top: -56rpx;
  506. left: 0;
  507. width: 522rpx;
  508. height: 132rpx;
  509. display: flex;
  510. justify-content: center;
  511. image {
  512. border-radius: 20rpx 20rpx 0 0;
  513. width: 450rpx;
  514. height: 132rpx;
  515. }
  516. }
  517. .mian {
  518. margin-top: -44rpx;
  519. display: flex;
  520. flex-direction: column;
  521. align-items: center;
  522. // padding: 32rpx 32rpx;
  523. background-color: #ffffff;
  524. border-radius: 0 0 20rpx 20rpx;
  525. text-align: center;
  526. .delivery {
  527. font-size: 40rpx;
  528. color: #333333;
  529. display: flex;
  530. align-items: center;
  531. flex-direction: column;
  532. image {
  533. margin-top: 48rpx;
  534. width: 172rpx;
  535. height: 160rpx;
  536. }
  537. }
  538. .nocancel {
  539. font-size: 32rpx;
  540. color: #333333;
  541. margin-top: 14rpx;
  542. }
  543. .comfirm-box {
  544. margin-top: 52rpx;
  545. display: flex;
  546. .cancel {
  547. display: flex;
  548. align-items: center;
  549. justify-content: center;
  550. width: 197rpx;
  551. height: 74rpx;
  552. border: 1px solid #dcc786;
  553. border-radius: 38rpx;
  554. font-size: 32rpx;
  555. color: #605128;
  556. }
  557. .comfirm {
  558. margin-left: 32rpx;
  559. display: flex;
  560. align-items: center;
  561. justify-content: center;
  562. width: 197rpx;
  563. height: 74rpx;
  564. background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
  565. border-radius: 38px;
  566. font-size: 32rpx;
  567. color: #605128;
  568. }
  569. }
  570. }
  571. }
  572. </style>