purpleJf.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  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"></view>
  16. <view class="money-btn" @click="navto('/pages/money/withdrawal?type=purple')">阳光提现 ></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">{{ sr || 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">{{ zc || 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 { getPurpleJf, getUserInfo, GetIntegral } 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. zc: 0,
  92. sr: 0,
  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. },
  108. {
  109. state: 1,
  110. text: '收入',
  111. loadingType: 'more',
  112. orderList: [],
  113. page: 1, //当前页数
  114. limit: 10 //每次信息条数
  115. }
  116. ],
  117. money: ''
  118. };
  119. },
  120. onLoad(options) {},
  121. onShow() {
  122. this.loadData();
  123. // 获取用户余额
  124. getUserInfo({}).then(({ data }) => {
  125. this.money = data.now_money;
  126. this.setUserInfo(data);
  127. });
  128. },
  129. computed: {
  130. ...mapState('user', ['userInfo'])
  131. },
  132. methods: {
  133. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  134. toBack() {
  135. uni.navigateBack({});
  136. },
  137. // 页面跳转
  138. navto(e) {
  139. uni.navigateTo({
  140. url: e
  141. });
  142. },
  143. //获取收入支出信息
  144. async loadData(source) {
  145. let obj = this;
  146. //这里是将订单挂载到tab列表下
  147. let index = this.tabCurrentIndex;
  148. let navItem = this.navList[index];
  149. let state = navItem.state;
  150. if (source === 'tabChange' && navItem.loaded === true) {
  151. //tab切换只有第一次需要加载数据
  152. return;
  153. }
  154. if (navItem.loadingType === 'loading') {
  155. //防止重复加载
  156. return;
  157. }
  158. // 修改当前对象状态为加载中
  159. navItem.loadingType = 'loading';
  160. GetIntegral({
  161. page: navItem.page,
  162. limit: navItem.limit,
  163. pm: navItem.state
  164. })
  165. .then(({ data }) => {
  166. obj.zc = data.zc;
  167. obj.sr = data.sr;
  168. navItem.orderList = navItem.orderList.concat(data.list);
  169. navItem.page++;
  170. if (navItem.limit == data.list.length) {
  171. navItem.loadingType = 'more';
  172. } else {
  173. navItem.loadingType = 'noMore';
  174. }
  175. obj.$set(navItem, 'loaded', true);
  176. })
  177. .catch(e => {
  178. console.log(e);
  179. });
  180. },
  181. //swiper 切换
  182. changeTab(e) {
  183. this.tabCurrentIndex = e.target.current;
  184. this.loadData('tabChange');
  185. },
  186. //顶部tab点击
  187. tabClick(index) {
  188. this.tabCurrentIndex = index;
  189. }
  190. }
  191. };
  192. </script>
  193. <style lang="scss">
  194. page {
  195. background: #f1f1f1;
  196. height: 100%;
  197. }
  198. .status_bar {
  199. height: var(--status-bar-height);
  200. width: 100%;
  201. }
  202. .content-money {
  203. position: relative;
  204. height: 480rpx;
  205. .content-bg {
  206. position: absolute;
  207. top: 0;
  208. left: 0;
  209. right: 0;
  210. width: 750rpx;
  211. height: 480rpx;
  212. image {
  213. width: 100%;
  214. height: 100%;
  215. }
  216. }
  217. .body-title {
  218. height: 80rpx;
  219. text-align: center;
  220. font-size: 35rpx;
  221. position: relative;
  222. .header {
  223. position: absolute;
  224. left: 0;
  225. top: 0;
  226. width: 100%;
  227. font-size: 36rpx;
  228. font-family: PingFang SC;
  229. font-weight: bold;
  230. color: #fffeff;
  231. height: 80rpx;
  232. font-size: 36rpx;
  233. font-weight: 700;
  234. z-index: 9;
  235. display: flex;
  236. justify-content: center;
  237. align-items: center;
  238. }
  239. .goback-box {
  240. position: absolute;
  241. left: 18rpx;
  242. top: 0;
  243. height: 80rpx;
  244. display: flex;
  245. align-items: center;
  246. }
  247. .goback {
  248. z-index: 100;
  249. width: 34rpx;
  250. height: 34rpx;
  251. }
  252. }
  253. }
  254. .info-box {
  255. width: 670rpx;
  256. height: 186rpx;
  257. background: #ffffff;
  258. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  259. border-radius: 20rpx;
  260. margin: -100rpx auto 0;
  261. position: relative;
  262. z-index: 2;
  263. .info-item {
  264. width: 50%;
  265. display: flex;
  266. flex-direction: column;
  267. align-items: center;
  268. line-height: 1;
  269. .info-font {
  270. font-size: 30rpx;
  271. font-family: PingFang SC;
  272. font-weight: bold;
  273. color: #999999;
  274. }
  275. .info-num {
  276. margin-top: 30rpx;
  277. font-size: 30rpx;
  278. font-family: PingFang SC;
  279. font-weight: bold;
  280. color: #181818;
  281. }
  282. }
  283. .shu {
  284. width: 2rpx;
  285. height: 74rpx;
  286. background: #dcdfe6;
  287. }
  288. }
  289. .money-box {
  290. position: relative;
  291. z-index: 2;
  292. padding-top: 70rpx;
  293. /* #ifdef APP-PLUS */
  294. padding-top: 30rpx;
  295. /* #endif */
  296. color: #ffffff;
  297. text-align: center;
  298. .money {
  299. font-size: 72rpx;
  300. font-family: PingFang SC;
  301. font-weight: bold;
  302. color: #ffffff;
  303. }
  304. .text {
  305. font-size: 30rpx;
  306. }
  307. }
  308. .moneybtn-box {
  309. display: flex;
  310. justify-content: space-between;
  311. position: relative;
  312. z-index: 2;
  313. color: #ffffff;
  314. padding: 20rpx 50rpx;
  315. font-size: 30rpx;
  316. font-family: PingFang SC;
  317. font-weight: bold;
  318. color: #ffffff;
  319. }
  320. .navbar {
  321. margin-top: 20rpx;
  322. display: flex;
  323. height: 88rpx;
  324. padding: 0 5px;
  325. background: #fff;
  326. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  327. position: relative;
  328. z-index: 10;
  329. .nav-item {
  330. flex: 1;
  331. display: flex;
  332. justify-content: center;
  333. align-items: center;
  334. height: 100%;
  335. font-size: 15px;
  336. color: #999999;
  337. position: relative;
  338. &.current {
  339. color: #000;
  340. &:after {
  341. content: '';
  342. position: absolute;
  343. left: 50%;
  344. bottom: 0;
  345. transform: translateX(-50%);
  346. width: 44px;
  347. height: 0;
  348. border-bottom: 2px solid #fe5b38;
  349. }
  350. }
  351. }
  352. }
  353. //列表
  354. .swiper-box {
  355. .order-item:last-child {
  356. margin-bottom: 60rpx;
  357. }
  358. .order-item {
  359. padding: 20rpx 30rpx;
  360. line-height: 1.5;
  361. .title-box {
  362. .title {
  363. font-size: $font-lg;
  364. color: $font-color-base;
  365. }
  366. .time {
  367. font-size: $font-base;
  368. color: $font-color-light;
  369. }
  370. }
  371. .money {
  372. color: #fd5b23;
  373. font-size: $font-lg;
  374. text-align: right;
  375. .status {
  376. color: $font-color-light;
  377. }
  378. }
  379. }
  380. }
  381. .list-scroll-content {
  382. background: #ffffff;
  383. height: 100%;
  384. }
  385. .content {
  386. height: 100%;
  387. .empty-content {
  388. background-color: #ffffff;
  389. }
  390. }
  391. .btn-box {
  392. width: 674rpx;
  393. height: 88rpx;
  394. background: linear-gradient(0deg, #2e58ff, #32c6ff);
  395. border-radius: 44rpx;
  396. font-size: 36rpx;
  397. font-family: PingFang SC;
  398. font-weight: 500;
  399. color: #ffffff;
  400. text-align: center;
  401. line-height: 88rpx;
  402. position: fixed;
  403. bottom: 48rpx;
  404. left: 0;
  405. right: 0;
  406. margin: 0 auto;
  407. }
  408. </style>