clockin.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. <template>
  2. <view>
  3. <view class="main_view">
  4. <view class="status_bar" :style="status_bar_style">
  5. <view v-if="hasPrePage" class="back-btn" @click="goBack">
  6. <uni-icons type="left" size="20" color="#333"></uni-icons>
  7. </view>
  8. </view>
  9. <view class="info_box">
  10. <view class="left_box">
  11. <view class="score_info">
  12. <view class="score_title">当前积分</view>
  13. <view class="score_current">{{ scoreInfo.score }} </view>
  14. </view>
  15. <view class="wait_info">
  16. <view class="wait_title">待入账积分</view>
  17. <view class="wait_score">{{ scoreInfo.wait_score ? scoreInfo.wait_score : 0 }}</view>
  18. </view>
  19. </view>
  20. <view class="right_box" v-if="show_lottery">
  21. <navigator url="/pages/score/lottery" class="lottery_enter">
  22. <image class="lottery_img" src="https://mall.findit.ltd/uploads/images/default/lottery_record.png" mode=""></image>
  23. <view class="lottery_text">点我抽奖</view>
  24. </navigator>
  25. </view>
  26. </view>
  27. <view class="clockin_box" v-if="clockinList.length > 0">
  28. <view class="box_title">
  29. <view class="left_icon" v-if="this.listKey > 0" @click="leftClockin()"><uni-icons type="left" size="20"></uni-icons></view>
  30. {{ isMark.finish_day ? '已连续签到 ' + isMark.finish_day + ' 天' : '连续签到奖励更丰厚' }}
  31. <view class="right_icon" v-if="this.listKey < this.listLength - 1" @click="rightClockin()"> <uni-icons type="right" size="20"></uni-icons></view>
  32. </view>
  33. <view class="clockin_list">
  34. <view class="clockin_item" :class="item.is_finish ? 'acitve' : ''" v-for="(item, index) in clockinList[listKey]" :key="index">
  35. <view class="give_coupon" v-if="item['coupon_id']">券</view>
  36. <view class="what_day">{{ item.what_day }}</view>
  37. <view class="score_one">
  38. <image class="score_icon" src="https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/icon/score.png" mode=""></image>
  39. </view>
  40. <!-- <view class="score_tow" v-if="index == 2 || index == 4">
  41. <image class="score_icon" src="https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/icon/score.png" mode=""></image>
  42. <image class="score_icon" src="https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/icon/score.png" mode=""></image>
  43. </view>-->
  44. <view class="give_score">+{{ item.reward }}</view>
  45. </view>
  46. </view>
  47. <button class="clockin_btn" :class="isMark.is_clockin ? 'active' : ''" @click="toClockin()">{{ isMark.is_clockin ? '已签到' : '签到' }}</button>
  48. <navigator url="/pages/score/record" class="score_record">积分记录 &gt;</navigator>
  49. <button class="clockin_rule_btn" @click="showRule">活动规则 &gt;</button>
  50. </view>
  51. <view class="clockin_box" v-else>
  52. <view class="box_title"> 暂无签到活动 </view>
  53. <navigator url="/pages/score/record" class="score_record">积分记录 &gt;</navigator>
  54. </view>
  55. <uni-popup ref="clockinRule" type="center">
  56. <view class="clockin_rule_box">
  57. <view class="clockin_rule_title">
  58. <text>签到规则</text>
  59. <view class="close_btn" @click="closeRule"> X </view>
  60. </view>
  61. <scroll-view class="clockin_rule_info" scroll-y="true">
  62. <rich-text :nodes="active_rule" class="rich_text"></rich-text>
  63. </scroll-view>
  64. </view>
  65. </uni-popup>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. export default {
  71. data() {
  72. return {
  73. status_bar_style: {},
  74. hasPrePage: false,
  75. clockinList: [],
  76. isMark: {
  77. finish_day: 0,
  78. is_clockin: 0,
  79. },
  80. scoreInfo: {
  81. score: 0,
  82. use_score: 0,
  83. wait_score: 0,
  84. },
  85. isReqing: false,
  86. listKey: 0,
  87. listLength: 0,
  88. active_id: 0,
  89. active_rule: '',
  90. show_lottery: 0,
  91. };
  92. },
  93. onLoad() {
  94. // #ifdef MP-WEIXIN
  95. let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
  96. this.status_bar_style = {
  97. height: menuButtonInfo.height + 'px',
  98. 'padding-top': menuButtonInfo.top + 'px',
  99. position: 'relative',
  100. display: 'flex',
  101. justifyContent: 'center',
  102. alignItems: 'center',
  103. zIndex: 1000,
  104. };
  105. // 判断是否有上级页面
  106. const pages = getCurrentPages();
  107. this.hasPrePage = pages.length > 1;
  108. // #endif
  109. // #ifdef MP-WEIXIN
  110. //分享按钮
  111. uni.showShareMenu({
  112. withShareTicket: true,
  113. menus: ['shareAppMessage', 'shareTimeline'],
  114. });
  115. // #endif
  116. },
  117. onShareAppMessage(obj) {
  118. // 获取分享信息
  119. let shareList = getApp().globalData.shareList;
  120. // 获取分享信息
  121. let shareObj = {
  122. title: '999智控终端平台\n药优惠 得积分 兑豪礼',
  123. path: '/pages/score/clockin',
  124. imageUrl: '',
  125. };
  126. // 循环列表
  127. for (let i in shareList) {
  128. if (shareList[i].pages == 'pages/score/clockin') {
  129. shareObj.path = shareList[i].path ? shareList[i].path : shareObj.path;
  130. shareObj.title = shareList[i].title ? `999智控终端平台\n${shareList[i].title}` : shareObj.title;
  131. shareObj.imageUrl = shareList[i].image_url ? shareList[i].image_url : shareObj.imageUrl;
  132. }
  133. }
  134. // 返回分享信息
  135. return shareObj;
  136. },
  137. onShow() {
  138. // 登录提示
  139. if (!this.$checkAccess.checkLogin()) return;
  140. // 请求打卡列表
  141. this.getClockinList();
  142. // 请求中,不允许刷新
  143. if (this.isReqing) return;
  144. // 设置请求中
  145. this.isReqing = true;
  146. // 请求列表
  147. this.$http.request('/api/custom_score/get_info', this.requestParam).then((re) => {
  148. // 设置非请求中
  149. this.isReqing = false;
  150. // 成功结果
  151. if (re.code == 'success') {
  152. this.scoreInfo = re.data;
  153. }
  154. });
  155. // 请求
  156. this.$http.request('api/lottery_score/get_detail').then((re) => {
  157. // 成功结果
  158. if (re.code == 'success') {
  159. this.show_lottery = 1;
  160. }
  161. });
  162. },
  163. methods: {
  164. goBack() {
  165. uni.navigateBack();
  166. },
  167. showRule() {
  168. this.$refs.clockinRule.open('center');
  169. },
  170. closeRule() {
  171. this.$refs.clockinRule.close();
  172. },
  173. toClockin() {
  174. // 如果已经打卡
  175. if (this.isMark.is_clockin) return;
  176. // 登录提示
  177. if (!this.$checkAccess.alterLogin()) return;
  178. if (this.active_id === 0) {
  179. uni.showToast({
  180. title: '暂无活动',
  181. icon: 'none',
  182. });
  183. }
  184. // 请求中,不允许刷新
  185. if (this.isReqing) return;
  186. // 设置请求中
  187. this.isReqing = true;
  188. // 请求列表
  189. this.$http
  190. .request(
  191. 'api/score_clockin/finish',
  192. {
  193. active_id: this.active_id,
  194. },
  195. 'post'
  196. )
  197. .then((re) => {
  198. // 设置非请求中
  199. this.isReqing = false;
  200. // 成功结果
  201. if (re.code == 'success') {
  202. // 赋值
  203. this.isMark = re.data;
  204. // 积分更新
  205. this.scoreInfo.score = re.data.reward + this.scoreInfo.score;
  206. // 更新打卡
  207. for (let i in this.clockinList[this.listKey]) {
  208. // 如果小于等于连续打卡天数,设置为打卡
  209. if (this.clockinList[this.listKey][i].what_day <= this.isMark.finish_day) this.clockinList[this.listKey][i].is_finish = 1;
  210. }
  211. } else {
  212. uni.showToast({
  213. title: '打卡失败',
  214. icon: 'none',
  215. });
  216. }
  217. });
  218. },
  219. getClockinList() {
  220. // 请求列表
  221. this.$http.request('api/score_clockin/get_list', this.requestParam).then((re) => {
  222. // 成功结果
  223. if (re.code == 'success') {
  224. // 赋值
  225. this.clockinList = re.data.list;
  226. this.listLength = this.clockinList.length;
  227. this.active_id = re.data.active_id;
  228. this.active_rule = re.data.active_rule;
  229. // 赋值
  230. this.isMark = re.data.is_mark;
  231. }
  232. });
  233. },
  234. leftClockin() {
  235. if (this.listKey > 0) {
  236. this.listKey = this.listKey - 1;
  237. }
  238. },
  239. rightClockin() {
  240. this.listKey = this.listKey + 1;
  241. },
  242. },
  243. };
  244. </script>
  245. <style lang="less">
  246. .status_bar {
  247. .back-btn {
  248. position: absolute;
  249. left: 16px;
  250. bottom: 0;
  251. padding: 6px;
  252. display: flex;
  253. align-items: center;
  254. justify-content: center;
  255. z-index: 1000;
  256. }
  257. }
  258. page {
  259. background-color: #ffffff;
  260. }
  261. .main_view {
  262. display: block;
  263. height: 1000rpx;
  264. background: linear-gradient(to bottom, #fc335f 0%, #fb7224 50%, #ffffff 100%);
  265. .status_bar {
  266. width: 100%;
  267. height: 64rpx;
  268. display: block;
  269. padding-top: var(--status-bar-height);
  270. }
  271. .info_box {
  272. display: block;
  273. overflow: hidden;
  274. .left_box {
  275. float: left;
  276. width: 450rpx;
  277. .score_info {
  278. color: #ffffff;
  279. overflow: hidden;
  280. padding: 0rpx 35rpx;
  281. .score_title {
  282. width: 240rpx;
  283. height: 60rpx;
  284. display: block;
  285. font-size: 26rpx;
  286. line-height: 60rpx;
  287. }
  288. .score_current {
  289. width: 240rpx;
  290. height: 80rpx;
  291. display: block;
  292. font-size: 66rpx;
  293. line-height: 80rpx;
  294. }
  295. }
  296. .wait_info {
  297. color: #ffffff;
  298. display: block;
  299. overflow: hidden;
  300. padding: 0rpx 35rpx;
  301. margin-top: 20rpx;
  302. .wait_title {
  303. width: 240rpx;
  304. height: 40rpx;
  305. display: block;
  306. font-size: 24rpx;
  307. line-height: 40rpx;
  308. }
  309. .wait_score {
  310. width: 240rpx;
  311. height: 60rpx;
  312. display: block;
  313. font-size: 36rpx;
  314. line-height: 60rpx;
  315. }
  316. }
  317. }
  318. .right_box {
  319. float: right;
  320. overflow: hidden;
  321. margin-top: 60rpx;
  322. margin-right: 35rpx;
  323. .lottery_enter {
  324. display: block;
  325. overflow: hidden;
  326. text-align: center;
  327. .lottery_img {
  328. width: 150rpx;
  329. height: 150rpx;
  330. display: block;
  331. margin: 0 auto;
  332. }
  333. .lottery_text {
  334. color: #ffffff;
  335. height: 60rpx;
  336. font-size: 28rpx;
  337. line-height: 60rpx;
  338. }
  339. }
  340. }
  341. }
  342. .clockin_box {
  343. z-index: 9;
  344. display: block;
  345. width: 700rpx;
  346. margin: 0rpx auto;
  347. position: relative;
  348. border-radius: 40rpx;
  349. background-color: #ffffff;
  350. box-shadow: 5rpx 5rpx 2rpx 0rpx #dddddd;
  351. .box_title {
  352. height: 80rpx;
  353. color: #999999;
  354. text-align: center;
  355. line-height: 80rpx;
  356. .left_icon {
  357. float: left;
  358. padding-left: 20rpx;
  359. }
  360. .right_icon {
  361. float: right;
  362. padding-right: 20rpx;
  363. }
  364. }
  365. .clockin_list {
  366. display: block;
  367. overflow: hidden;
  368. width: 100%;
  369. padding-top: 25rpx;
  370. .clockin_item {
  371. float: left;
  372. position: relative;
  373. width: 70rpx;
  374. height: 165rpx;
  375. text-align: center;
  376. margin-left: 25rpx;
  377. border-radius: 20rpx;
  378. margin-bottom: 20rpx;
  379. background-color: #f8f8f8;
  380. .what_day {
  381. display: block;
  382. height: 40rpx;
  383. font-size: 24rpx;
  384. line-height: 60rpx;
  385. }
  386. .score_one {
  387. display: block;
  388. height: 60rpx;
  389. margin: 10rpx auto;
  390. position: relative;
  391. .score_icon {
  392. display: block;
  393. width: 60rpx;
  394. height: 60rpx;
  395. margin: 0rpx auto;
  396. }
  397. }
  398. .score_tow {
  399. display: block;
  400. height: 80rpx;
  401. margin: 10rpx auto;
  402. position: relative;
  403. .score_icon {
  404. display: block;
  405. width: 80rpx;
  406. height: 80rpx;
  407. margin: 0rpx auto;
  408. }
  409. .score_icon:nth-child(1) {
  410. top: 0rpx;
  411. left: 10rpx;
  412. width: 80rpx;
  413. height: 80rpx;
  414. position: absolute;
  415. }
  416. .score_icon:nth-child(2) {
  417. top: 0rpx;
  418. left: 55rpx;
  419. width: 80rpx;
  420. height: 80rpx;
  421. position: absolute;
  422. }
  423. }
  424. .score_the {
  425. width: 200rpx;
  426. display: block;
  427. height: 100rpx;
  428. margin: 10rpx auto;
  429. position: relative;
  430. .score_icon {
  431. display: block;
  432. width: 80rpx;
  433. height: 80rpx;
  434. margin: 0rpx auto;
  435. }
  436. .score_icon:nth-child(1) {
  437. top: 15rpx;
  438. left: 20rpx;
  439. width: 80rpx;
  440. height: 80rpx;
  441. position: absolute;
  442. }
  443. .score_icon:nth-child(2) {
  444. top: 15rpx;
  445. left: 95rpx;
  446. width: 80rpx;
  447. height: 80rpx;
  448. position: absolute;
  449. }
  450. .score_icon:nth-child(3) {
  451. top: 0rpx;
  452. left: 60rpx;
  453. width: 80rpx;
  454. height: 80rpx;
  455. position: absolute;
  456. }
  457. }
  458. .give_score {
  459. display: block;
  460. height: 30rpx;
  461. font-size: 24rpx;
  462. line-height: 40rpx;
  463. }
  464. .give_coupon {
  465. position: absolute;
  466. font-size: 20rpx;
  467. padding: 2px 5px;
  468. background-color: #f00;
  469. color: #fff;
  470. border-radius: 6px;
  471. display: inline-block;
  472. text-align: center;
  473. right: -15rpx;
  474. top: -15rpx;
  475. }
  476. }
  477. /*.clockin_item:nth-child(7){
  478. width: 315rpx;
  479. }*/
  480. .clockin_item.acitve {
  481. color: #ffffff;
  482. background-color: #f89c33;
  483. }
  484. }
  485. .clockin_btn {
  486. width: 660rpx;
  487. color: #ffffff;
  488. font-size: 30rpx;
  489. margin-top: 20rpx;
  490. padding: 0rpx 0rpx;
  491. border-radius: 60rpx;
  492. background-color: #f89c33;
  493. border: 0rpx solid transparent;
  494. }
  495. .clockin_btn.active {
  496. color: #ffffff;
  497. background-color: #aaaaaa;
  498. }
  499. .clockin_btn::after {
  500. border: 0rpx solid transparent;
  501. }
  502. .score_record {
  503. height: 60rpx;
  504. display: block;
  505. color: #999999;
  506. font-size: 24rpx;
  507. margin-top: 20rpx;
  508. text-align: center;
  509. line-height: 80rpx;
  510. }
  511. .clockin_rule_btn {
  512. color: #999999;
  513. overflow: hidden;
  514. font-size: 24rpx;
  515. text-align: center;
  516. line-height: 80rpx;
  517. padding: 0rpx 0rpx;
  518. background: transparent;
  519. }
  520. .clockin_rule_btn::after {
  521. border: 0rpx solid transparent;
  522. }
  523. }
  524. }
  525. .popup {
  526. overflow: hidden;
  527. }
  528. .clockin_rule_box {
  529. width: 500rpx;
  530. display: block;
  531. overflow: hidden;
  532. background: #ffffff;
  533. font-size: 26rpx;
  534. margin: 0rpx auto;
  535. line-height: 50rpx;
  536. border-radius: 10rpx;
  537. padding: 0rpx 25rpx;
  538. padding-bottom: 20rpx;
  539. background: linear-gradient(to bottom, #fc335f 0%, #fb7224 100%);
  540. .clockin_rule_title {
  541. color: #ffffff;
  542. height: 60rpx;
  543. font-size: 32rpx;
  544. line-height: 60rpx;
  545. text-align: center;
  546. margin-bottom: 10rpx;
  547. .close_btn {
  548. float: right;
  549. width: 40rpx;
  550. height: 40rpx;
  551. font-size: 24rpx;
  552. margin-top: 9rpx;
  553. line-height: 40rpx;
  554. border-radius: 50%;
  555. border: 1rpx solid #ffffff;
  556. }
  557. }
  558. .clockin_rule_info {
  559. display: block;
  560. height: 500rpx;
  561. font-size: 24rpx;
  562. line-height: 40rpx;
  563. border-radius: 10rpx;
  564. padding: 20rpx 20rpx;
  565. box-sizing: border-box;
  566. background-color: #ffffff;
  567. .rich_text {
  568. white-space: break-spaces;
  569. }
  570. }
  571. }
  572. </style>