award.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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/img/anchor11.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. .content-money {
  181. padding-bottom: 30rpx;
  182. background: $page-color-base;
  183. // border: 2px solid #ffffff;
  184. // padding-top: var(--status-bar-height);
  185. .moneyTx {
  186. position: absolute;
  187. top: 120rpx;
  188. right: 0rpx;
  189. // width: 150rpx;
  190. padding: 10rpx 10rpx;
  191. border: 2px solid #ffffff;
  192. border-top-left-radius: 15rpx;
  193. border-bottom-left-radius: 15rpx;
  194. line-height: 1;
  195. font-size: $font-base;
  196. background: #ffffff;
  197. }
  198. .buttom-box {
  199. background-color: #ffffff;
  200. text-align: center;
  201. margin: 0 30rpx;
  202. padding: 20rpx 0;
  203. border-radius: $border-radius-sm;
  204. margin-top: -60rpx;
  205. .buttom {
  206. font-size: $font-lg;
  207. flex-grow: 1;
  208. }
  209. .interval {
  210. width: 2px;
  211. height: 60rpx;
  212. background-color: #eeeeee;
  213. }
  214. .icon {
  215. height: 36rpx;
  216. width: 36rpx;
  217. margin: 0 auto;
  218. .icon-img {
  219. width: 100%;
  220. height: 100%;
  221. }
  222. }
  223. }
  224. }
  225. .money-box {
  226. color: #ffffff;
  227. text-align: center;
  228. position: relative;
  229. background-color: pink;
  230. .yue{
  231. position: absolute;
  232. right: 0;
  233. z-index: 9999;
  234. text-align: center;
  235. line-height: 50rpx;
  236. top: 100rpx;
  237. width: 142rpx;
  238. height: 50rpx;
  239. background: #FFFFFF;
  240. border-radius: 7rpx;
  241. font-size: 26rpx;
  242. font-family: PingFang SC;
  243. font-weight: bold;
  244. color: #FF4C4C;
  245. }
  246. .header {
  247. position: absolute;
  248. left: 0;
  249. top: 0;
  250. width: 100%;
  251. height: 80rpx;
  252. font-size: 32rpx;
  253. font-weight: 700;
  254. z-index: 99;
  255. display: flex;
  256. justify-content: center;
  257. align-items: center;
  258. }
  259. .goback-box {
  260. position: absolute;
  261. left: 18rpx;
  262. top: 0;
  263. height: 80rpx;
  264. display: flex;
  265. align-items: center;
  266. }
  267. .goback {
  268. z-index: 100;
  269. width: 34rpx;
  270. height: 34rpx;
  271. }
  272. .money_bg {
  273. width: 100%;
  274. height: 400rpx;
  275. display: block;
  276. }
  277. .text {
  278. padding-top: 80rpx;
  279. font-size: $font-lg;
  280. }
  281. .money {
  282. position: absolute;
  283. top: 0;
  284. width: 100%;
  285. padding-top: 186rpx;
  286. font-size: 82rpx;
  287. font-weight: bold;
  288. &::before {
  289. content: '¥';
  290. font-size: 46rpx;
  291. }
  292. }
  293. }
  294. .navbar {
  295. display: flex;
  296. height: 40px;
  297. padding: 0 5px;
  298. background: #fff;
  299. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  300. position: relative;
  301. z-index: 10;
  302. .nav-item {
  303. flex: 1;
  304. display: flex;
  305. justify-content: center;
  306. align-items: center;
  307. height: 100%;
  308. font-size: 15px;
  309. color: #999999;
  310. position: relative;
  311. &.current {
  312. color: #000000;
  313. &:after {
  314. content: '';
  315. position: absolute;
  316. left: 50%;
  317. bottom: 0;
  318. transform: translateX(-50%);
  319. width: 44px;
  320. height: 0;
  321. border-bottom: 2px solid #FF4C4C;
  322. }
  323. }
  324. }
  325. }
  326. // 列表
  327. .swiper-box {
  328. padding-top: 10rpx;
  329. .order-item {
  330. padding: 20rpx 30rpx;
  331. line-height: 1.5;
  332. .title-box {
  333. .title {
  334. font-size: $font-lg;
  335. color: $font-color-base;
  336. }
  337. .time {
  338. font-size: $font-base;
  339. color: $font-color-light;
  340. }
  341. }
  342. .money {
  343. color: #ff0000;
  344. font-size: $font-lg;
  345. }
  346. }
  347. }
  348. .list-scroll-content {
  349. height: 100%;
  350. }
  351. .wallet-btn {
  352. width: 674rpx;
  353. height: 88rpx;
  354. background: #FF4C4C;
  355. border-radius: 44rpx;
  356. font-size: $font-lg;
  357. font-family: PingFang SC;
  358. font-weight: 500;
  359. color: #ffffff;
  360. display: flex;
  361. align-items: center;
  362. justify-content: center;
  363. position: fixed;
  364. left: 38rpx;
  365. bottom: 50rpx;
  366. }
  367. .content {
  368. height: 100%;
  369. .empty-content {
  370. background-color: #ffffff;
  371. }
  372. }
  373. </style>