integral.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. <template>
  2. <view>
  3. <view class="top-cont">
  4. <!-- 背景图片 -->
  5. <image class="bg" src="../../static/images/jf_top_Bg.png" mode=""></image>
  6. <view class="top-inner">
  7. <!-- 这里是状态栏 -->
  8. <view class="fixed-top-box" :style="{ background: bg }">
  9. <view class="status_bar" :style="{height: statusBarHeight}"></view>
  10. <view class="back-box" @click="back">
  11. <image src="../../static/images/back_white.png" mode=""></image>
  12. <text class="title">我的积分</text>
  13. <text></text>
  14. </view>
  15. </view>
  16. <!-- 顶部固定后站位元素 -->
  17. <view style="padding-bottom: 88upx;">
  18. <view :style="{height: statusBarHeight}"></view>
  19. </view>
  20. <!-- 可用积分 -->
  21. <view class="available-points">
  22. <text class="label">可用积分</text>
  23. <text class="num">{{integral}}</text>
  24. </view>
  25. <!-- 签到 -->
  26. <view class="singn-content">
  27. <view class="sign-in-box">
  28. <view class="inner">
  29. <view class="title-box">已连续签到<text class="num">{{signNum}}</text>天</view>
  30. <!-- 签到天数 -->
  31. <view class="sign-list">
  32. <view v-for="(item,index) in sign" :key="index" :class="signNum >= index+ 1?'item active':'item'">
  33. <view class="line"></view>
  34. <view class="right">
  35. <!-- 已签到图标 -->
  36. <image v-if="signNum >= index+ 1" src="../../static/images/right_org.png" mode=""></image>
  37. <!-- 未签到图标 -->
  38. <image v-else src="../../static/images/right_org_ling.png" mode=""></image>
  39. <text class="text">{{ item.day }}</text>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <!-- 签到按钮 -->
  45. <view class="sign-btn-box" >
  46. <view class="btn" v-if="isDaySign==false" @click="doSign()">
  47. <image src="../../static/images/sign.png" mode=""></image>
  48. <text class="text">签到</text>
  49. </view>
  50. <view class="btn" v-else>
  51. <image src="../../static/images/sign.png" mode=""></image>
  52. <text class="text">已签到</text>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="content">
  58. <!-- 积分列表 -->
  59. <view class="points-cont">
  60. <!-- tab切换 -->
  61. <view class="pub-tab-box">
  62. <view class="tab-inner">
  63. <view
  64. v-for="(item,index) in tags"
  65. :key="index"
  66. :class="tabIndex == item.value?'item active':'item'"
  67. @click="tabChange(item)"
  68. >
  69. <view class="text">
  70. {{ item.lable }}
  71. <image v-show="tabIndex == item.value" class="tab-bg" src="../../static/images/tab_bg2.png" mode=""></image>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. <!-- 列表 -->
  77. <view class="point-list">
  78. <view v-for="(item,index) in list" :key="index" class="item">
  79. <view class="left">
  80. <view class="title">{{item.title}}</view>
  81. <view class="time">{{item.createTime}}</view>
  82. </view>
  83. <view class="right">
  84. <text v-if="item.number<0" class="less">{{item.number}}</text>
  85. <text v-else class="add">+{{item.number}}</text>
  86. </view>
  87. </view>
  88. </view>
  89. <Loading :loaded="loaded" :loading="loading"></Loading>
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. </template>
  96. <script>
  97. import {getUserSign,getIntegral,doSign} from '@/api/userSign'
  98. import Loading from "@/components/Loading";
  99. export default {
  100. components: {
  101. Loading,
  102. },
  103. data() {
  104. return {
  105. isDaySign:false,
  106. top:0,
  107. signNum:0,
  108. integral:0,
  109. sign:[],
  110. // 状态栏的高度
  111. statusBarHeight: uni.getStorageSync('menuInfo').statusBarHeight,
  112. // tab切换
  113. tags: [{lable:'全部',value:-1},{lable:'获得',value:1},{lable:'消耗',value:0}],
  114. // 选中的tab
  115. tabIndex: -1,
  116. current: 0,
  117. page: {
  118. billType:-1,
  119. page: 1,
  120. pageSize: 10
  121. },
  122. list: [],
  123. loaded: false,
  124. loading: false
  125. };
  126. },
  127. onLoad(option) {
  128. this.getUserSign()
  129. this.getIntegral()
  130. },
  131. onReachBottom() {
  132. !this.loading && this.getIntegral();
  133. },
  134. onPageScroll(e) {
  135. if(e.scrollTop > 30) {
  136. this.topFixed = true
  137. } else {
  138. this.topFixed = false
  139. }
  140. },
  141. onPageScroll(e) {
  142. this.top=e.scrollTop;
  143. },
  144. computed: {
  145. // 计算属性的 getter
  146. bg: function() {
  147. return 'rgba(255,142,60, ' + this.top / 30 + ')';
  148. },
  149. },
  150. methods: {
  151. doSign(){
  152. var data={};
  153. uni.showLoading({
  154. title:"正在加载中..."
  155. })
  156. doSign(data).then(
  157. res => {
  158. uni.hideLoading()
  159. if(res.code==200){
  160. uni.showToast({
  161. icon:'success',
  162. title: res.msg,
  163. });
  164. this.list=[];
  165. this.page.page=1;
  166. this.list=[];
  167. this.loaded=false;
  168. this.loading=false;
  169. this.getIntegral();
  170. this.getUserSign();
  171. }else{
  172. uni.showToast({
  173. icon:'none',
  174. title: res.msg,
  175. });
  176. }
  177. },
  178. rej => {}
  179. );
  180. },
  181. getUserSign(){
  182. getUserSign().then(
  183. res => {
  184. if(res.code==200){
  185. this.data=res.member;
  186. this.signNum=res.signNum;
  187. this.isDaySign=res.isDaySign;
  188. this.integral=res.integral;
  189. this.sign=JSON.parse(res.sign);
  190. }else{
  191. uni.showToast({
  192. icon:'none',
  193. title: "请求失败",
  194. });
  195. }
  196. },
  197. rej => {}
  198. );
  199. },
  200. getIntegral() {
  201. let that = this;
  202. if (that.loaded == true || that.loading == true) return;
  203. that.loading = true;
  204. uni.showLoading({
  205. title:"加载中..."
  206. })
  207. getIntegral(that.page).then(
  208. res => {
  209. that.loading = false;
  210. that.loaded = res.data.list.length < that.page.pageSize;
  211. that.page.page = that.page.page + 1;
  212. that.list.push.apply(that.list, res.data.list);
  213. uni.hideLoading()
  214. },
  215. err => {
  216. uni.hideLoading()
  217. uni.showToast({
  218. title: err.msg ,
  219. icon: 'none',
  220. duration: 2000
  221. });
  222. }
  223. );
  224. },
  225. // 返回上一页
  226. back() {
  227. uni.navigateBack()
  228. },
  229. // tab选择
  230. tabChange(item) {
  231. console.log(item)
  232. this.tabIndex = item.value
  233. this.page.billType=this.tabIndex;
  234. this.page.page=1;
  235. this.list=[];
  236. this.loaded=false;
  237. this.loading=false;
  238. this.getIntegral();
  239. }
  240. }
  241. }
  242. </script>
  243. <style lang="scss">
  244. .fixed-top-box{
  245. width: 100%;
  246. position: fixed;
  247. top: 0;
  248. left: 0;
  249. z-index: 1000;
  250. transition: all 0.5s;
  251. }
  252. .top-cont{
  253. width: 100%;
  254. height: 654upx;
  255. position: relative;
  256. .bg{
  257. width: 100%;
  258. height: 100%;
  259. position: absolute;
  260. top: 0;
  261. left: 0;
  262. z-index: 1;
  263. }
  264. .top-inner{
  265. width: 100%;
  266. height: 100%;
  267. position: absolute;
  268. top: 0;
  269. left: 0;
  270. z-index: 2;
  271. .back-box{
  272. height: 88upx;
  273. padding-left: 22upx;
  274. display: flex;
  275. align-items: center;
  276. justify-content: space-between;
  277. padding: 0 20upx;
  278. image{
  279. width: 40upx;
  280. height: 40upx;
  281. }
  282. .title{
  283. font-size: 36upx;
  284. font-family: PingFang SC;
  285. font-weight: 500;
  286. color: #FFFFFF;
  287. }
  288. }
  289. .available-points{
  290. margin-top: 40upx;
  291. display: flex;
  292. flex-direction: column;
  293. align-items: center;
  294. justify-content: center;
  295. .label{
  296. font-size: 30upx;
  297. font-family: PingFang SC;
  298. font-weight: bold;
  299. color: #FFFFFF;
  300. line-height: 1;
  301. }
  302. .num{
  303. font-size: 80upx;
  304. font-family: Gilroy;
  305. font-weight: 500;
  306. color: #FFFFFF;
  307. line-height: 1;
  308. margin-top: 28upx;
  309. }
  310. }
  311. .singn-content{
  312. padding: 0 20upx;
  313. margin-top: 50upx;
  314. }
  315. .sign-in-box{
  316. height: 380upx;
  317. background: #FFFFFF;
  318. border-radius: 16upx;
  319. .inner{
  320. padding: 40upx 30upx;
  321. .title-box{
  322. font-size: 26upx;
  323. font-family: PingFang SC;
  324. font-weight: 500;
  325. color: #666666;
  326. line-height: 1;
  327. .num{
  328. font-size: 32upx;
  329. font-family: PingFang SC;
  330. font-weight: Bold;
  331. color: #FF7511;
  332. margin: 0 10upx;
  333. line-height: 1;
  334. }
  335. }
  336. .sign-list{
  337. display: flex;
  338. align-items: center;
  339. justify-content: space-between;
  340. margin-top: 40upx;
  341. .item{
  342. display: flex;
  343. justify-content: center;
  344. .right{
  345. display: flex;
  346. flex-direction: column;
  347. align-items: center;
  348. justify-content: center;
  349. image{
  350. width: 44upx;
  351. height: 44upx;
  352. margin-bottom: 20upx;
  353. }
  354. .text{
  355. font-size: 24upx;
  356. font-family: PingFang SC;
  357. font-weight: 500;
  358. color: #FF7511;
  359. line-height: 1;
  360. white-space: nowrap;
  361. }
  362. }
  363. .line{
  364. width: 34upx;
  365. height: 4upx;
  366. background: #F6CDA7;
  367. border-radius: 2upx;
  368. margin-top: 22upx;
  369. }
  370. &:first-child{
  371. .line{
  372. display: none;
  373. }
  374. }
  375. &.active{
  376. .line{
  377. background: #FF8E3C;
  378. }
  379. }
  380. }
  381. }
  382. }
  383. .sign-btn-box{
  384. padding: 0 14upx;
  385. .btn{
  386. width: 100%;
  387. height: 120upx;
  388. background-image: url(../../static/images/org_btn.png);
  389. background-repeat: no-repeat;
  390. background-size: 100% 100%;
  391. display: flex;
  392. justify-content: center;
  393. image{
  394. width: 32upx;
  395. height: 32upx;
  396. margin-top: 32upx;
  397. margin-right: 16upx;
  398. }
  399. .text{
  400. font-size: 30upx;
  401. font-family: PingFang SC;
  402. font-weight: bold;
  403. color: #FFFFFF;
  404. line-height: 1;
  405. margin-top: 36upx;
  406. }
  407. }
  408. }
  409. }
  410. }
  411. }
  412. .content{
  413. margin-top: 20upx;
  414. padding: 0 20upx 40upx;
  415. .points-cont{
  416. background-color: #FFFFFF;
  417. border-radius: 16upx;
  418. .pub-tab-box{
  419. padding: 0 80upx;
  420. .tab-inner{
  421. height: 88upx;
  422. line-height: 88upx;
  423. display: flex;
  424. align-items: center;
  425. justify-content: space-between;
  426. }
  427. .item{
  428. font-size: 28upx;
  429. white-space: nowrap;
  430. line-height: 1;
  431. font-family: PingFang SC;
  432. font-weight: 500;
  433. color: #666666;
  434. display: flex;
  435. align-items: center;
  436. justify-content: center;
  437. &.active{
  438. font-weight: bold;
  439. color: #333333;
  440. }
  441. .text{
  442. position: relative;
  443. z-index: 1;
  444. }
  445. .tab-bg{
  446. width: 72upx;
  447. height: 28upx;
  448. position: absolute;
  449. top: 17upx;
  450. left: 50%;
  451. transform: translateX(-36upx);
  452. z-index: -1;
  453. }
  454. }
  455. }
  456. .point-list{
  457. padding: 0 30upx;
  458. .item{
  459. padding: 30upx 0;
  460. display: flex;
  461. align-items: center;
  462. justify-content: space-between;
  463. border-bottom: 1px solid #F0F0F0;
  464. &:last-child{
  465. border-bottom: none;
  466. }
  467. .left{
  468. .title{
  469. font-size: 28upx;
  470. font-family: PingFang SC;
  471. font-weight: 500;
  472. color: #111111;
  473. line-height: 1;
  474. }
  475. .time{
  476. font-size: 24upx;
  477. font-family: PingFang SC;
  478. font-weight: 500;
  479. color: #999999;
  480. line-height: 1;
  481. margin-top: 22upx;
  482. }
  483. }
  484. .right{
  485. .add{
  486. font-size: 28upx;
  487. font-family: PingFang SC;
  488. font-weight: 500;
  489. color: #111111;
  490. }
  491. .less{
  492. font-size: 28upx;
  493. font-family: PingFang SC;
  494. font-weight: 500;
  495. color: #F56C6C;
  496. }
  497. }
  498. }
  499. }
  500. }
  501. }
  502. </style>