jf.vue 9.4 KB

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