wallet.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="money-box">
  5. <image src="../../static/img/img33.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. if (data.length > 0) {
  138. data.forEach(e =>{
  139. console.log(e);
  140. navItem.orderList = navItem.orderList.concat(e.list);
  141. })
  142. console.log(navItem.orderList);
  143. navItem.page++;
  144. }
  145. if (navItem.limit == data.length) {
  146. //判断是否还有数据, 有改为 more, 没有改为noMore
  147. navItem.loadingType = 'more';
  148. return;
  149. } else {
  150. //判断是否还有数据, 有改为 more, 没有改为noMore
  151. navItem.loadingType = 'noMore';
  152. }
  153. uni.hideLoading();
  154. this.$set(navItem, 'loaded', true);
  155. })
  156. .catch(e => {
  157. console.log(e);
  158. });
  159. },
  160. //swiper 切换
  161. changeTab(e) {
  162. this.tabCurrentIndex = e.target.current;
  163. this.loadData('tabChange');
  164. },
  165. //顶部tab点击
  166. tabClick(index) {
  167. this.tabCurrentIndex = index;
  168. },
  169. addmoney() {
  170. uni.navigateTo({
  171. url: '/pages/money/recharge'
  172. })
  173. }
  174. }
  175. };
  176. </script>
  177. <style lang="scss">
  178. page {
  179. background: #ffffff;
  180. height: 100%;
  181. }
  182. .content-money {
  183. padding-bottom: 30rpx;
  184. background: $page-color-base;
  185. .moneyTx {
  186. position: absolute;
  187. top: 150rpx;
  188. right: 0rpx;
  189. width: 150rpx;
  190. padding: 10rpx 30rpx;
  191. border: 2px solid #ffffff;
  192. border-top-left-radius: 99rpx;
  193. border-bottom-left-radius: 99rpx;
  194. color: #ffffff;
  195. line-height: 1;
  196. font-size: $font-base;
  197. }
  198. .buttom-box {
  199. background-color: #ffffff;
  200. text-align: center;
  201. margin: 0 30rpx;
  202. padding: 20rpx 0;
  203. border-radius: $border-radius-sm;
  204. margin-top: -60rpx;
  205. .buttom {
  206. font-size: $font-lg;
  207. flex-grow: 1;
  208. }
  209. .interval {
  210. width: 2px;
  211. height: 60rpx;
  212. background-color: #eeeeee;
  213. }
  214. .icon {
  215. height: 50rpx;
  216. width: 48rpx;
  217. margin: 0 auto;
  218. .icon-img {
  219. width: 100%;
  220. height: 100%;
  221. }
  222. }
  223. }
  224. }
  225. .money-box {
  226. // background-color: $base-color;
  227. // padding-top: var(--status-bar-height);
  228. height: 400rpx;
  229. color: #FF4C4C;
  230. text-align: center;
  231. position: relative;
  232. image {
  233. position: absolute;
  234. top: 0;
  235. right: 0;
  236. height: 100%;
  237. width: 100%;
  238. // z-index: 1;
  239. }
  240. .text {
  241. padding-top: 147rpx;
  242. font-size: $font-sm;
  243. position: relative;
  244. }
  245. .money {
  246. padding-top: 175rpx;
  247. // margin: auto 0;
  248. font-size: 56rpx;
  249. font-weight: bold;
  250. color: #3F7C1F;
  251. position: relative;
  252. .money-icon {
  253. font-size: 38rpx;
  254. font-weight: bold;
  255. color: #3F7C1F;
  256. }
  257. }
  258. }
  259. .navbar {
  260. display: flex;
  261. height: 40px;
  262. padding: 0 5px;
  263. background: #fff;
  264. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  265. position: relative;
  266. z-index: 10;
  267. .nav-item {
  268. flex: 1;
  269. display: flex;
  270. justify-content: center;
  271. align-items: center;
  272. height: 100%;
  273. font-size: 15px;
  274. color: #999999;
  275. position: relative;
  276. &.current {
  277. color: $base-color;
  278. &:after {
  279. content: '';
  280. position: absolute;
  281. left: 50%;
  282. bottom: 0;
  283. transform: translateX(-50%);
  284. width: 44px;
  285. height: 0;
  286. border-bottom: 2px solid $base-color;
  287. }
  288. }
  289. }
  290. }
  291. // 列表
  292. .swiper-box {
  293. padding-top: 10rpx;
  294. .order-item {
  295. padding: 20rpx 30rpx;
  296. line-height: 1.5;
  297. position: relative;
  298. // border-bottom: 1rpx black solid;
  299. .title-box {
  300. .title {
  301. font-size: $font-lg;
  302. color: $font-color-base;
  303. }
  304. .time {
  305. font-size: $font-base;
  306. color: $font-color-light;
  307. }
  308. }
  309. .money {
  310. // color: #fd5b23;
  311. color: #901B21;
  312. font-size: $font-lg;
  313. }
  314. .jg {
  315. width: 701rpx;
  316. height: 2rpx;
  317. background: #F0F4F8;
  318. margin: 0 auto;
  319. position: absolute;
  320. bottom: 0;
  321. }
  322. }
  323. }
  324. .list-scroll-content {
  325. height: 100%;
  326. }
  327. .content {
  328. height: 100%;
  329. .empty-content {
  330. background-color: #ffffff;
  331. }
  332. }
  333. .add-btn {
  334. position: fixed;
  335. bottom: 51rpx;
  336. right: 39rpx;
  337. width: 674rpx;
  338. height: 88rpx;
  339. background: linear-gradient(-35deg, #F8DD4F, #FBEB77);
  340. border-radius: 44rpx;
  341. color: #fff;
  342. text-align: center;
  343. line-height: 88rpx;
  344. font-size: 34rpx;
  345. }
  346. </style>