yue.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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="https://xmyl.qiniu1314.com/static/image/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" ></view>
  17. <!-- 余额互转 -->
  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|| item.title }}</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 { getUser } 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();
  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. getUser({}).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 === 'tabChange' && navItem.loaded === true) {
  148. //tab切换只有第一次需要加载数据
  149. return;
  150. }
  151. if (navItem.loadingType === 'loading') {
  152. //防止重复加载
  153. return;
  154. }
  155. //修改当前对象状态为加载中
  156. navItem.loadingType = 'loading';
  157. spreadCommission(
  158. {
  159. page: navItem.page,
  160. limit: navItem.limit,
  161. },state
  162. )
  163. .then(({ data }) => {
  164. if (data.length > 0) {
  165. navItem.orderList = navItem.orderList.concat(data[0].list);
  166. console.log(navItem.orderList);
  167. navItem.page++;
  168. }
  169. if (navItem.limit == data.length) {
  170. //判断是否还有数据, 有改为 more, 没有改为noMore
  171. navItem.loadingType = 'more';
  172. return;
  173. } else {
  174. //判断是否还有数据, 有改为 more, 没有改为noMore
  175. navItem.loadingType = 'noMore';
  176. }
  177. uni.hideLoading();
  178. this.$set(navItem, 'loaded', true);
  179. })
  180. .catch(e => {
  181. console.log(e);
  182. });
  183. },
  184. //swiper 切换
  185. changeTab(e) {
  186. this.tabCurrentIndex = e.target.current;
  187. this.loadData('tabChange');
  188. },
  189. //顶部tab点击
  190. tabClick(index) {
  191. this.tabCurrentIndex = index;
  192. },
  193. toBack() {
  194. uni.navigateBack();
  195. }
  196. }
  197. };
  198. </script>
  199. <style lang="scss">
  200. page {
  201. background: #f2f5f4;
  202. height: 100%;
  203. }
  204. .status_bar {
  205. height: var(--status-bar-height);
  206. width: 100%;
  207. }
  208. .content-money {
  209. position: relative;
  210. height: 480rpx;
  211. .content-bg {
  212. position: absolute;
  213. top: 0;
  214. left: 0;
  215. right: 0;
  216. width: 750rpx;
  217. height: 480rpx;
  218. image {
  219. width: 100%;
  220. height: 100%;
  221. }
  222. }
  223. .body-title {
  224. height: 80rpx;
  225. text-align: center;
  226. font-size: 35rpx;
  227. position: relative;
  228. .header {
  229. position: absolute;
  230. left: 0;
  231. top: 0;
  232. width: 100%;
  233. font-size: 36rpx;
  234. font-family: PingFang SC;
  235. font-weight: bold;
  236. color: #fffeff;
  237. height: 80rpx;
  238. font-size: 36rpx;
  239. font-weight: 700;
  240. z-index: 9;
  241. display: flex;
  242. justify-content: center;
  243. align-items: center;
  244. }
  245. .goback-box {
  246. position: absolute;
  247. left: 18rpx;
  248. top: 0;
  249. height: 80rpx;
  250. display: flex;
  251. align-items: center;
  252. }
  253. .goback {
  254. z-index: 100;
  255. width: 34rpx;
  256. height: 34rpx;
  257. }
  258. }
  259. }
  260. .money-box {
  261. position: relative;
  262. z-index: 2;
  263. padding-top: 70rpx;
  264. color: #ffffff;
  265. text-align: center;
  266. .money {
  267. font-size: 72rpx;
  268. font-family: PingFang SC;
  269. font-weight: bold;
  270. color: #ffffff;
  271. }
  272. .text {
  273. font-size: 30rpx;
  274. }
  275. }
  276. .moneybtn-box {
  277. display: flex;
  278. justify-content: space-between;
  279. position: relative;
  280. z-index: 2;
  281. color: #ffffff;
  282. padding: 50rpx 50rpx 20rpx;
  283. font-size: 30rpx;
  284. font-family: PingFang SC;
  285. font-weight: bold;
  286. color: #ffffff;
  287. }
  288. .navbar {
  289. margin-top: 25rpx;
  290. display: flex;
  291. height: 40px;
  292. padding: 0 5px;
  293. background: #fff;
  294. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  295. position: relative;
  296. z-index: 10;
  297. .nav-item {
  298. flex: 1;
  299. display: flex;
  300. justify-content: center;
  301. align-items: center;
  302. height: 100%;
  303. font-size: 15px;
  304. color: $font-color-dark;
  305. position: relative;
  306. &.current {
  307. color: #000;
  308. font-weight: bold;
  309. &:after {
  310. content: '';
  311. position: absolute;
  312. left: 50%;
  313. bottom: 0;
  314. transform: translateX(-50%);
  315. width: 44px;
  316. height: 0;
  317. border-bottom: 2px solid #FF4C4C;
  318. }
  319. }
  320. }
  321. }
  322. //列表
  323. .swiper-box {
  324. .order-item {
  325. padding: 20rpx 30rpx;
  326. line-height: 1.5;
  327. .title-box {
  328. .title {
  329. font-size: $font-lg;
  330. color: $font-color-base;
  331. }
  332. .time {
  333. font-size: $font-base;
  334. color: $font-color-light;
  335. }
  336. }
  337. .money {
  338. color: rgba(239, 58, 85, 1);
  339. font-size: $font-lg;
  340. }
  341. }
  342. }
  343. .info-box {
  344. width: 670rpx;
  345. height: 186rpx;
  346. background: #ffffff;
  347. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  348. border-radius: 20rpx;
  349. margin: -100rpx auto 0;
  350. position: relative;
  351. z-index: 2;
  352. .info-item {
  353. width: 50%;
  354. display: flex;
  355. flex-direction: column;
  356. align-items: center;
  357. line-height: 1;
  358. .info-font {
  359. font-size: 30rpx;
  360. font-family: PingFang SC;
  361. font-weight: bold;
  362. color: #999999;
  363. }
  364. .info-num {
  365. margin-top: 30rpx;
  366. font-size: 30rpx;
  367. font-family: PingFang SC;
  368. font-weight: bold;
  369. color: #181818;
  370. }
  371. }
  372. .shu {
  373. width: 2rpx;
  374. height: 74rpx;
  375. background: #dcdfe6;
  376. }
  377. }
  378. .list-scroll-content {
  379. background-color: #ffffff;
  380. height: 100%;
  381. }
  382. .content {
  383. height: 100%;
  384. .empty-content {
  385. background-color: #ffffff;
  386. }
  387. }
  388. .btm-wrap {
  389. height: 140rpx;
  390. width: 750rpx;
  391. position: fixed;
  392. bottom: 0;
  393. left: 0;
  394. background-color: #fff;
  395. .btn {
  396. width: 674rpx;
  397. height: 88rpx;
  398. line-height: 88rpx;
  399. margin: auto;
  400. background: linear-gradient(-22deg, #9a5e19, #9a5e19);
  401. border-radius: 44rpx;
  402. text-align: center;
  403. font-size: 36rpx;
  404. font-family: PingFang SC;
  405. font-weight: 500;
  406. color: #ffffff;
  407. }
  408. }
  409. </style>