award.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  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/anchor11.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. // margin-top: var(--status-bar-height);
  234. // background-color: pink;
  235. width: 100%;
  236. height: 68rpx;
  237. display: flex;
  238. align-items: center;
  239. justify-content: center;
  240. font-size: 26rpx;
  241. // font-family: PingFang SC;
  242. font-weight: 400;
  243. color: #ffffff;
  244. position: relative;
  245. left: 0;
  246. top: 0;
  247. // .toback {
  248. // // background-color: red;
  249. // display: flex;
  250. // align-items: center;
  251. // width: 44rpx;
  252. // height: 68rpx;
  253. // margin-left: 16rpx;
  254. // position: absolute;
  255. // left: 0rpx;
  256. // top: 0rpx;
  257. // image {
  258. // width: 34rpx;
  259. // height: 38rpx;
  260. // }
  261. // }
  262. }
  263. .header {
  264. margin-top: var(--status-bar-height);
  265. position: absolute;
  266. left: 0;
  267. top: 0;
  268. width: 100%;
  269. height: 80rpx;
  270. font-size: 32rpx;
  271. font-weight: 700;
  272. z-index: 99;
  273. display: flex;
  274. justify-content: center;
  275. align-items: center;
  276. }
  277. .goback-box {
  278. margin-top: var(--status-bar-height);
  279. position: absolute;
  280. left: 18rpx;
  281. top: 0;
  282. height: 80rpx;
  283. display: flex;
  284. align-items: center;
  285. }
  286. .goback {
  287. z-index: 100;
  288. width: 34rpx;
  289. height: 34rpx;
  290. }
  291. .money_bg {
  292. width: 100%;
  293. height: 360rpx;
  294. display: block;
  295. }
  296. .text {
  297. padding-top: 80rpx;
  298. font-size: $font-lg;
  299. }
  300. .money {
  301. position: absolute;
  302. top: 0;
  303. width: 100%;
  304. padding-top: 186rpx;
  305. font-size: 60rpx;
  306. font-weight: bold;
  307. &::before {
  308. content: '¥';
  309. font-size: 30rpx;
  310. }
  311. }
  312. }
  313. .navbar {
  314. display: flex;
  315. height: 40px;
  316. padding: 0 5px;
  317. background: #fff;
  318. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  319. position: relative;
  320. z-index: 10;
  321. .nav-item {
  322. flex: 1;
  323. display: flex;
  324. justify-content: center;
  325. align-items: center;
  326. height: 100%;
  327. font-size: 15px;
  328. color: #999999;
  329. position: relative;
  330. &.current {
  331. color: #000000;
  332. &:after {
  333. content: '';
  334. position: absolute;
  335. left: 50%;
  336. bottom: 0;
  337. transform: translateX(-50%);
  338. width: 44px;
  339. height: 0;
  340. border-bottom: 2px solid #27d4dd;
  341. }
  342. }
  343. }
  344. }
  345. // 列表
  346. .swiper-box {
  347. padding-top: 10rpx;
  348. .order-item {
  349. padding: 20rpx 30rpx;
  350. line-height: 1.5;
  351. .title-box {
  352. .title {
  353. font-size: $font-lg;
  354. color: $font-color-base;
  355. }
  356. .time {
  357. font-size: $font-base;
  358. color: $font-color-light;
  359. }
  360. }
  361. .money {
  362. color: #ff0000;
  363. font-size: $font-lg;
  364. }
  365. }
  366. }
  367. .list-scroll-content {
  368. height: 100%;
  369. }
  370. .wallet-btn {
  371. width: 674rpx;
  372. height: 88rpx;
  373. background: linear-gradient(90deg, #08c4e6, #50ead2);
  374. border-radius: 44rpx;
  375. font-size: $font-lg;
  376. font-family: PingFang SC;
  377. font-weight: 500;
  378. color: #ffffff;
  379. display: flex;
  380. align-items: center;
  381. justify-content: center;
  382. position: fixed;
  383. left: 38rpx;
  384. bottom: 50rpx;
  385. }
  386. .content {
  387. height: 100%;
  388. .empty-content {
  389. background-color: #ffffff;
  390. }
  391. }
  392. </style>