myLq.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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/myLq.png" mode=""></image></view>
  10. <view class="money-box">
  11. <view class="money">{{ userInfo.brokerage_price | getMoneyStyle }}</view>
  12. <view>可用积分</view>
  13. </view>
  14. <view class="moneybtn-box">
  15. <view class="money-btn" @click="navto('/pages/money/wallet')">转给好友</view>
  16. <view class="money-btn" @click="navto('/pages/money/withdrawal')">积分提现</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 { moneyList, 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. 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. spreadCommission(
  161. {
  162. page: navItem.page,
  163. limit: navItem.limit,
  164. pm: navItem.state
  165. },
  166. navItem.state
  167. )
  168. .then(({ data }) => {
  169. this.zc = data.sum_out;
  170. this.sr = data.sum_in;
  171. navItem.orderList = navItem.orderList.concat(data.list);
  172. navItem.page++;
  173. if (navItem.limit == data.list.length) {
  174. navItem.loadingType = 'more';
  175. } else {
  176. navItem.loadingType = 'noMore';
  177. }
  178. this.$set(navItem, 'loaded', true);
  179. })
  180. .catch(e => {
  181. console.log(e);
  182. });
  183. },
  184. //swiper 切换
  185. changeTab(e) {
  186. this.tabCurrentIndex = e.target.current;
  187. this.loadData('tabChange');
  188. },
  189. //顶部tab点击
  190. tabClick(index) {
  191. this.tabCurrentIndex = index;
  192. }
  193. }
  194. };
  195. </script>
  196. <style lang="scss">
  197. page {
  198. background: #f1f1f1;
  199. height: 100%;
  200. }
  201. .status_bar {
  202. height: var(--status-bar-height);
  203. width: 100%;
  204. }
  205. .content-money {
  206. position: relative;
  207. height: 480rpx;
  208. .content-bg {
  209. position: absolute;
  210. top: 0;
  211. left: 0;
  212. right: 0;
  213. width: 750rpx;
  214. height: 480rpx;
  215. image {
  216. width: 100%;
  217. height: 100%;
  218. }
  219. }
  220. .body-title {
  221. height: 80rpx;
  222. text-align: center;
  223. font-size: 35rpx;
  224. position: relative;
  225. .header {
  226. position: absolute;
  227. left: 0;
  228. top: 0;
  229. width: 100%;
  230. font-size: 36rpx;
  231. font-family: PingFang SC;
  232. font-weight: bold;
  233. color: #fffeff;
  234. height: 80rpx;
  235. font-size: 36rpx;
  236. font-weight: 700;
  237. z-index: 9;
  238. display: flex;
  239. justify-content: center;
  240. align-items: center;
  241. }
  242. .goback-box {
  243. position: absolute;
  244. left: 18rpx;
  245. top: 0;
  246. height: 80rpx;
  247. display: flex;
  248. align-items: center;
  249. }
  250. .goback {
  251. z-index: 100;
  252. width: 34rpx;
  253. height: 34rpx;
  254. }
  255. }
  256. }
  257. .info-box {
  258. width: 670rpx;
  259. height: 186rpx;
  260. background: #ffffff;
  261. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  262. border-radius: 20rpx;
  263. margin: -100rpx auto 0;
  264. position: relative;
  265. z-index: 2;
  266. .info-item {
  267. width: 50%;
  268. display: flex;
  269. flex-direction: column;
  270. align-items: center;
  271. line-height: 1;
  272. .info-font {
  273. font-size: 30rpx;
  274. font-family: PingFang SC;
  275. font-weight: bold;
  276. color: #999999;
  277. }
  278. .info-num {
  279. margin-top: 30rpx;
  280. font-size: 30rpx;
  281. font-family: PingFang SC;
  282. font-weight: bold;
  283. color: #181818;
  284. }
  285. }
  286. .shu {
  287. width: 2rpx;
  288. height: 74rpx;
  289. background: #dcdfe6;
  290. }
  291. }
  292. .money-box {
  293. position: relative;
  294. z-index: 2;
  295. padding-top: 70rpx;
  296. color: #ffffff;
  297. text-align: center;
  298. /* #ifdef APP-PLUS */
  299. padding-top: 30rpx;
  300. /* #endif */
  301. .money {
  302. font-size: 72rpx;
  303. font-family: PingFang SC;
  304. font-weight: bold;
  305. color: #ffffff;
  306. }
  307. .text {
  308. font-size: 30rpx;
  309. }
  310. }
  311. .moneybtn-box {
  312. display: flex;
  313. justify-content: space-between;
  314. position: relative;
  315. z-index: 2;
  316. color: #ffffff;
  317. padding: 20rpx 50rpx;
  318. font-size: 30rpx;
  319. font-family: PingFang SC;
  320. font-weight: bold;
  321. color: #ffffff;
  322. }
  323. .navbar {
  324. margin-top: 20rpx;
  325. display: flex;
  326. height: 88rpx;
  327. padding: 0 5px;
  328. background: #fff;
  329. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  330. position: relative;
  331. z-index: 10;
  332. .nav-item {
  333. flex: 1;
  334. display: flex;
  335. justify-content: center;
  336. align-items: center;
  337. height: 100%;
  338. font-size: 15px;
  339. color: #999999;
  340. position: relative;
  341. &.current {
  342. color: #000;
  343. &:after {
  344. content: '';
  345. position: absolute;
  346. left: 50%;
  347. bottom: 0;
  348. transform: translateX(-50%);
  349. width: 44px;
  350. height: 0;
  351. border-bottom: 2px solid #fe5b38;
  352. }
  353. }
  354. }
  355. }
  356. //列表
  357. .swiper-box {
  358. .order-item:last-child {
  359. margin-bottom: 60rpx;
  360. }
  361. .order-item {
  362. padding: 20rpx 30rpx;
  363. line-height: 1.5;
  364. .title-box {
  365. .title {
  366. font-size: $font-lg;
  367. color: $font-color-base;
  368. }
  369. .time {
  370. font-size: $font-base;
  371. color: $font-color-light;
  372. }
  373. }
  374. .money {
  375. color: #fd5b23;
  376. font-size: $font-lg;
  377. text-align: right;
  378. .status {
  379. color: $font-color-light;
  380. }
  381. }
  382. }
  383. }
  384. .list-scroll-content {
  385. background: #ffffff;
  386. height: 100%;
  387. }
  388. .content {
  389. height: 100%;
  390. .empty-content {
  391. background-color: #ffffff;
  392. }
  393. }
  394. .btn-box {
  395. width: 674rpx;
  396. height: 88rpx;
  397. background: linear-gradient(0deg, #2e58ff, #32c6ff);
  398. border-radius: 44rpx;
  399. font-size: 36rpx;
  400. font-family: PingFang SC;
  401. font-weight: 500;
  402. color: #ffffff;
  403. text-align: center;
  404. line-height: 88rpx;
  405. position: fixed;
  406. bottom: 48rpx;
  407. left: 0;
  408. right: 0;
  409. margin: 0 auto;
  410. }
  411. </style>