wallet.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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>{{ 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.add_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 { spreadCommission, userBalance } from '@/api/wallet.js';
  53. import { getMoneyStyle } from '@/utils/rocessor.js';
  54. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  55. import empty from '@/components/empty';
  56. export default {
  57. filters: {
  58. getMoneyStyle
  59. },
  60. components: {
  61. empty,
  62. uniLoadMore
  63. },
  64. onReady() {
  65. // 初始化获取页面宽度
  66. uni.createSelectorQuery()
  67. .select('.content')
  68. .fields(
  69. {
  70. size: true
  71. },
  72. data => {
  73. console.log(data);
  74. console.log(Math.floor((data.width / 750) * 300));
  75. // 保存头部高度
  76. this.maxheight =data.height - Math.floor((data.width / 750) * 570);
  77. console.log(this.maxheight);
  78. }
  79. )
  80. .exec();
  81. },
  82. data() {
  83. return {
  84. // 头部图高度
  85. maxheight:'',
  86. tabCurrentIndex: 1,
  87. navList: [
  88. {
  89. state: 0,
  90. text: '全部',
  91. loadingType: 'more',
  92. orderList: [],
  93. page: 1, //当前页数
  94. limit: 10 //每次信息条数
  95. },
  96. {
  97. state: 1,
  98. text: '收入',
  99. loadingType: 'more',
  100. orderList: [
  101. // { title: 'hello word', add_time: '2021-02-03', pm: 0, number: 99},
  102. // { title: 'hello word', add_time: '2021-02-03', pm: 0, number: 99},
  103. // { title: 'hello word', add_time: '2021-02-03', pm: 0, number: 99}
  104. ],
  105. page: 1, //当前页数
  106. limit: 10 //每次信息条数
  107. },
  108. {
  109. state: 2,
  110. text: '支出',
  111. loadingType: 'more',
  112. orderList: [],
  113. page: 1, //当前页数
  114. limit: 10 //每次信息条数
  115. }
  116. ],
  117. money: ''
  118. };
  119. },
  120. onLoad(options) {},
  121. onShow() {
  122. // this.loadData();
  123. // 获取用户余额
  124. // userBalance({}).then(({ data }) => {
  125. // this.money = data.now_money;
  126. // });
  127. },
  128. methods: {
  129. // 页面跳转
  130. navto(e) {
  131. uni.navigateTo({
  132. url: e
  133. });
  134. },
  135. //获取收入支出信息
  136. async loadData(source) {
  137. //这里是将订单挂载到tab列表下
  138. let index = this.tabCurrentIndex;
  139. let navItem = this.navList[index];
  140. let state = navItem.state;
  141. if (source === 'tabChange' && navItem.loaded === true) {
  142. //tab切换只有第一次需要加载数据
  143. return;
  144. }
  145. if (navItem.loadingType === 'loading') {
  146. //防止重复加载
  147. return;
  148. }
  149. // 修改当前对象状态为加载中
  150. navItem.loadingType = 'loading';
  151. spreadCommission(
  152. {
  153. page: navItem.page,
  154. limit: navItem.limit
  155. },
  156. state
  157. )
  158. .then(({ data }) => {
  159. if (data.length > 0) {
  160. navItem.orderList = navItem.orderList.concat(data[0].list);
  161. console.log(navItem.orderList);
  162. navItem.page++;
  163. }
  164. if (navItem.limit == data.length) {
  165. //判断是否还有数据, 有改为 more, 没有改为noMore
  166. navItem.loadingType = 'more';
  167. return;
  168. } else {
  169. //判断是否还有数据, 有改为 more, 没有改为noMore
  170. navItem.loadingType = 'noMore';
  171. }
  172. uni.hideLoading();
  173. this.$set(navItem, 'loaded', true);
  174. })
  175. .catch(e => {
  176. console.log(e);
  177. });
  178. },
  179. //swiper 切换
  180. changeTab(e) {
  181. this.tabCurrentIndex = e.target.current;
  182. this.loadData('tabChange');
  183. },
  184. //顶部tab点击
  185. tabClick(index) {
  186. this.tabCurrentIndex = index;
  187. }
  188. }
  189. };
  190. </script>
  191. <style lang="scss">
  192. page {
  193. background: #ffffff;
  194. height: 100%;
  195. }
  196. .content-money {
  197. padding-bottom: 30rpx;
  198. background: $page-color-base;
  199. .moneyTx {
  200. position: absolute;
  201. top: 150rpx;
  202. right: 0rpx;
  203. width: 150rpx;
  204. padding: 10rpx 30rpx;
  205. border: 2px solid #ffffff;
  206. border-top-left-radius: 99rpx;
  207. border-bottom-left-radius: 99rpx;
  208. color: #ffffff;
  209. line-height: 1;
  210. font-size: $font-base;
  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. background-image: url(../../static/img/wallertbg.png);
  246. background-size: 100% 100%;
  247. .text {
  248. padding-top: 147rpx;
  249. font-size: $font-sm;
  250. }
  251. .money {
  252. padding-top: 137rpx;
  253. // margin: auto 0;
  254. font-size: 56rpx;
  255. font-weight: bold;
  256. color: #FFFFFF;
  257. .money-icon {
  258. font-size: 38rpx;
  259. font-weight: bold;
  260. color: #FFFFFF;
  261. }
  262. }
  263. }
  264. .navbar {
  265. display: flex;
  266. height: 40px;
  267. padding: 0 5px;
  268. background: #fff;
  269. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  270. position: relative;
  271. z-index: 10;
  272. .nav-item {
  273. flex: 1;
  274. display: flex;
  275. justify-content: center;
  276. align-items: center;
  277. height: 100%;
  278. font-size: 15px;
  279. color: $font-color-dark;
  280. position: relative;
  281. &.current {
  282. color: $base-color;
  283. &:after {
  284. content: '';
  285. position: absolute;
  286. left: 50%;
  287. bottom: 0;
  288. transform: translateX(-50%);
  289. width: 44px;
  290. height: 0;
  291. border-bottom: 2px solid $base-color;
  292. }
  293. }
  294. }
  295. }
  296. // 列表
  297. .swiper-box {
  298. padding-top: 10rpx;
  299. .order-item {
  300. padding: 20rpx 30rpx;
  301. line-height: 1.5;
  302. position: relative;
  303. // border-bottom: 1rpx black solid;
  304. .title-box {
  305. .title {
  306. font-size: $font-lg;
  307. color: $font-color-base;
  308. }
  309. .time {
  310. font-size: $font-base;
  311. color: $font-color-light;
  312. }
  313. }
  314. .money {
  315. // color: #fd5b23;
  316. color: #901B21;
  317. font-size: $font-lg;
  318. }
  319. .jg {
  320. width: 701rpx;
  321. height: 2rpx;
  322. background: #F0F4F8;
  323. margin: 0 auto;
  324. position: absolute;
  325. bottom: 0;
  326. }
  327. }
  328. }
  329. .list-scroll-content {
  330. height: 100%;
  331. }
  332. .content {
  333. height: 100%;
  334. .empty-content {
  335. background-color: #ffffff;
  336. }
  337. }
  338. .add-btn {
  339. width: 674rpx;
  340. height: 88rpx;
  341. background: #FF383E;
  342. border-radius: 44rpx;
  343. }
  344. </style>