wallet.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="money-box">
  5. <view class="bg"><image src="../../static/img/money.png" mode=""></image></view>
  6. <view class="body-title">
  7. <view class="goback-box" @click="toBack"><image class="goback" src="../../static/icon/fanhui.png" mode=""></image></view>
  8. <view class="header">我的余额</view>
  9. </view>
  10. <view>
  11. <view class="money">{{ money | getMoneyStyle }}</view>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="moneyTx" @click="navto('/pages/award/withdrawal?type=now_money')">提现</view>
  16. <view class="navbar">
  17. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  18. </view>
  19. <swiper :current="tabCurrentIndex" :style="{ height: maxheight + 'px' }" class="swiper-box" duration="300" @change="changeTab">
  20. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  21. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  22. <!-- 空白页 -->
  23. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  24. <!-- 订单列表 -->
  25. <view class="itemList" v-for="(items, indexs) in tabItem.orderList" :key="indexs">
  26. <!-- <view class='font-size-lg padding-l-30 bg-gray padding-v-10'>
  27. {{items.time}}
  28. </view> -->
  29. <view v-for="(item, index) in items.list" :key="index" class="order-item flex">
  30. <view class="title-box">
  31. <view class="title">
  32. <text>{{ item.title }}</text>
  33. </view>
  34. <view class="time">
  35. <text>{{ item.add_time }}</text>
  36. </view>
  37. </view>
  38. <view class="money">
  39. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  40. </view>
  41. </view>
  42. </view>
  43. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  44. </scroll-view>
  45. </swiper-item>
  46. </swiper>
  47. <view class="btn" @click="navto('/pages/wallet/recharge')">立即充值</view>
  48. </view>
  49. </template>
  50. <script>
  51. import { spreadCommission, userBalance, rechargemoneys } from '@/api/wallet.js';
  52. // import { mapState } from 'vuex';
  53. import { getMoneyStyle } from '@/utils/rocessor.js';
  54. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  55. import empty from '@/components/empty';
  56. // #ifdef H5
  57. import { weixindata } from '@/utils/wxAuthorized';
  58. // #endif
  59. export default {
  60. filters: {
  61. getMoneyStyle
  62. },
  63. components: {
  64. empty,
  65. uniLoadMore
  66. },
  67. // computed: {
  68. // ...mapState(['weichatObj'])
  69. // },
  70. onReady() {
  71. let obj = this;
  72. // 初始化获取页面高度
  73. uni.createSelectorQuery()
  74. .select('.content')
  75. .fields(
  76. {
  77. size: true
  78. },
  79. data => {
  80. // 初始化获取头部高度
  81. uni.createSelectorQuery()
  82. .select('.content-money')
  83. .fields(
  84. {
  85. size: true
  86. },
  87. es => {
  88. // 保存头部高度
  89. obj.maxheight = data.height - es.height - 40;
  90. }
  91. )
  92. .exec();
  93. }
  94. )
  95. .exec();
  96. },
  97. data() {
  98. return {
  99. // 头部图高度
  100. maxheight: '',
  101. tabCurrentIndex: 0,
  102. navList: [
  103. {
  104. state: 1,
  105. text: '支出',
  106. loadingType: 'more',
  107. orderList: [],
  108. page: 1, //当前页数
  109. limit: 10 //每次信息条数
  110. },
  111. {
  112. state: 2,
  113. text: '收入',
  114. loadingType: 'more',
  115. orderList: [],
  116. page: 1, //当前页数
  117. limit: 10 //每次信息条数
  118. }
  119. ],
  120. money: ''
  121. };
  122. },
  123. onLoad(options) {
  124. let bool = uni.getStorageSync('weichatBrowser');
  125. if (bool) {
  126. // 加载微信信息
  127. weixindata();
  128. }
  129. },
  130. onShow() {
  131. this.loadData();
  132. // 获取用户余额
  133. userBalance({}).then(({ data }) => {
  134. this.money = data.now_money;
  135. });
  136. },
  137. methods: {
  138. // ToChangeInto() {
  139. // // #ifdef H5
  140. // this.weichatObj.scanQRCode({
  141. // needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  142. // scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
  143. // success: function(res) {
  144. // let result = JSON.parse(res.resultStr);
  145. // rechargemoneys({
  146. // id: result.id,
  147. // money: result.money
  148. // })
  149. // .then(({ data }) => {
  150. // uni.showModal({
  151. // title: '标题',
  152. // content: '成功',
  153. // showCancel: false
  154. // });
  155. // })
  156. // .catch(e => {
  157. // console.log(e);
  158. // });
  159. // }
  160. // });
  161. // // #endif
  162. // },
  163. // 页面跳转
  164. navto(e) {
  165. uni.navigateTo({
  166. url: e
  167. });
  168. },
  169. //获取收入支出信息
  170. async loadData(source) {
  171. //这里是将订单挂载到tab列表下
  172. let index = this.tabCurrentIndex;
  173. let navItem = this.navList[index];
  174. let state = navItem.state;
  175. if (source === 'tabChange' && navItem.loaded === true) {
  176. //tab切换只有第一次需要加载数据
  177. return;
  178. }
  179. if (navItem.loadingType === 'loading') {
  180. //防止重复加载
  181. return;
  182. }
  183. // 修改当前对象状态为加载中
  184. navItem.loadingType = 'loading';
  185. spreadCommission(
  186. {
  187. page: navItem.page,
  188. limit: navItem.limit
  189. },
  190. state
  191. )
  192. .then(({ data }) => {
  193. if (data.length > 0) {
  194. navItem.orderList = navItem.orderList.concat(data);
  195. console.log(navItem.orderList);
  196. navItem.page++;
  197. }
  198. if (navItem.limit == data.length) {
  199. //判断是否还有数据, 有改为 more, 没有改为noMore
  200. navItem.loadingType = 'more';
  201. return;
  202. } else {
  203. //判断是否还有数据, 有改为 more, 没有改为noMore
  204. navItem.loadingType = 'noMore';
  205. }
  206. uni.hideLoading();
  207. this.$set(navItem, 'loaded', true);
  208. })
  209. .catch(e => {
  210. console.log(e);
  211. });
  212. },
  213. //返回上一页面
  214. toBack() {
  215. console.log(111);
  216. uni.navigateBack({});
  217. },
  218. //swiper 切换
  219. changeTab(e) {
  220. this.tabCurrentIndex = e.target.current;
  221. this.loadData('tabChange');
  222. },
  223. //顶部tab点击
  224. tabClick(index) {
  225. this.tabCurrentIndex = index;
  226. }
  227. }
  228. };
  229. </script>
  230. <style lang="scss">
  231. page {
  232. background: #ffffff;
  233. height: 100%;
  234. padding: 0;
  235. }
  236. .content-money {
  237. padding-bottom: 30rpx;
  238. background: $page-color-base;
  239. }
  240. .money-box {
  241. background-color: $base-color;
  242. padding-top: var(--status-bar-height);
  243. height: 468rpx;
  244. color: #ffffff;
  245. text-align: center;
  246. justify-content: center;
  247. position: relative;
  248. .body-title {
  249. height: 80rpx;
  250. text-align: center;
  251. font-size: 35rpx;
  252. position: relative;
  253. .header {
  254. position: absolute;
  255. left: 0;
  256. top: 0;
  257. width: 100%;
  258. font-size: 36rpx;
  259. font-family: PingFang SC;
  260. font-weight: bold;
  261. color: #fffeff;
  262. height: 80rpx;
  263. font-size: 32rpx;
  264. font-weight: 700;
  265. z-index: 9;
  266. display: flex;
  267. justify-content: center;
  268. align-items: center;
  269. }
  270. .goback-box {
  271. position: absolute;
  272. z-index: 10;
  273. left: 24rpx;
  274. top: 0;
  275. height: 80rpx;
  276. display: flex;
  277. align-items: center;
  278. }
  279. .goback {
  280. width: 30rpx;
  281. height: 36rpx;
  282. }
  283. }
  284. .bg {
  285. position: absolute;
  286. top: 0;
  287. left: 0;
  288. width: 100%;
  289. height: 100%;
  290. image {
  291. width: 100%;
  292. height: 100%;
  293. }
  294. }
  295. .money {
  296. position: relative;
  297. z-index: 10;
  298. font-size: 56rpx;
  299. height: 388rpx;
  300. line-height: 288rpx;
  301. }
  302. }
  303. .navbar {
  304. display: flex;
  305. height: 40px;
  306. padding: 0 5px;
  307. background: #fff;
  308. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  309. position: relative;
  310. z-index: 10;
  311. .nav-item {
  312. flex: 1;
  313. display: flex;
  314. justify-content: center;
  315. align-items: center;
  316. height: 100%;
  317. font-size: 15px;
  318. color: $font-color-dark;
  319. position: relative;
  320. &.current {
  321. color: $base-color;
  322. &:after {
  323. content: '';
  324. position: absolute;
  325. left: 50%;
  326. bottom: 0;
  327. transform: translateX(-50%);
  328. width: 44px;
  329. height: 0;
  330. border-bottom: 2px solid $base-color;
  331. }
  332. }
  333. }
  334. }
  335. // 列表
  336. .swiper-box {
  337. padding-top: 10rpx;
  338. .order-item {
  339. padding: 20rpx 30rpx;
  340. line-height: 1.5;
  341. .title-box {
  342. .title {
  343. font-size: $font-lg;
  344. color: $font-color-base;
  345. }
  346. .time {
  347. font-size: $font-base;
  348. color: $font-color-light;
  349. }
  350. }
  351. .money {
  352. color: #fd5b23;
  353. font-size: $font-lg;
  354. }
  355. }
  356. }
  357. .list-scroll-content {
  358. height: 100%;
  359. }
  360. .content {
  361. height: 100%;
  362. .empty-content {
  363. background-color: #ffffff;
  364. }
  365. }
  366. .btn {
  367. position: fixed;
  368. bottom: 40rpx;
  369. left: 50%;
  370. width: 674rpx;
  371. height: 88rpx;
  372. background: #52c696;
  373. border-radius: 44rpx;
  374. margin-left: -337rpx;
  375. font-size: 36rpx;
  376. font-family: PingFang SC;
  377. font-weight: bold;
  378. text-align: center;
  379. line-height: 88rpx;
  380. color: #ffffff;
  381. }
  382. .moneyTx {
  383. position: absolute;
  384. z-index: 10;
  385. top: 150rpx;
  386. right: 0rpx;
  387. width: 130rpx;
  388. padding: 10rpx 30rpx;
  389. border: 2px solid #ffffff;
  390. border-top-left-radius: 99rpx;
  391. border-bottom-left-radius: 99rpx;
  392. color: #ffffff;
  393. line-height: 1;
  394. font-size: $font-base;
  395. }
  396. </style>