integralP.vue 9.6 KB

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