wallet.vue 7.8 KB

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