wallet.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="money-box">
  5. <view class="text">充值金额(元)</view>
  6. <view class="money">{{ userInfo.now_money | getMoneyStyle }}</view>
  7. </view>
  8. <!-- <view class="moneyTx" @click="navto('/pages/wallet/recharge')">充值</view> -->
  9. <!-- <view class="flex buttom-box">
  10. <view class="buttom" @click="navto('/pages/wallet/recharge')">
  11. <view class="icon"><image class="icon-img" src="/static/icon/i1.png" mode="aspectFit"></image></view>
  12. <text>充值</text>
  13. </view>
  14. <view class="interval"></view>
  15. <view class="buttom" @click="navto('/pages/wallet/withdrawal')">
  16. <view class="icon"><image class="icon-img" src="/static/icon/i2.png" mode="aspectFit"></image></view>
  17. <text>提现</text>
  18. </view>
  19. </view> -->
  20. </view>
  21. <view class="navbar">
  22. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  23. </view>
  24. <swiper :current="tabCurrentIndex" :style="{ height: maxheight + 'px' }" class="swiper-box" duration="300" @change="changeTab">
  25. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  26. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  27. <!-- 空白页 -->
  28. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  29. <!-- 订单列表 -->
  30. <view v-for="(item, index) in tabItem.orderList" :key="index" class="order-item flex">
  31. <view class="title-box">
  32. <view class="title">
  33. <text>{{ item.title }}</text>
  34. </view>
  35. <view class="time">
  36. <text>{{ item.add_time }}</text>
  37. </view>
  38. </view>
  39. <view class="money" :class="{'money-num': item.pm == 0 }">
  40. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  41. </view>
  42. </view>
  43. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  44. </scroll-view>
  45. </swiper-item>
  46. </swiper>
  47. </view>
  48. </template>
  49. <script>
  50. // import { spreadCommission, userBalance } from '@/api/wallet.js';
  51. import { mapState, mapMutations } from 'vuex';
  52. import { getMoneyStyle } from '@/utils/rocessor.js';
  53. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  54. import empty from '@/components/empty';
  55. export default {
  56. filters: {
  57. getMoneyStyle
  58. },
  59. components: {
  60. empty,
  61. uniLoadMore
  62. },
  63. onReady() {
  64. // 初始化获取页面宽度
  65. uni.createSelectorQuery()
  66. .select('.content')
  67. .fields(
  68. {
  69. size: true
  70. },
  71. data => {
  72. // 保存头部高度
  73. this.maxheight = data.height - Math.floor((data.width / 750) * 570);
  74. }
  75. )
  76. .exec();
  77. },
  78. computed: {
  79. ...mapState(['userInfo'])
  80. },
  81. data() {
  82. return {
  83. // 头部图高度
  84. maxheight: '',
  85. tabCurrentIndex: 0,
  86. navList: [
  87. {
  88. state: 1,
  89. text: '支出',
  90. loadingType: 'more',
  91. orderList: [],
  92. page: 1, //当前页数
  93. limit: 10 //每次信息条数
  94. },
  95. {
  96. state: 2,
  97. text: '收入',
  98. loadingType: 'more',
  99. orderList: [],
  100. page: 1, //当前页数
  101. limit: 10 //每次信息条数
  102. }
  103. ],
  104. };
  105. },
  106. onLoad() {
  107. console.log(this.userInfo)
  108. },
  109. onShow() {
  110. // this.loadData();
  111. },
  112. methods: {
  113. // 页面跳转
  114. navto(e) {
  115. uni.navigateTo({
  116. url: e
  117. });
  118. },
  119. //获取收入支出信息
  120. async loadData(source) {
  121. //这里是将订单挂载到tab列表下
  122. let index = this.tabCurrentIndex;
  123. let navItem = this.navList[index];
  124. let state = navItem.state;
  125. if (source === 'tabChange' && navItem.loaded === true) {
  126. //tab切换只有第一次需要加载数据
  127. return;
  128. }
  129. if (navItem.loadingType === 'loading') {
  130. //防止重复加载
  131. return;
  132. }
  133. // 修改当前对象状态为加载中
  134. navItem.loadingType = 'loading';
  135. spreadCommission(
  136. {
  137. page: navItem.page,
  138. limit: navItem.limit
  139. },
  140. state
  141. )
  142. .then(({ data }) => {
  143. if (data.length > 0) {
  144. navItem.orderList = navItem.orderList.concat(data[0].list);
  145. console.log(navItem.orderList);
  146. navItem.page++;
  147. }
  148. if (navItem.limit == data.length) {
  149. //判断是否还有数据, 有改为 more, 没有改为noMore
  150. navItem.loadingType = 'more';
  151. return;
  152. } else {
  153. //判断是否还有数据, 有改为 more, 没有改为noMore
  154. navItem.loadingType = 'noMore';
  155. }
  156. uni.hideLoading();
  157. this.$set(navItem, 'loaded', true);
  158. })
  159. .catch(e => {
  160. console.log(e);
  161. });
  162. },
  163. //swiper 切换
  164. changeTab(e) {
  165. this.tabCurrentIndex = e.target.current;
  166. this.loadData('tabChange');
  167. },
  168. //顶部tab点击
  169. tabClick(index) {
  170. this.tabCurrentIndex = index;
  171. }
  172. }
  173. };
  174. </script>
  175. <style lang="scss">
  176. page {
  177. background: #ffffff;
  178. height: 100%;
  179. }
  180. .content-money {
  181. background: $page-color-base;
  182. .moneyTx {
  183. position: absolute;
  184. top: 150rpx;
  185. right: 0rpx;
  186. width: 150rpx;
  187. padding: 10rpx 30rpx;
  188. border: 2px solid #ffffff;
  189. border-top-left-radius: 99rpx;
  190. border-bottom-left-radius: 99rpx;
  191. color: #ffffff;
  192. line-height: 1;
  193. font-size: $font-base;
  194. }
  195. .buttom-box {
  196. background-color: #ffffff;
  197. text-align: center;
  198. margin: 0 30rpx;
  199. padding: 20rpx 0;
  200. border-radius: $border-radius-sm;
  201. margin-top: -60rpx;
  202. .buttom {
  203. font-size: $font-lg;
  204. flex-grow: 1;
  205. }
  206. .interval {
  207. width: 2px;
  208. height: 60rpx;
  209. background-color: #eeeeee;
  210. }
  211. .icon {
  212. height: 50rpx;
  213. width: 48rpx;
  214. margin: 0 auto;
  215. .icon-img {
  216. width: 36rpx;
  217. height: 36rpx;
  218. margin-bottom: 10rpx;
  219. }
  220. }
  221. }
  222. }
  223. .money-box {
  224. background:linear-gradient(52deg,rgba(151,143,250,1) 0%,rgba(126,153,254,1) 100%);
  225. height: 350rpx;
  226. color: #ffffff;
  227. text-align: center;
  228. padding-top:120rpx;
  229. .text {
  230. font-size:24rpx;
  231. font-weight: 400;
  232. color: rgba(255,255,255,1);
  233. }
  234. .money {
  235. margin-top: 20rpx;
  236. font-size: 60rpx;
  237. font-weight: bold;
  238. color: rgba(255,255,255,1);
  239. }
  240. }
  241. .navbar {
  242. display: flex;
  243. height: 40px;
  244. padding: 0 5px;
  245. background: #fff;
  246. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  247. position: relative;
  248. z-index: 10;
  249. .nav-item {
  250. flex: 1;
  251. display: flex;
  252. justify-content: center;
  253. align-items: center;
  254. height: 100%;
  255. font-size: 15px;
  256. color: $font-color-dark;
  257. position: relative;
  258. &.current {
  259. &:after {
  260. content: '';
  261. position: absolute;
  262. left: 50%;
  263. bottom: 0;
  264. transform: translateX(-50%);
  265. width: 44px;
  266. height: 0;
  267. border-bottom: 2px solid #6786FB;
  268. }
  269. }
  270. }
  271. }
  272. // 列表
  273. .swiper-box {
  274. padding-top: 10rpx;
  275. .order-item {
  276. padding: 20rpx 30rpx;
  277. line-height: 1.5;
  278. .title-box {
  279. .title {
  280. font-size: $font-lg;
  281. color: $font-color-base;
  282. }
  283. .time {
  284. font-size: $font-base;
  285. color: $font-color-light;
  286. }
  287. }
  288. .money {
  289. color: #E73932;
  290. font-size: $font-lg;
  291. }
  292. .money.money-num {
  293. color: #333333;
  294. }
  295. }
  296. }
  297. .list-scroll-content {
  298. height: 100%;
  299. }
  300. .content {
  301. height: 100%;
  302. .empty-content {
  303. background-color: #ffffff;
  304. }
  305. }
  306. </style>