yue.vue 9.5 KB

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