greenJf.vue 8.8 KB

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