yue.vue 8.9 KB

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