award.vue 9.1 KB

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