yue.vue 9.6 KB

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