clockin.vue 15 KB

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