integralP.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  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/user-ping.png" mode=""></image></view>
  10. <view class="money-box"><view class="money">{{ integral || 0 }}</view></view>
  11. <view class="rule" @click="open()">转赠规则</view>
  12. </view>
  13. <view class="btn flex">
  14. <view class="btn-item" @click="navto('/pages/conversion/candy?type=USDC')">转换为糖果</view>
  15. <view class="btn-item" @click="navto('/pages/conversion/transfers?type=USDC')">积分转赠</view>
  16. </view>
  17. <view class="navbar">
  18. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  19. </view>
  20. <swiper :current="tabCurrentIndex" :style="{ height: maxheight }" class="swiper-box" duration="300" @change="changeTab">
  21. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  22. <scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="loadData">
  23. <!-- 空白页 -->
  24. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  25. <!-- 订单列表 -->
  26. <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index">
  27. <view class="title-box">
  28. <view class="title">
  29. <text>{{ item.title }}</text>
  30. </view>
  31. <view class="time">
  32. <text>{{ item.add_time }}</text>
  33. </view>
  34. </view>
  35. <view class="money">
  36. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  37. </view>
  38. </view>
  39. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  40. </scroll-view>
  41. </swiper-item>
  42. </swiper>
  43. <uni-popup ref="popup" type="center">
  44. <view class="popup-box">
  45. <view class="popup-title">转赠规则</view>
  46. <view class="popup-main">
  47. <view class="popup-little">一、活动时间</view>
  48. <view class="popup-text">xxxx年xx月xx日xx时举办活动</view>
  49. <view class="popup-little">二、规则</view>
  50. <view class="popup-text">本次活动奖励共二挡,活动奖励按 最高档发放</view>
  51. <view class="popup-little">一、活动时间</view>
  52. <view class="popup-text">xxxx年xx月xx日xx时举办活动</view>
  53. <view class="popup-little">二、规则</view>
  54. <view class="popup-text">本次活动奖励共二挡,活动奖励按 最高档发放</view>
  55. </view>
  56. </view>
  57. <view class="close" @click="close"><image src="../../static/img/Close.png" mode=""></image></view>
  58. </uni-popup>
  59. </view>
  60. </template>
  61. <script>
  62. import { moneyLog, recharge, wallet } from '@/api/finance.js';
  63. import { mapState, mapMutations } from 'vuex';
  64. import uniLoadMore from '@/uview-ui/components/u-loadmore/u-loadmore.vue';
  65. import empty from '@/uview-ui/components/u-empty/u-empty.vue';
  66. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  67. export default {
  68. components: {
  69. empty,
  70. uniLoadMore,
  71. uniPopup
  72. },
  73. onReady(res) {
  74. var _this = this;
  75. uni.getSystemInfo({
  76. success: resu => {
  77. const query = uni.createSelectorQuery();
  78. query.select('.swiper-box').boundingClientRect();
  79. query.exec(function(res) {
  80. _this.maxheight = resu.windowHeight - res[0].top + 'px';
  81. console.log('打印页面的剩余高度', _this.height);
  82. });
  83. },
  84. fail: res => {}
  85. });
  86. },
  87. data() {
  88. return {
  89. integral: 0,//我的积分
  90. // 头部图高度
  91. maxheight: '',
  92. tabCurrentIndex: 0,
  93. navList: [
  94. {
  95. state: 1,
  96. text: '收入',
  97. loadingType: 'more',
  98. orderList: [],
  99. page: 1, //当前页面
  100. limit: 10 //每次信息条数
  101. },
  102. {
  103. state: 0,
  104. text: '支出',
  105. loadingType: 'more',
  106. orderList: [],
  107. page: 1, //当前页面
  108. limit: 10 //每次信息条数
  109. }
  110. ],
  111. };
  112. },
  113. onLoad(options) {},
  114. onShow() {
  115. wallet({}).then(({ data }) => {
  116. const obj = this
  117. const arr = Object.keys(data.back);
  118. console.log(arr);
  119. arr.forEach(e => {
  120. if(e == 'USDC'){
  121. obj.integral = (data.back[e].money.money*1)
  122. }
  123. });
  124. });
  125. this.loadData();
  126. },
  127. methods: {
  128. navto(e) {
  129. uni.navigateTo({
  130. url: e
  131. });
  132. },
  133. // 点击返回 我的页面
  134. toBack() {
  135. uni.navigateBack({});
  136. },
  137. async loadData(source) {
  138. //这里时将订单挂载到tab列表下
  139. let index = this.tabCurrentIndex;
  140. let navItem = this.navList[index];
  141. let state = navItem.state + 3;
  142. if (source === 'tabChange' && navItem.loaded === true) {
  143. //tab切换只有第一次需要加载数据
  144. return;
  145. }
  146. if (navItem.loadingType === 'loading') {
  147. //防止重复加载
  148. return;
  149. }
  150. //修改当前对象状态为加载中
  151. navItem.loadingType = 'loading';
  152. moneyLog(
  153. {
  154. page: navItem.page,
  155. limit: navItem.limit,
  156. pm:navItem.state
  157. },
  158. 'USDC'
  159. )
  160. .then(({ data }) => {
  161. if (data.list.length > 0) {
  162. navItem.orderList = navItem.orderList.concat(data.list);
  163. console.log(navItem.orderList);
  164. navItem.page++;
  165. }
  166. //判断是否还有数据, 有改为more, 没有改为noMore
  167. if (navItem.limit == data.length) {
  168. navItem.loadingType = 'more';
  169. return;
  170. } else {
  171. navItem.loadingType = 'noMore';
  172. }
  173. uni.hideLoading();
  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. open() {
  190. this.$refs.popup.open();
  191. },
  192. close() {
  193. this.$refs.popup.close();
  194. },
  195. }
  196. };
  197. </script>
  198. <style lang="scss">
  199. page {
  200. background: #f1f1f1;
  201. height: 100%;
  202. }
  203. .status_bar {
  204. height: var(--status-bar-height);
  205. width: 100%;
  206. }
  207. .content-money {
  208. padding-bottom: 30rpx;
  209. position: relative;
  210. height: 400rpx;
  211. .content-bg {
  212. position: absolute;
  213. top: 0;
  214. left: 0;
  215. right: 0;
  216. width: 750rpx;
  217. height: 400rpx;
  218. image {
  219. width: 100%;
  220. height: 100%;
  221. }
  222. }
  223. .body-title {
  224. height: 80rpx;
  225. text-align: center;
  226. font-size: 35rpx;
  227. position: relative;
  228. .header {
  229. position: absolute;
  230. left: 0;
  231. top: 0;
  232. width: 100%;
  233. font-size: 36rpx;
  234. font-family: PingFang SC;
  235. font-weight: bold;
  236. color: #fffeff;
  237. height: 80rpx;
  238. font-size: 36rpx;
  239. font-weight: 700;
  240. z-index: 2;
  241. display: flex;
  242. justify-content: center;
  243. align-items: center;
  244. }
  245. .goback-box {
  246. position: absolute;
  247. left: 18rpx;
  248. top: 0;
  249. height: 80rpx;
  250. display: flex;
  251. align-items: center;
  252. }
  253. .goback {
  254. z-index: 100;
  255. width: 34rpx;
  256. height: 34rpx;
  257. }
  258. }
  259. .rule {
  260. z-index: 11;
  261. position: absolute;
  262. top: 130rpx;
  263. right: 0;
  264. width: 140rpx;
  265. height: 50rpx;
  266. background: #ffffff;
  267. border-top-left-radius: 8rpx;
  268. border-bottom-left-radius: 8rpx;
  269. text-align: center;
  270. line-height: 50rpx;
  271. font-size: 26rpx;
  272. font-family: PingFang SC;
  273. font-weight: bold;
  274. color: #2e58ff;
  275. }
  276. }
  277. .btn {
  278. justify-content: center;
  279. align-items: center;
  280. position: relative;
  281. z-index: 10;
  282. .btn-item {
  283. margin: 0 15rpx;
  284. width: 330rpx;
  285. height: 100rpx;
  286. background: #ffffff;
  287. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  288. border-radius: 10rpx;
  289. text-align: center;
  290. line-height: 100rpx;
  291. font-size: 34rpx;
  292. font-family: PingFang SC;
  293. font-weight: bold;
  294. color: #3c77ff;
  295. margin-top: -50rpx;
  296. }
  297. }
  298. .money-box {
  299. position: relative;
  300. z-index: 10;
  301. padding-top: 80rpx;
  302. color: #ffffff;
  303. text-align: center;
  304. .money {
  305. font-size: 86rpx;
  306. font-family: PingFang SC;
  307. font-weight: bold;
  308. color: #ffffff;
  309. }
  310. }
  311. .navbar {
  312. margin-top: 20rpx;
  313. display: flex;
  314. height: 88rpx;
  315. padding: 0 5px;
  316. background: #fff;
  317. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  318. position: relative;
  319. z-index: 10;
  320. .nav-item {
  321. flex: 1;
  322. display: flex;
  323. justify-content: center;
  324. align-items: center;
  325. height: 100%;
  326. font-size: 15px;
  327. color: $font-color-dark;
  328. position: relative;
  329. &.current {
  330. color: $base-color;
  331. &:after {
  332. content: '';
  333. position: absolute;
  334. left: 50%;
  335. bottom: 0;
  336. transform: translateX(-50%);
  337. width: 44px;
  338. height: 0;
  339. border-bottom: 2px solid $base-color;
  340. }
  341. }
  342. }
  343. }
  344. //列表
  345. .swiper-box {
  346. .order-item {
  347. padding: 20rpx 30rpx;
  348. line-height: 1.5;
  349. .title-box {
  350. .title {
  351. font-size: $font-lg;
  352. color: $font-color-base;
  353. }
  354. .time {
  355. font-size: $font-base;
  356. color: $font-color-light;
  357. }
  358. }
  359. .money {
  360. color: #fd5b23;
  361. font-size: $font-lg;
  362. }
  363. }
  364. }
  365. .list-scroll-content {
  366. background: #ffffff;
  367. height: 100%;
  368. }
  369. .content {
  370. height: 100%;
  371. .empty-content {
  372. background-color: #ffffff;
  373. }
  374. }
  375. .popup-box {
  376. background: #FFFFFF;
  377. border-radius: 10rpx;
  378. width: 580rpx;
  379. padding: 43rpx 60rpx 56rpx 34rpx;
  380. .popup-title {
  381. width: 100%;
  382. text-align: center;
  383. font-size: 36rpx;
  384. font-family: PingFang SC;
  385. font-weight: bold;
  386. color: #333333;
  387. }
  388. .popup-main {
  389. margin-top: 48rpx;
  390. .popup-little {
  391. padding-top: 18rpx;
  392. font-size: 30rpx;
  393. font-family: PingFang SC;
  394. font-weight: 500;
  395. color: #333333;
  396. }
  397. .popup-text {
  398. padding-left: 60rpx;
  399. padding-top: 18rpx;
  400. font-size: 28rpx;
  401. font-family: PingFang SC;
  402. font-weight: 500;
  403. color: #666666;
  404. }
  405. }
  406. }
  407. .close {
  408. margin: 70rpx auto 0;
  409. width: 84rpx;
  410. height: 84rpx;
  411. image {
  412. width: 100%;
  413. height: 100%;
  414. }
  415. }
  416. </style>