wallet.vue 7.6 KB

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