mallJf.vue 9.0 KB

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