wallet.vue 6.5 KB

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