wallet.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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"><text class="money-icon">¥</text>{{ userInfo.now_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)" v-if="item.text!=='全部'">{{ 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.create_time }}</text>
  37. </view>
  38. </view>
  39. <view class="money">
  40. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  41. </view>
  42. <view class="jg"></view>
  43. </view>
  44. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  45. </scroll-view>
  46. </swiper-item>
  47. </swiper>
  48. <view class="add-btn">立刻充值</view>
  49. </view>
  50. </template>
  51. <script>
  52. import { mapState, mapMutations } from 'vuex';
  53. import { spreadCommission, userBalance } from '@/api/wallet.js';
  54. import { getMoneyStyle } from '@/utils/rocessor.js';
  55. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  56. import empty from '@/components/empty';
  57. export default {
  58. filters: {
  59. getMoneyStyle
  60. },
  61. components: {
  62. empty,
  63. uniLoadMore
  64. },
  65. onReady() {
  66. // 初始化获取页面宽度
  67. uni.createSelectorQuery()
  68. .select('.content')
  69. .fields(
  70. {
  71. size: true
  72. },
  73. data => {
  74. console.log(data);
  75. console.log(Math.floor((data.width / 750) * 300));
  76. // 保存头部高度
  77. this.maxheight =data.height - Math.floor((data.width / 750) * 570);
  78. console.log(this.maxheight);
  79. }
  80. )
  81. .exec();
  82. },
  83. data() {
  84. return {
  85. // 头部图高度
  86. maxheight:'',
  87. tabCurrentIndex: 1,
  88. navList: [
  89. {
  90. state: 1,
  91. text: '支出',
  92. loadingType: 'more',
  93. orderList: [
  94. // { title: 'hello word', add_time: '2021-02-03', pm: 0, number: 99},
  95. // { title: 'hello word', add_time: '2021-02-03', pm: 0, number: 99},
  96. // { title: 'hello word', add_time: '2021-02-03', pm: 0, number: 99}
  97. ],
  98. page: 1, //当前页数
  99. limit: 10 //每次信息条数
  100. },
  101. {
  102. state: 2,
  103. text: '收入',
  104. loadingType: 'more',
  105. orderList: [],
  106. page: 1, //当前页数
  107. limit: 10 //每次信息条数
  108. }
  109. ],
  110. money: ''
  111. };
  112. },
  113. computed: {
  114. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  115. },
  116. onLoad(options) {},
  117. onShow() {
  118. this.loadData();
  119. // 获取用户余额
  120. },
  121. methods: {
  122. // 页面跳转
  123. navto(e) {
  124. uni.navigateTo({
  125. url: e
  126. });
  127. },
  128. //获取收入支出信息
  129. async loadData(source) {
  130. //这里是将订单挂载到tab列表下
  131. let index = this.tabCurrentIndex;
  132. let navItem = this.navList[index];
  133. let state = navItem.state;
  134. if (source === 'tabChange' && navItem.loaded === true) {
  135. //tab切换只有第一次需要加载数据
  136. return;
  137. }
  138. if (navItem.loadingType === 'loading') {
  139. //防止重复加载
  140. return;
  141. }
  142. // 修改当前对象状态为加载中
  143. navItem.loadingType = 'loading';
  144. spreadCommission(
  145. {
  146. page: navItem.page,
  147. limit: navItem.limit,
  148. type: state
  149. },
  150. )
  151. .then(({ data }) => {
  152. console.log(data);
  153. if (data.count > 0) {
  154. navItem.orderList = navItem.orderList.concat(data.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: 265rpx;
  237. color: #ffffff;
  238. text-align: center;
  239. background-image: url(../../static/img/wallertbg.png);
  240. background-size: 100%;
  241. background-position: bottom;
  242. .text {
  243. padding-top: 147rpx;
  244. font-size: $font-sm;
  245. }
  246. .money {
  247. padding-top: 137rpx;
  248. // margin: auto 0;
  249. font-size: 56rpx;
  250. font-weight: bold;
  251. color: #FFFFFF;
  252. .money-icon {
  253. font-size: 38rpx;
  254. font-weight: bold;
  255. color: #FFFFFF;
  256. }
  257. }
  258. }
  259. .navbar {
  260. display: flex;
  261. height: 40px;
  262. padding: 0 5px;
  263. background: #fff;
  264. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  265. position: relative;
  266. z-index: 10;
  267. .nav-item {
  268. flex: 1;
  269. display: flex;
  270. justify-content: center;
  271. align-items: center;
  272. height: 100%;
  273. font-size: 15px;
  274. color: #999999;
  275. position: relative;
  276. &.current {
  277. color: $base-color;
  278. &:after {
  279. content: '';
  280. position: absolute;
  281. left: 50%;
  282. bottom: 0;
  283. transform: translateX(-50%);
  284. width: 44px;
  285. height: 0;
  286. border-bottom: 2px solid $base-color;
  287. }
  288. }
  289. }
  290. }
  291. // 列表
  292. .swiper-box {
  293. padding-top: 10rpx;
  294. .order-item {
  295. padding: 20rpx 30rpx;
  296. line-height: 1.5;
  297. position: relative;
  298. // border-bottom: 1rpx black solid;
  299. .title-box {
  300. .title {
  301. font-size: $font-lg;
  302. color: $font-color-base;
  303. }
  304. .time {
  305. font-size: $font-base;
  306. color: $font-color-light;
  307. }
  308. }
  309. .money {
  310. // color: #fd5b23;
  311. color: #901B21;
  312. font-size: $font-lg;
  313. }
  314. .jg {
  315. width: 701rpx;
  316. height: 2rpx;
  317. background: #F0F4F8;
  318. margin: 0 auto;
  319. position: absolute;
  320. bottom: 0;
  321. }
  322. }
  323. }
  324. .list-scroll-content {
  325. height: 100%;
  326. }
  327. .content {
  328. height: 100%;
  329. .empty-content {
  330. background-color: #ffffff;
  331. }
  332. }
  333. .add-btn {
  334. position: fixed;
  335. bottom: 51rpx;
  336. right: 39rpx;
  337. width: 674rpx;
  338. height: 88rpx;
  339. background: #901B21;
  340. border-radius: 44rpx;
  341. color: #fff;
  342. text-align: center;
  343. line-height: 88rpx;
  344. font-size: 34rpx;
  345. }
  346. </style>