wallet.vue 9.2 KB

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