wallet.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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. // height: 100rpx;
  199. padding: 10rpx 30rpx;
  200. border: 2px solid #ffffff;
  201. border-top-left-radius: 99rpx;
  202. border-bottom-left-radius: 99rpx;
  203. color: #ffffff;
  204. line-height: 1.6;
  205. font-size: 32rpx;
  206. }
  207. .buttom-box {
  208. background-color: #ffffff;
  209. text-align: center;
  210. margin: 0 30rpx;
  211. padding: 20rpx 0;
  212. border-radius: $border-radius-sm;
  213. margin-top: -60rpx;
  214. .buttom {
  215. font-size: $font-lg;
  216. flex-grow: 1;
  217. }
  218. .interval {
  219. width: 2px;
  220. height: 60rpx;
  221. background-color: #eeeeee;
  222. }
  223. .icon {
  224. height: 50rpx;
  225. width: 48rpx;
  226. margin: 0 auto;
  227. .icon-img {
  228. width: 100%;
  229. height: 100%;
  230. }
  231. }
  232. }
  233. }
  234. .money-box {
  235. background-color: $base-color;
  236. padding-top: var(--status-bar-height);
  237. height: 368rpx;
  238. color: #ffffff;
  239. text-align: center;
  240. .text {
  241. padding-top: 147rpx;
  242. font-size: $font-sm;
  243. }
  244. .money {
  245. font-size: 56rpx;
  246. }
  247. }
  248. .navbar {
  249. display: flex;
  250. height: 40px;
  251. padding: 0 5px;
  252. background: #fff;
  253. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  254. position: relative;
  255. z-index: 10;
  256. .nav-item {
  257. flex: 1;
  258. display: flex;
  259. justify-content: center;
  260. align-items: center;
  261. height: 100%;
  262. font-size: 15px;
  263. color: $font-color-dark;
  264. position: relative;
  265. &.current {
  266. color: $base-color;
  267. &:after {
  268. content: '';
  269. position: absolute;
  270. left: 50%;
  271. bottom: 0;
  272. transform: translateX(-50%);
  273. width: 44px;
  274. height: 0;
  275. border-bottom: 2px solid $base-color;
  276. }
  277. }
  278. }
  279. }
  280. // 列表
  281. .swiper-box {
  282. padding-top: 10rpx;
  283. .order-item {
  284. padding: 20rpx 30rpx;
  285. line-height: 1.5;
  286. .title-box {
  287. .title {
  288. font-size: $font-lg;
  289. color: $font-color-base;
  290. }
  291. .time {
  292. font-size: $font-base;
  293. color: $font-color-light;
  294. }
  295. }
  296. .money {
  297. color: #fd5b23;
  298. font-size: $font-lg;
  299. }
  300. }
  301. }
  302. .list-scroll-content {
  303. height: 100%;
  304. }
  305. .content {
  306. height: 100%;
  307. .empty-content {
  308. background-color: #ffffff;
  309. }
  310. }
  311. </style>