shopJf.vue 9.5 KB

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