award.vue 7.7 KB

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