integral.vue 12 KB

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