wallet.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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">{{ money | getMoneyStyle }}</view>
  7. </view>
  8. <view class="moneyTx" @click="navto('/pages/money/recharge')">充值</view>
  9. <view class="flex buttom-box">
  10. <view class="buttom" @click="navto('/pages/money/recharge')">
  11. <view class="icon"><image class="icon-img" src="/static/icon/i5.png" mode="aspectFit"></image></view>
  12. <text>充值</text>
  13. </view>
  14. <view class="interval"></view>
  15. <view class="buttom" @click="navto('/pages/money/withdrawal')">
  16. <view class="icon"><image class="icon-img" src="/static/icon/i1.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">
  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 { getMoneyStyle } from '@/utils/rocessor.js';
  52. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  53. import empty from '@/components/empty';
  54. export default {
  55. filters: {
  56. getMoneyStyle
  57. },
  58. components: {
  59. empty,
  60. uniLoadMore
  61. },
  62. onReady() {
  63. // 初始化获取页面宽度
  64. uni.createSelectorQuery()
  65. .select('.content')
  66. .fields(
  67. {
  68. size: true
  69. },
  70. data => {
  71. console.log(data);
  72. console.log(Math.floor((data.width / 750) * 300));
  73. // 保存头部高度
  74. this.maxheight =data.height - Math.floor((data.width / 750) * 570);
  75. console.log(this.maxheight);
  76. }
  77. )
  78. .exec();
  79. },
  80. data() {
  81. return {
  82. // 头部图高度
  83. maxheight:'',
  84. tabCurrentIndex: 0,
  85. navList: [
  86. {
  87. state: 0,
  88. text: '全部',
  89. loadingType: 'more',
  90. orderList: [],
  91. page: 1, //当前页数
  92. limit: 10 //每次信息条数
  93. },
  94. {
  95. state: 1,
  96. text: '支出',
  97. loadingType: 'more',
  98. orderList: [],
  99. page: 1, //当前页数
  100. limit: 10 //每次信息条数
  101. },
  102. {
  103. state: 2,
  104. text: '收入',
  105. loadingType: 'more',
  106. orderList: [],
  107. page: 1, //当前页数
  108. limit: 10 //每次信息条数
  109. }
  110. ],
  111. money: ''
  112. };
  113. },
  114. onLoad(options) {},
  115. onShow() {
  116. this.loadData();
  117. // 获取用户余额
  118. userBalance({}).then(({ data }) => {
  119. this.money = data.now_money;
  120. });
  121. },
  122. methods: {
  123. // 页面跳转
  124. navto(e) {
  125. uni.navigateTo({
  126. url: e
  127. });
  128. },
  129. //获取收入支出信息
  130. async loadData(source) {
  131. //这里是将订单挂载到tab列表下
  132. let index = this.tabCurrentIndex;
  133. let navItem = this.navList[index];
  134. let state = navItem.state;
  135. if (source === 'tabChange' && navItem.loaded === true) {
  136. //tab切换只有第一次需要加载数据
  137. return;
  138. }
  139. if (navItem.loadingType === 'loading') {
  140. //防止重复加载
  141. return;
  142. }
  143. // 修改当前对象状态为加载中
  144. navItem.loadingType = 'loading';
  145. spreadCommission(
  146. {
  147. page: navItem.page,
  148. limit: navItem.limit
  149. },
  150. state
  151. )
  152. .then(({ data }) => {
  153. if (data.length > 0) {
  154. navItem.orderList = navItem.orderList.concat(data[0].list);
  155. console.log(navItem.orderList);
  156. navItem.page++;
  157. }
  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. };
  184. </script>
  185. <style lang="scss">
  186. page {
  187. background: #ffffff;
  188. height: 100%;
  189. }
  190. .content-money {
  191. padding-bottom: 30rpx;
  192. background: $page-color-base;
  193. .moneyTx {
  194. position: absolute;
  195. top: 150rpx;
  196. right: 0rpx;
  197. width: 150rpx;
  198. padding: 10rpx 30rpx;
  199. border: 2px solid #ffffff;
  200. border-top-left-radius: 99rpx;
  201. border-bottom-left-radius: 99rpx;
  202. color: #ffffff;
  203. line-height: 1;
  204. font-size: $font-base;
  205. }
  206. .buttom-box {
  207. background-color: #ffffff;
  208. text-align: center;
  209. margin: 0 30rpx;
  210. padding: 20rpx 0;
  211. border-radius: $border-radius-sm;
  212. margin-top: -60rpx;
  213. .buttom {
  214. font-size: $font-lg;
  215. flex-grow: 1;
  216. }
  217. .interval {
  218. width: 2px;
  219. height: 60rpx;
  220. background-color: #eeeeee;
  221. }
  222. .icon {
  223. height: 50rpx;
  224. width: 48rpx;
  225. margin: 0 auto;
  226. .icon-img {
  227. width: 100%;
  228. height: 100%;
  229. }
  230. }
  231. }
  232. }
  233. .money-box {
  234. background-color: $base-color;
  235. padding-top: var(--status-bar-height);
  236. height: 368rpx;
  237. color: #ffffff;
  238. text-align: center;
  239. .text {
  240. padding-top: 147rpx;
  241. font-size: $font-sm;
  242. }
  243. .money {
  244. font-size: 56rpx;
  245. }
  246. }
  247. .navbar {
  248. display: flex;
  249. height: 40px;
  250. padding: 0 5px;
  251. background: #fff;
  252. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  253. position: relative;
  254. z-index: 10;
  255. .nav-item {
  256. flex: 1;
  257. display: flex;
  258. justify-content: center;
  259. align-items: center;
  260. height: 100%;
  261. font-size: 15px;
  262. color: $font-color-dark;
  263. position: relative;
  264. &.current {
  265. color: $base-color;
  266. &:after {
  267. content: '';
  268. position: absolute;
  269. left: 50%;
  270. bottom: 0;
  271. transform: translateX(-50%);
  272. width: 44px;
  273. height: 0;
  274. border-bottom: 2px solid $base-color;
  275. }
  276. }
  277. }
  278. }
  279. // 列表
  280. .swiper-box {
  281. padding-top: 10rpx;
  282. .order-item {
  283. padding: 20rpx 30rpx;
  284. line-height: 1.5;
  285. .title-box {
  286. .title {
  287. font-size: $font-lg;
  288. color: $font-color-base;
  289. }
  290. .time {
  291. font-size: $font-base;
  292. color: $font-color-light;
  293. }
  294. }
  295. .money {
  296. color: #fd5b23;
  297. font-size: $font-lg;
  298. }
  299. }
  300. }
  301. .list-scroll-content {
  302. height: 100%;
  303. }
  304. .content {
  305. height: 100%;
  306. .empty-content {
  307. background-color: #ffffff;
  308. }
  309. }
  310. </style>