clockin.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  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"
  19. src="https://mall.findit.ltd/uploads/images/default/lottery_record.png" mode=""></image>
  20. <view class="lottery_text">点我抽奖</view>
  21. </navigator>
  22. </view>
  23. </view>
  24. <view class="clockin_box" v-if="clockinList.length > 0">
  25. <view class="box_title">
  26. <view class="left_icon" v-if="(this.listKey>0)" @click="leftClockin()"><uni-icons type="left"
  27. size="20"></uni-icons></view>
  28. {{isMark.finish_day?'已连续签到 '+isMark.finish_day+' 天':'连续签到奖励更丰厚'}}
  29. <view class="right_icon" v-if="(this.listKey<(this.listLength-1))" @click="rightClockin()">
  30. <uni-icons type="right" size="20"></uni-icons></view>
  31. </view>
  32. <view class="clockin_list">
  33. <view class="clockin_item" :class="item.is_finish?'acitve':''"
  34. 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="../../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="../../static/icon/score.png" mode=""></image>
  42. <image class="score_icon" src="../../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':''"
  48. @click="toClockin()">{{isMark.is_clockin?'已签到':'签到'}}</button>
  49. <navigator url="/pages/score/record" class="score_record">积分记录 &gt;</navigator>
  50. </view>
  51. <view class="clockin_box" v-else>
  52. <view class="box_title">
  53. 暂无签到活动
  54. </view>
  55. <navigator url="/pages/score/record" class="score_record">积分记录 &gt;</navigator>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. export default {
  62. data() {
  63. return {
  64. status_bar_style: {},
  65. clockinList: [],
  66. isMark: {
  67. finish_day: 0,
  68. is_clockin: 0,
  69. },
  70. scoreInfo: {
  71. score: 0,
  72. use_score: 0,
  73. wait_score: 0,
  74. },
  75. isReqing: false,
  76. listKey: 0,
  77. listLength: 0,
  78. active_id: 0,
  79. }
  80. },
  81. onLoad() {
  82. // #ifdef MP-WEIXIN
  83. let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
  84. this.status_bar_style = {
  85. height: (menuButtonInfo.height) + "px",
  86. "padding-top": menuButtonInfo.top + "px"
  87. };
  88. // #endif
  89. // #ifdef MP-WEIXIN
  90. //分享按钮
  91. uni.showShareMenu({
  92. withShareTicket: true,
  93. menus: ['shareAppMessage', 'shareTimeline']
  94. })
  95. // #endif
  96. },
  97. onShareAppMessage(obj) {
  98. // 获取分享信息
  99. let shareList = getApp().globalData.shareList;
  100. // 获取分享信息
  101. let shareObj = {
  102. title: '药优惠 得积分 兑豪礼',
  103. path: '/pages/score/clockin',
  104. imageUrl:'',
  105. };
  106. // 循环列表
  107. for ( let i in shareList ) {
  108. if( shareList[i].pages == 'pages/score/clockin' ) {
  109. shareObj.path = shareList[i].path ? shareList[i].path : shareObj.path ;
  110. shareObj.title = shareList[i].title ? shareList[i].title : shareObj.title ;
  111. shareObj.imageUrl = shareList[i].image_url ? shareList[i].image_url : shareObj.imageUrl ;
  112. }
  113. }
  114. // 返回分享信息
  115. return shareObj;
  116. },
  117. onShow() {
  118. // 登录提示
  119. if (!this.$checkAccess.alterLogin()) return;
  120. // 请求打卡列表
  121. this.getClockinList();
  122. // 请求中,不允许刷新
  123. if (this.isReqing) return;
  124. // 设置请求中
  125. this.isReqing = true;
  126. // 请求列表
  127. this.$http.request('/api/custom_score/get_info', this.requestParam).then((re) => {
  128. // 设置非请求中
  129. this.isReqing = false;
  130. // 成功结果
  131. if (re.code == 'success') {
  132. this.scoreInfo = re.data;
  133. }
  134. });
  135. },
  136. methods: {
  137. toClockin() {
  138. // 如果已经打卡
  139. if (this.isMark.is_clockin) return;
  140. // 登录提示
  141. if (!this.$checkAccess.alterLogin()) return;
  142. if (this.active_id === 0) {
  143. uni.showToast({
  144. title: '暂无活动',
  145. icon: "none"
  146. });
  147. }
  148. // 请求中,不允许刷新
  149. if (this.isReqing) return;
  150. // 设置请求中
  151. this.isReqing = true;
  152. // 请求列表
  153. this.$http.request('api/score_clockin/finish', {
  154. 'active_id': this.active_id
  155. }, 'post').then((re) => {
  156. // 设置非请求中
  157. this.isReqing = false;
  158. // 成功结果
  159. if (re.code == 'success') {
  160. // 赋值
  161. this.isMark = re.data;
  162. // 积分更新
  163. this.scoreInfo.score = re.data.reward + this.scoreInfo.score;
  164. // 更新打卡
  165. for (let i in this.clockinList[this.listKey]) {
  166. // 如果小于等于连续打卡天数,设置为打卡
  167. if (this.clockinList[this.listKey][i].what_day <= this.isMark.finish_day) this.clockinList[this.listKey][i].is_finish = 1;
  168. }
  169. } else {
  170. uni.showToast({
  171. title: '打卡失败',
  172. icon: "none"
  173. })
  174. }
  175. });
  176. },
  177. getClockinList() {
  178. // 请求列表
  179. this.$http.request('api/score_clockin/get_list', this.requestParam).then((re) => {
  180. // 成功结果
  181. if (re.code == 'success') {
  182. // 赋值
  183. this.clockinList = re.data.list;
  184. this.listLength = this.clockinList.length;
  185. this.active_id = re.data.active_id;
  186. // 赋值
  187. this.isMark = re.data.is_mark;
  188. }
  189. });
  190. },
  191. leftClockin() {
  192. if (this.listKey > 0) {
  193. this.listKey = this.listKey - 1
  194. }
  195. },
  196. rightClockin() {
  197. this.listKey = this.listKey + 1
  198. }
  199. }
  200. }
  201. </script>
  202. <style lang="less">
  203. page {
  204. background-color: #FFFFFF;
  205. }
  206. .main_view {
  207. display: block;
  208. height: 1000rpx;
  209. background: linear-gradient(to bottom, #FC335F 0%, #FB7224 50%, #FFFFFF 100%);
  210. .status_bar {
  211. width: 100%;
  212. height: 64rpx;
  213. display: block;
  214. padding-top: var(--status-bar-height);
  215. }
  216. .info_box {
  217. display: block;
  218. overflow: hidden;
  219. .left_box {
  220. float: left;
  221. width: 450rpx;
  222. .score_info {
  223. color: #FFFFFF;
  224. overflow: hidden;
  225. padding: 0rpx 35rpx;
  226. .score_title {
  227. width: 240rpx;
  228. height: 60rpx;
  229. display: block;
  230. font-size: 26rpx;
  231. line-height: 60rpx;
  232. }
  233. .score_current {
  234. width: 240rpx;
  235. height: 80rpx;
  236. display: block;
  237. font-size: 66rpx;
  238. line-height: 80rpx;
  239. }
  240. }
  241. .wait_info {
  242. color: #FFFFFF;
  243. display: block;
  244. overflow: hidden;
  245. padding: 0rpx 35rpx;
  246. margin-top: 20rpx;
  247. .wait_title {
  248. width: 240rpx;
  249. height: 40rpx;
  250. display: block;
  251. font-size: 24rpx;
  252. line-height: 40rpx;
  253. }
  254. .wait_score {
  255. width: 240rpx;
  256. height: 60rpx;
  257. display: block;
  258. font-size: 36rpx;
  259. line-height: 60rpx;
  260. }
  261. }
  262. }
  263. .right_box {
  264. float: right;
  265. overflow: hidden;
  266. margin-top: 60rpx;
  267. margin-right: 35rpx;
  268. .lottery_enter {
  269. display: block;
  270. overflow: hidden;
  271. text-align: center;
  272. .lottery_img {
  273. width: 150rpx;
  274. height: 150rpx;
  275. display: block;
  276. margin: 0 auto;
  277. }
  278. .lottery_text {
  279. color: #FFFFFF;
  280. height: 60rpx;
  281. font-size: 28rpx;
  282. line-height: 60rpx;
  283. }
  284. }
  285. }
  286. }
  287. .clockin_box {
  288. z-index: 9;
  289. display: block;
  290. width: 700rpx;
  291. margin: 0rpx auto;
  292. position: relative;
  293. border-radius: 40rpx;
  294. background-color: #FFFFFF;
  295. box-shadow: 5rpx 5rpx 2rpx 0rpx #DDDDDD;
  296. .box_title {
  297. height: 80rpx;
  298. color: #999999;
  299. text-align: center;
  300. line-height: 80rpx;
  301. .left_icon {
  302. float: left;
  303. padding-left: 20rpx;
  304. }
  305. .right_icon {
  306. float: right;
  307. padding-right: 20rpx;
  308. }
  309. }
  310. .clockin_list {
  311. display: block;
  312. overflow: hidden;
  313. width: 100%;
  314. padding-top: 25rpx;
  315. .clockin_item {
  316. float: left;
  317. position: relative;
  318. width: 70rpx;
  319. height: 165rpx;
  320. text-align: center;
  321. margin-left: 25rpx;
  322. border-radius: 20rpx;
  323. margin-bottom: 20rpx;
  324. background-color: #F8F8F8;
  325. .what_day {
  326. display: block;
  327. height: 40rpx;
  328. font-size: 24rpx;
  329. line-height: 60rpx;
  330. }
  331. .score_one {
  332. display: block;
  333. height: 60rpx;
  334. margin: 10rpx auto;
  335. position: relative;
  336. .score_icon {
  337. display: block;
  338. width: 60rpx;
  339. height: 60rpx;
  340. margin: 0rpx auto;
  341. }
  342. }
  343. .score_tow {
  344. display: block;
  345. height: 80rpx;
  346. margin: 10rpx auto;
  347. position: relative;
  348. .score_icon {
  349. display: block;
  350. width: 80rpx;
  351. height: 80rpx;
  352. margin: 0rpx auto;
  353. }
  354. .score_icon:nth-child(1) {
  355. top: 0rpx;
  356. left: 10rpx;
  357. width: 80rpx;
  358. height: 80rpx;
  359. position: absolute;
  360. }
  361. .score_icon:nth-child(2) {
  362. top: 0rpx;
  363. left: 55rpx;
  364. width: 80rpx;
  365. height: 80rpx;
  366. position: absolute;
  367. }
  368. }
  369. .score_the {
  370. width: 200rpx;
  371. display: block;
  372. height: 100rpx;
  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: 15rpx;
  383. left: 20rpx;
  384. width: 80rpx;
  385. height: 80rpx;
  386. position: absolute;
  387. }
  388. .score_icon:nth-child(2) {
  389. top: 15rpx;
  390. left: 95rpx;
  391. width: 80rpx;
  392. height: 80rpx;
  393. position: absolute;
  394. }
  395. .score_icon:nth-child(3) {
  396. top: 0rpx;
  397. left: 60rpx;
  398. width: 80rpx;
  399. height: 80rpx;
  400. position: absolute;
  401. }
  402. }
  403. .give_score {
  404. display: block;
  405. height: 30rpx;
  406. font-size: 24rpx;
  407. line-height: 40rpx;
  408. }
  409. .give_coupon {
  410. position: absolute;
  411. font-size: 20rpx;
  412. padding: 2px 5px;
  413. background-color: #f00;
  414. color: #fff;
  415. border-radius: 6px;
  416. display: inline-block;
  417. text-align: center;
  418. right: -15rpx;
  419. top: -15rpx;
  420. }
  421. }
  422. /*.clockin_item:nth-child(7){
  423. width: 315rpx;
  424. }*/
  425. .clockin_item.acitve {
  426. color: #FFFFFF;
  427. background-color: #E03519;
  428. }
  429. }
  430. .clockin_btn {
  431. width: 660rpx;
  432. color: #FFFFFF;
  433. font-size: 30rpx;
  434. margin-top: 20rpx;
  435. padding: 0rpx 0rpx;
  436. border-radius: 60rpx;
  437. background-color: #E03519;
  438. border: 0rpx solid transparent;
  439. }
  440. .clockin_btn.active {
  441. color: #FFFFFF;
  442. background-color: #AAAAAA;
  443. }
  444. .clockin_btn::after {
  445. border: 0rpx solid transparent;
  446. }
  447. .score_record {
  448. height: 60rpx;
  449. display: block;
  450. color: #999999;
  451. font-size: 24rpx;
  452. margin-top: 20rpx;
  453. text-align: center;
  454. line-height: 80rpx;
  455. }
  456. }
  457. }
  458. </style>