whiteJf.vue 10 KB

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