integral.vue 10.0 KB

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