greenJf.vue 10 KB

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