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: 0,
  132. text: '支出',
  133. loadingType: 'more',
  134. orderList: [],
  135. page: 1, //当前页数
  136. limit: 10 //每次信息条数
  137. },
  138. {
  139. state: 1,
  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. pm:state
  193. })
  194. .then(({
  195. data
  196. }) => {
  197. // console.log(data,'垃圾数据');
  198. if (data.length > 0) {
  199. // console.log(data, '数据111');
  200. navItem.orderList = navItem.orderList.concat(data);
  201. console.log(navItem.orderList,'合并数据');
  202. navItem.page++;
  203. }
  204. if (navItem.limit == data.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. // .catch(e => {
  215. // console.log(e);
  216. // });
  217. })
  218. // obj.recharge = data.income;
  219. // obj.orderStatusSum = data.expend;
  220. },
  221. //swiper 切换
  222. changeTab(e) {
  223. this.tabCurrentIndex = e.target.current;
  224. this.loadData('tabChange');
  225. },
  226. //顶部tab点击
  227. tabClick(index) {
  228. this.tabCurrentIndex = index;
  229. },
  230. toBack(e) {
  231. uni.switchTab({
  232. url: e
  233. })
  234. }
  235. }
  236. };
  237. </script>
  238. <style lang="scss">
  239. page {
  240. background: #f1f1f1;
  241. height: 100%;
  242. }
  243. .status_bar {
  244. height: var(--status-bar-height);
  245. width: 100%;
  246. }
  247. .content-money {
  248. position: relative;
  249. height: 480rpx;
  250. .content-bg {
  251. position: absolute;
  252. top: 0;
  253. left: 0;
  254. right: 0;
  255. width: 750rpx;
  256. height: 480rpx;
  257. image {
  258. width: 100%;
  259. height: 100%;
  260. }
  261. }
  262. .body-title {
  263. height: 80rpx;
  264. text-align: center;
  265. font-size: 35rpx;
  266. position: relative;
  267. .header {
  268. position: absolute;
  269. left: 0;
  270. top: 0;
  271. width: 100%;
  272. font-size: 36rpx;
  273. font-family: PingFang SC;
  274. font-weight: bold;
  275. color: #fffeff;
  276. height: 80rpx;
  277. font-size: 36rpx;
  278. font-weight: 700;
  279. z-index: 9;
  280. display: flex;
  281. justify-content: center;
  282. align-items: center;
  283. }
  284. .goback-box {
  285. position: absolute;
  286. left: 18rpx;
  287. top: 0;
  288. height: 80rpx;
  289. display: flex;
  290. align-items: center;
  291. }
  292. .goback {
  293. z-index: 100;
  294. width: 20rpx;
  295. height: 37rpx;
  296. }
  297. }
  298. }
  299. .info-box {
  300. width: 670rpx;
  301. height: 186rpx;
  302. background: #ffffff;
  303. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  304. border-radius: 20rpx;
  305. margin: -100rpx auto 0;
  306. position: relative;
  307. z-index: 2;
  308. .info-item {
  309. width: 50%;
  310. display: flex;
  311. flex-direction: column;
  312. align-items: center;
  313. line-height: 1;
  314. .info-font {
  315. font-size: 30rpx;
  316. font-family: PingFang SC;
  317. font-weight: bold;
  318. color: #999999;
  319. }
  320. .info-num {
  321. margin-top: 30rpx;
  322. font-size: 30rpx;
  323. font-family: PingFang SC;
  324. font-weight: bold;
  325. color: #181818;
  326. }
  327. }
  328. .shu {
  329. width: 2rpx;
  330. height: 74rpx;
  331. background: #dcdfe6;
  332. }
  333. }
  334. .money-box {
  335. position: relative;
  336. z-index: 2;
  337. padding-top: 90rpx;
  338. color: #ffffff;
  339. text-align: center;
  340. .money {
  341. font-size: 72rpx;
  342. font-family: PingFang SC;
  343. font-weight: bold;
  344. color: #ffffff;
  345. }
  346. .text {
  347. font-size: 30rpx;
  348. }
  349. }
  350. .money-btn {
  351. position: relative;
  352. z-index: 2;
  353. color: #ffffff;
  354. padding-right: 50rpx;
  355. text-align: right;
  356. font-size: 30rpx;
  357. font-family: PingFang SC;
  358. font-weight: bold;
  359. color: #FFFFFF;
  360. text {
  361. display: inline-block;
  362. padding-left: 10rpx;
  363. }
  364. }
  365. .navbar {
  366. margin-top: 20rpx;
  367. display: flex;
  368. height: 88rpx;
  369. padding: 0 5px;
  370. background: #fff;
  371. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  372. position: relative;
  373. z-index: 10;
  374. .nav-item {
  375. flex: 1;
  376. display: flex;
  377. justify-content: center;
  378. align-items: center;
  379. height: 100%;
  380. font-size: 15px;
  381. color: #999999;
  382. position: relative;
  383. &.current {
  384. color: #000;
  385. &:after {
  386. content: '';
  387. position: absolute;
  388. left: 50%;
  389. bottom: 0;
  390. transform: translateX(-50%);
  391. width: 44px;
  392. height: 0;
  393. border-bottom: 2px solid #fe5b38;
  394. }
  395. }
  396. }
  397. }
  398. //列表
  399. .swiper-box {
  400. .order-item:last-child {
  401. margin-bottom: 60rpx;
  402. }
  403. .order-item {
  404. padding: 20rpx 30rpx;
  405. line-height: 1.5;
  406. .title-box {
  407. .title {
  408. font-size: $font-lg;
  409. color: $font-color-base;
  410. }
  411. .time {
  412. font-size: $font-base;
  413. color: $font-color-light;
  414. }
  415. }
  416. .money {
  417. color: #fd5b23;
  418. font-size: $font-lg;
  419. text-align: right;
  420. .status {
  421. color: $font-color-light;
  422. }
  423. }
  424. }
  425. }
  426. .list-scroll-content {
  427. background: #ffffff;
  428. height: 100%;
  429. }
  430. .content {
  431. height: 100%;
  432. .empty-content {
  433. background-color: #ffffff;
  434. }
  435. }
  436. .btn-box {
  437. width: 674rpx;
  438. height: 88rpx;
  439. background: linear-gradient(0deg, #2e58ff, #32c6ff);
  440. border-radius: 44rpx;
  441. font-size: 36rpx;
  442. font-family: PingFang SC;
  443. font-weight: 500;
  444. color: #ffffff;
  445. text-align: center;
  446. line-height: 88rpx;
  447. position: fixed;
  448. bottom: 48rpx;
  449. left: 0;
  450. right: 0;
  451. margin: 0 auto;
  452. }
  453. </style>