integral.vue 12 KB

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