wallet.vue 7.1 KB

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