integral.vue 12 KB

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