award.vue 8.5 KB

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