purpleJf.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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.purple_integral | getMoneyStyle}}</view>
  18. <view>当前余额</view>
  19. </view>
  20. <view class="moneybtn-box">
  21. <view class="money-btn">
  22. <!-- 易货券转账 -->
  23. </view>
  24. <view class="money-btn" @click="navto('/pages/money/withdrawal?type=purple')">
  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. getPurpleJf,
  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. console.log(this.userInfo.purple_integral);
  146. this.loadData();
  147. // 获取用户余额
  148. getUserInfo({}).then(({
  149. data
  150. }) => {
  151. this.money = data.now_money;
  152. this.setUserInfo(data);
  153. });
  154. },
  155. computed: {
  156. ...mapState('user', ['userInfo'])
  157. },
  158. methods: {
  159. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  160. toBack() {
  161. uni.switchTab({
  162. url: '/pages/user/user',
  163. fail() {
  164. uni.switchTab({
  165. url: '/pages/index/index'
  166. })
  167. }
  168. })
  169. },
  170. // 页面跳转
  171. navto(e) {
  172. uni.navigateTo({
  173. url: e
  174. });
  175. },
  176. //获取收入支出信息
  177. async loadData(source) {
  178. let obj = this
  179. //这里是将订单挂载到tab列表下
  180. let index = this.tabCurrentIndex;
  181. let navItem = this.navList[index];
  182. let state = navItem.state;
  183. if (source === 'tabChange' && navItem.loaded === true) {
  184. //tab切换只有第一次需要加载数据
  185. return;
  186. }
  187. if (navItem.loadingType === 'loading') {
  188. //防止重复加载
  189. return;
  190. }
  191. // 修改当前对象状态为加载中
  192. navItem.loadingType = 'loading';
  193. getPurpleJf({
  194. page: navItem.page,
  195. limit: navItem.limit,
  196. pm: navItem.state
  197. })
  198. .then(({
  199. data
  200. }) => {
  201. console.log(data,'2222');
  202. obj.zc = data.zc
  203. obj.sr = data.sr
  204. navItem.orderList = navItem.orderList.concat(data.list)
  205. navItem.page++
  206. if (navItem.limit == data.list.length) {
  207. navItem.loadingType = 'more'
  208. } else {
  209. navItem.loadingType = 'noMore'
  210. }
  211. obj.$set(navItem, 'loaded', true);
  212. })
  213. .catch(e => {
  214. console.log(e);
  215. });
  216. },
  217. //swiper 切换
  218. changeTab(e) {
  219. this.tabCurrentIndex = e.target.current;
  220. this.loadData('tabChange');
  221. },
  222. //顶部tab点击
  223. tabClick(index) {
  224. this.tabCurrentIndex = index;
  225. }
  226. }
  227. };
  228. </script>
  229. <style lang="scss">
  230. page {
  231. background: #f1f1f1;
  232. height: 100%;
  233. }
  234. .status_bar {
  235. height: var(--status-bar-height);
  236. width: 100%;
  237. }
  238. .content-money {
  239. position: relative;
  240. height: 480rpx;
  241. .content-bg {
  242. position: absolute;
  243. top: 0;
  244. left: 0;
  245. right: 0;
  246. width: 750rpx;
  247. height: 480rpx;
  248. image {
  249. width: 100%;
  250. height: 100%;
  251. }
  252. }
  253. .body-title {
  254. height: 80rpx;
  255. text-align: center;
  256. font-size: 35rpx;
  257. position: relative;
  258. .header {
  259. position: absolute;
  260. left: 0;
  261. top: 0;
  262. width: 100%;
  263. font-size: 36rpx;
  264. font-family: PingFang SC;
  265. font-weight: bold;
  266. color: #fffeff;
  267. height: 80rpx;
  268. font-size: 36rpx;
  269. font-weight: 700;
  270. z-index: 9;
  271. display: flex;
  272. justify-content: center;
  273. align-items: center;
  274. }
  275. .goback-box {
  276. position: absolute;
  277. left: 18rpx;
  278. top: 0;
  279. height: 80rpx;
  280. display: flex;
  281. align-items: center;
  282. }
  283. .goback {
  284. z-index: 100;
  285. width: 34rpx;
  286. height: 34rpx;
  287. }
  288. }
  289. }
  290. .info-box {
  291. width: 670rpx;
  292. height: 186rpx;
  293. background: #ffffff;
  294. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  295. border-radius: 20rpx;
  296. margin: -100rpx auto 0;
  297. position: relative;
  298. z-index: 2;
  299. .info-item {
  300. width: 50%;
  301. display: flex;
  302. flex-direction: column;
  303. align-items: center;
  304. line-height: 1;
  305. .info-font {
  306. font-size: 30rpx;
  307. font-family: PingFang SC;
  308. font-weight: bold;
  309. color: #999999;
  310. }
  311. .info-num {
  312. margin-top: 30rpx;
  313. font-size: 30rpx;
  314. font-family: PingFang SC;
  315. font-weight: bold;
  316. color: #181818;
  317. }
  318. }
  319. .shu {
  320. width: 2rpx;
  321. height: 74rpx;
  322. background: #dcdfe6;
  323. }
  324. }
  325. .money-box {
  326. position: relative;
  327. z-index: 2;
  328. padding-top: 70rpx;
  329. /* #ifdef APP-PLUS */
  330. padding-top: 30rpx;
  331. /* #endif */
  332. color: #ffffff;
  333. text-align: center;
  334. .money {
  335. font-size: 72rpx;
  336. font-family: PingFang SC;
  337. font-weight: bold;
  338. color: #ffffff;
  339. }
  340. .text {
  341. font-size: 30rpx;
  342. }
  343. }
  344. .moneybtn-box {
  345. display: flex;
  346. justify-content: space-between;
  347. position: relative;
  348. z-index: 2;
  349. color: #ffffff;
  350. padding: 20rpx 50rpx;
  351. font-size: 30rpx;
  352. font-family: PingFang SC;
  353. font-weight: bold;
  354. color: #FFFFFF;
  355. }
  356. .navbar {
  357. margin-top: 20rpx;
  358. display: flex;
  359. height: 88rpx;
  360. padding: 0 5px;
  361. background: #fff;
  362. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  363. position: relative;
  364. z-index: 10;
  365. .nav-item {
  366. flex: 1;
  367. display: flex;
  368. justify-content: center;
  369. align-items: center;
  370. height: 100%;
  371. font-size: 15px;
  372. color: #999999;
  373. position: relative;
  374. &.current {
  375. color: #000;
  376. &:after {
  377. content: '';
  378. position: absolute;
  379. left: 50%;
  380. bottom: 0;
  381. transform: translateX(-50%);
  382. width: 44px;
  383. height: 0;
  384. border-bottom: 2px solid #fe5b38;
  385. }
  386. }
  387. }
  388. }
  389. //列表
  390. .swiper-box {
  391. .order-item:last-child {
  392. margin-bottom: 60rpx;
  393. }
  394. .order-item {
  395. padding: 20rpx 30rpx;
  396. line-height: 1.5;
  397. .title-box {
  398. width: 580rpx;
  399. // text-overflow: ellipsis;
  400. // overflow: hidden;
  401. // white-space: nowrap;
  402. .title {
  403. width: 580rpx;
  404. display: flex;
  405. flex-wrap: wrap;
  406. // text-overflow: ellipsis;
  407. // overflow: hidden;
  408. // white-space: nowrap;
  409. font-size: $font-lg;
  410. color: $font-color-base;
  411. }
  412. .time {
  413. font-size: $font-base;
  414. color: $font-color-light;
  415. }
  416. }
  417. .money {
  418. color: #fd5b23;
  419. font-size: $font-lg;
  420. text-align: right;
  421. .status {
  422. color: $font-color-light;
  423. }
  424. }
  425. }
  426. }
  427. .list-scroll-content {
  428. background: #ffffff;
  429. height: 100%;
  430. }
  431. .content {
  432. height: 100%;
  433. .empty-content {
  434. background-color: #ffffff;
  435. }
  436. }
  437. .btn-box {
  438. width: 674rpx;
  439. height: 88rpx;
  440. background: linear-gradient(0deg, #2e58ff, #32c6ff);
  441. border-radius: 44rpx;
  442. font-size: 36rpx;
  443. font-family: PingFang SC;
  444. font-weight: 500;
  445. color: #ffffff;
  446. text-align: center;
  447. line-height: 88rpx;
  448. position: fixed;
  449. bottom: 48rpx;
  450. left: 0;
  451. right: 0;
  452. margin: 0 auto;
  453. }
  454. </style>