shopJf.vue 9.1 KB

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