jf.vue 8.6 KB

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