wallet.vue 7.5 KB

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