publicWelfare.vue 10 KB

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