shopJf.vue 9.5 KB

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