clockin.vue 15 KB

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