award.vue 8.6 KB

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