wallet.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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. console.log(e,'123456');
  127. uni.navigateTo({
  128. url: e
  129. });
  130. },
  131. //获取收入支出信息
  132. async loadData(source) {
  133. //这里是将订单挂载到tab列表下
  134. let index = this.tabCurrentIndex;
  135. let navItem = this.navList[index];
  136. let state = navItem.state;
  137. if (source === 'tabChange' && navItem.loaded === true) {
  138. //tab切换只有第一次需要加载数据
  139. return;
  140. }
  141. if (navItem.loadingType === 'loading') {
  142. //防止重复加载
  143. return;
  144. }
  145. // 修改当前对象状态为加载中
  146. navItem.loadingType = 'loading';
  147. spreadCommission(
  148. {
  149. page: navItem.page,
  150. limit: navItem.limit
  151. },
  152. state
  153. )
  154. .then(({ data }) => {
  155. if (data.length > 0) {
  156. navItem.orderList = navItem.orderList.concat(data[0].list);
  157. console.log(navItem.orderList);
  158. navItem.page++;
  159. }
  160. if (navItem.limit == data.length) {
  161. //判断是否还有数据, 有改为 more, 没有改为noMore
  162. navItem.loadingType = 'more';
  163. return;
  164. } else {
  165. //判断是否还有数据, 有改为 more, 没有改为noMore
  166. navItem.loadingType = 'noMore';
  167. }
  168. uni.hideLoading();
  169. this.$set(navItem, 'loaded', true);
  170. })
  171. .catch(e => {
  172. console.log(e);
  173. });
  174. },
  175. //swiper 切换
  176. changeTab(e) {
  177. this.tabCurrentIndex = e.target.current;
  178. this.loadData('tabChange');
  179. },
  180. //顶部tab点击
  181. tabClick(index) {
  182. this.tabCurrentIndex = index;
  183. }
  184. }
  185. };
  186. </script>
  187. <style lang="scss">
  188. page {
  189. background: #ffffff;
  190. height: 100%;
  191. }
  192. .content-money {
  193. padding-bottom: 30rpx;
  194. background: $page-color-base;
  195. .moneyTx {
  196. position: absolute;
  197. top: 100rpx;
  198. right: 0rpx;
  199. width: 170rpx;
  200. height: 60rpx;
  201. text-align: center;
  202. padding: 10rpx ;
  203. border: 2px solid #ffffff;
  204. border-top-left-radius: 99rpx;
  205. border-bottom-left-radius: 99rpx;
  206. color: #ffffff;
  207. line-height: 1;
  208. font-size: $font-base;
  209. }
  210. .two{
  211. margin-top: 80rpx;
  212. }
  213. .buttom-box {
  214. background-color: #ffffff;
  215. text-align: center;
  216. margin: 0 30rpx;
  217. padding: 20rpx 0;
  218. border-radius: $border-radius-sm;
  219. margin-top: -60rpx;
  220. .buttom {
  221. font-size: $font-lg;
  222. flex-grow: 1;
  223. }
  224. .interval {
  225. width: 2px;
  226. height: 60rpx;
  227. background-color: #eeeeee;
  228. }
  229. .icon {
  230. height: 50rpx;
  231. width: 48rpx;
  232. margin: 0 auto;
  233. .icon-img {
  234. width: 100%;
  235. height: 100%;
  236. }
  237. }
  238. }
  239. }
  240. .money-box {
  241. background-color: $base-color;
  242. padding-top: var(--status-bar-height);
  243. height: 368rpx;
  244. color: #ffffff;
  245. text-align: center;
  246. .text {
  247. padding-top: 147rpx;
  248. font-size: $font-sm;
  249. }
  250. .money {
  251. font-size: 56rpx;
  252. }
  253. }
  254. .navbar {
  255. display: flex;
  256. height: 40px;
  257. padding: 0 5px;
  258. background: #fff;
  259. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  260. position: relative;
  261. z-index: 10;
  262. .nav-item {
  263. flex: 1;
  264. display: flex;
  265. justify-content: center;
  266. align-items: center;
  267. height: 100%;
  268. font-size: 15px;
  269. color: $font-color-dark;
  270. position: relative;
  271. &.current {
  272. color: $base-color;
  273. &:after {
  274. content: '';
  275. position: absolute;
  276. left: 50%;
  277. bottom: 0;
  278. transform: translateX(-50%);
  279. width: 44px;
  280. height: 0;
  281. border-bottom: 2px solid $base-color;
  282. }
  283. }
  284. }
  285. }
  286. // 列表
  287. .swiper-box {
  288. padding-top: 10rpx;
  289. .order-item {
  290. padding: 20rpx 30rpx;
  291. line-height: 1.5;
  292. .title-box {
  293. .title {
  294. font-size: $font-lg;
  295. color: $font-color-base;
  296. }
  297. .time {
  298. font-size: $font-base;
  299. color: $font-color-light;
  300. }
  301. }
  302. .money {
  303. color: #fd5b23;
  304. font-size: $font-lg;
  305. }
  306. }
  307. }
  308. .list-scroll-content {
  309. height: 100%;
  310. }
  311. .content {
  312. height: 100%;
  313. .empty-content {
  314. background-color: #ffffff;
  315. }
  316. }
  317. </style>