wallet.vue 7.2 KB

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