yue.vue 9.1 KB

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