award.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="money-box">
  5. <view class="goback-box" @click="toBack"><image class="goback" src="../../static/img/fanhui.png" mode=""></image></view>
  6. <view class="header">我的余额</view>
  7. <image class="money_bg" src="../../static/img/orderbg.png"></image>
  8. <view class="money">{{ money | getMoneyStyle }}</view>
  9. </view>
  10. </view>
  11. <view class="navbar">
  12. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  13. </view>
  14. <swiper :current="tabCurrentIndex" :style="{ height: maxheight + 'px' }" class="swiper-box" duration="300" @change="changeTab">
  15. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  16. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  17. <!-- 空白页 -->
  18. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  19. <!-- 订单列表 -->
  20. <template v-for="(ls, index) in tabItem.orderList">
  21. <view v-for="(item, i) in ls.list" class="order-item flex">
  22. <view class="title-box">
  23. <view class="title">
  24. <text>{{ item.title }}</text>
  25. </view>
  26. <view class="time">
  27. <text>{{ item.add_time }}</text>
  28. </view>
  29. </view>
  30. <view class="money">
  31. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  32. </view>
  33. </view>
  34. </template>
  35. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  36. </scroll-view>
  37. </swiper-item>
  38. </swiper>
  39. <view class="wallet-btn" @click="navto('/pages/money/recharge')">立即充值</view>
  40. </view>
  41. </template>
  42. <script>
  43. import { spreadCommission, userBalance } from '@/api/wallet.js';
  44. import { mapState, mapMutations } from 'vuex';
  45. import { getMoneyStyle } from '@/utils/rocessor.js';
  46. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  47. import empty from '@/components/empty';
  48. export default {
  49. filters: {
  50. getMoneyStyle
  51. },
  52. components: {
  53. empty,
  54. uniLoadMore
  55. },
  56. onReady() {
  57. // 初始化获取页面宽度
  58. uni.createSelectorQuery()
  59. .select('.content')
  60. .fields(
  61. {
  62. size: true
  63. },
  64. data => {
  65. // 保存头部高度
  66. this.maxheight = data.height - Math.floor((data.width / 750) * 330) - 40 - 40;
  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. page: 1, //当前页数
  91. limit: 10 //每次信息条数
  92. }
  93. ],
  94. money: ''
  95. };
  96. },
  97. onLoad(options) {
  98. this.loadData();
  99. },
  100. onShow() {
  101. // 获取用户余额
  102. userBalance({}).then(({ data }) => {
  103. this.money = data.now_money;
  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 === 'noMore') {
  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. navItem.orderList = navItem.orderList.concat(data);
  138. navItem.page++;
  139. if (navItem.limit == data.length) {
  140. //判断是否还有数据, 有改为 more, 没有改为noMore
  141. navItem.loadingType = 'more';
  142. return;
  143. } else {
  144. //判断是否还有数据, 有改为 more, 没有改为noMore
  145. navItem.loadingType = 'noMore';
  146. }
  147. uni.hideLoading();
  148. this.$set(navItem, 'loaded', true);
  149. })
  150. .catch(e => {
  151. console.log(e);
  152. });
  153. },
  154. //swiper 切换
  155. changeTab(e) {
  156. this.tabCurrentIndex = e.target.current;
  157. this.loadData('tabChange');
  158. },
  159. //顶部tab点击
  160. tabClick(index) {
  161. this.tabCurrentIndex = index;
  162. },
  163. // 点击返回 我的页面
  164. toBack() {
  165. uni.switchTab({
  166. url: '/pages/user/user'
  167. });
  168. }
  169. }
  170. };
  171. </script>
  172. <style lang="scss">
  173. page {
  174. background: #ffffff;
  175. height: 100%;
  176. }
  177. // .header{
  178. // width: 100%;
  179. // height: 54px;
  180. // background-color: #FF0000;
  181. // }
  182. .content-money {
  183. padding-bottom: 30rpx;
  184. background: $page-color-base;
  185. // border: 2px solid #ffffff;
  186. // padding-top: var(--status-bar-height);
  187. .moneyTx {
  188. position: absolute;
  189. top: 120rpx;
  190. right: 0rpx;
  191. // width: 150rpx;
  192. padding: 10rpx 10rpx;
  193. border: 2px solid #ffffff;
  194. border-top-left-radius: 15rpx;
  195. border-bottom-left-radius: 15rpx;
  196. line-height: 1;
  197. font-size: $font-base;
  198. background: #ffffff;
  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: 36rpx;
  218. width: 36rpx;
  219. margin: 0 auto;
  220. .icon-img {
  221. width: 100%;
  222. height: 100%;
  223. }
  224. }
  225. }
  226. }
  227. .money-box {
  228. color: #ffffff;
  229. text-align: center;
  230. position: relative;
  231. background-color: pink;
  232. .header {
  233. position: absolute;
  234. left: 0;
  235. top: 0;
  236. width: 100%;
  237. height: 80rpx;
  238. font-size: 32rpx;
  239. font-weight: 700;
  240. z-index: 99;
  241. display: flex;
  242. justify-content: center;
  243. align-items: center;
  244. }
  245. .goback-box {
  246. position: absolute;
  247. left: 18rpx;
  248. top: 0;
  249. height: 80rpx;
  250. display: flex;
  251. align-items: center;
  252. }
  253. .goback {
  254. z-index: 100;
  255. width: 34rpx;
  256. height: 34rpx;
  257. }
  258. .money_bg {
  259. width: 100%;
  260. height: 360rpx;
  261. display: block;
  262. }
  263. .text {
  264. padding-top: 80rpx;
  265. font-size: $font-lg;
  266. }
  267. .money {
  268. position: absolute;
  269. top: 0;
  270. width: 100%;
  271. padding-top: 186rpx;
  272. font-size: 60rpx;
  273. font-weight: bold;
  274. &::before {
  275. content: '¥';
  276. font-size: 30rpx;
  277. }
  278. }
  279. }
  280. .navbar {
  281. display: flex;
  282. height: 40px;
  283. padding: 0 5px;
  284. background: #fff;
  285. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  286. position: relative;
  287. z-index: 10;
  288. .nav-item {
  289. flex: 1;
  290. display: flex;
  291. justify-content: center;
  292. align-items: center;
  293. height: 100%;
  294. font-size: 15px;
  295. color: #999999;
  296. position: relative;
  297. &.current {
  298. color: #000000;
  299. &:after {
  300. content: '';
  301. position: absolute;
  302. left: 50%;
  303. bottom: 0;
  304. transform: translateX(-50%);
  305. width: 44px;
  306. height: 0;
  307. border-bottom: 2px solid #52C696;
  308. }
  309. }
  310. }
  311. }
  312. // 列表
  313. .swiper-box {
  314. padding-top: 10rpx;
  315. .order-item {
  316. padding: 20rpx 30rpx;
  317. line-height: 1.5;
  318. .title-box {
  319. .title {
  320. font-size: $font-lg;
  321. color: $font-color-base;
  322. }
  323. .time {
  324. font-size: $font-base;
  325. color: $font-color-light;
  326. }
  327. }
  328. .money {
  329. color: #ff0000;
  330. font-size: $font-lg;
  331. }
  332. }
  333. }
  334. .list-scroll-content {
  335. height: 100%;
  336. }
  337. .wallet-btn {
  338. width: 674rpx;
  339. height: 88rpx;
  340. background: #52C696;
  341. border-radius: 44rpx;
  342. font-size: $font-lg;
  343. font-family: PingFang SC;
  344. font-weight: 500;
  345. color: #ffffff;
  346. display: flex;
  347. align-items: center;
  348. justify-content: center;
  349. position: fixed;
  350. left: 38rpx;
  351. bottom: 50rpx;
  352. }
  353. .content {
  354. height: 100%;
  355. .empty-content {
  356. background-color: #ffffff;
  357. }
  358. }
  359. </style>