wallet.vue 8.8 KB

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