shopJf.vue 11 KB

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