wallet.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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. margin-top: -1rpx;
  248. .text {
  249. padding-top: 147rpx;
  250. font-size: $font-sm;
  251. }
  252. .money {
  253. padding-top: 137rpx;
  254. // margin: auto 0;
  255. font-size: 56rpx;
  256. font-weight: bold;
  257. color: #FFFFFF;
  258. .money-icon {
  259. font-size: 38rpx;
  260. font-weight: bold;
  261. color: #FFFFFF;
  262. }
  263. }
  264. }
  265. .navbar {
  266. display: flex;
  267. height: 40px;
  268. padding: 0 5px;
  269. background: #fff;
  270. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  271. position: relative;
  272. z-index: 10;
  273. .nav-item {
  274. flex: 1;
  275. display: flex;
  276. justify-content: center;
  277. align-items: center;
  278. height: 100%;
  279. font-size: 15px;
  280. color: #999999;
  281. position: relative;
  282. &.current {
  283. color: $base-color;
  284. &:after {
  285. content: '';
  286. position: absolute;
  287. left: 50%;
  288. bottom: 0;
  289. transform: translateX(-50%);
  290. width: 44px;
  291. height: 0;
  292. border-bottom: 2px solid $base-color;
  293. }
  294. }
  295. }
  296. }
  297. // 列表
  298. .swiper-box {
  299. padding-top: 10rpx;
  300. .order-item {
  301. padding: 20rpx 30rpx;
  302. line-height: 1.5;
  303. position: relative;
  304. // border-bottom: 1rpx black solid;
  305. .title-box {
  306. .title {
  307. font-size: $font-lg;
  308. color: $font-color-base;
  309. }
  310. .time {
  311. font-size: $font-base;
  312. color: $font-color-light;
  313. }
  314. }
  315. .money {
  316. // color: #fd5b23;
  317. color: #901B21;
  318. font-size: $font-lg;
  319. }
  320. .jg {
  321. width: 701rpx;
  322. height: 2rpx;
  323. background: #F0F4F8;
  324. margin: 0 auto;
  325. position: absolute;
  326. bottom: 0;
  327. }
  328. }
  329. }
  330. .list-scroll-content {
  331. height: 100%;
  332. }
  333. .content {
  334. height: 100%;
  335. .empty-content {
  336. background-color: #ffffff;
  337. }
  338. }
  339. .add-btn {
  340. position: fixed;
  341. bottom: 51rpx;
  342. right: 39rpx;
  343. width: 674rpx;
  344. height: 88rpx;
  345. background: #901B21;
  346. border-radius: 44rpx;
  347. color: #fff;
  348. text-align: center;
  349. line-height: 88rpx;
  350. font-size: 34rpx;
  351. }
  352. </style>