clockin.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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">
  24. <view class="box_title">{{ isMark.finish_day ? '已连续签到 ' + isMark.finish_day + ' 天' : '连续签到奖励更丰厚' }}</view>
  25. <view class="clockin_list">
  26. <view class="clockin_item" :class="item.is_finish ? 'acitve' : ''" v-for="(item, index) in clockinList" :key="index">
  27. <view class="what_day">第{{ item.what_day }}天</view>
  28. <view class="score_one" v-if="index == 0 || index == 1 || index == 3 || index == 5">
  29. <image class="score_icon" src="../../static/icon/score.png" mode=""></image>
  30. </view>
  31. <view class="score_tow" v-if="index == 2 || index == 4">
  32. <image class="score_icon" src="../../static/icon/score.png" mode=""></image>
  33. <image class="score_icon" src="../../static/icon/score.png" mode=""></image>
  34. </view>
  35. <view class="score_the" v-if="index == 6">
  36. <image class="score_icon" src="../../static/icon/score.png" mode=""></image>
  37. <image class="score_icon" src="../../static/icon/score.png" mode=""></image>
  38. <image class="score_icon" src="../../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. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. data() {
  52. return {
  53. status_bar_style: {},
  54. clockinList: [],
  55. isMark: {
  56. finish_day: 0,
  57. is_clockin: 0
  58. },
  59. scoreInfo: {
  60. score: 0,
  61. use_score: 0,
  62. wait_score: 0
  63. },
  64. isReqing: false
  65. };
  66. },
  67. onLoad() {
  68. // #ifdef MP-WEIXIN
  69. let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
  70. this.status_bar_style = { height: menuButtonInfo.height + 'px', 'padding-top': menuButtonInfo.top + 'px' };
  71. // #endif
  72. // #ifdef MP-WEIXIN
  73. //分享按钮
  74. uni.showShareMenu({
  75. withShareTicket: true,
  76. menus: ['shareAppMessage', 'shareTimeline']
  77. });
  78. // #endif
  79. },
  80. onShareAppMessage(obj) {
  81. return {
  82. title: '双十一 药优惠 得积分 兑豪礼',
  83. path: '/pages/index/index'
  84. };
  85. },
  86. onShow() {
  87. // 请求打卡列表
  88. this.getClockinList();
  89. // 登录提示
  90. if (!this.$checkAccess.onlyCheckAccess()) return;
  91. // 请求中,不允许刷新
  92. if (this.isReqing) return;
  93. // 设置请求中
  94. this.isReqing = true;
  95. // 请求列表
  96. this.$http.request('/api/custom_score/get_info', this.requestParam).then((re) => {
  97. // 设置非请求中
  98. this.isReqing = false;
  99. // 成功结果
  100. if (re.code == 'success') {
  101. this.scoreInfo = re.data;
  102. }
  103. });
  104. },
  105. methods: {
  106. toClockin() {
  107. // 如果已经打卡
  108. if (this.isMark.is_clockin) return;
  109. // 登录提示
  110. if (!this.$checkAccess.alterLogin()) return;
  111. // 请求中,不允许刷新
  112. if (this.isReqing) return;
  113. // 设置请求中
  114. this.isReqing = true;
  115. // 请求列表
  116. this.$http.request('api/score_clockin/finish', {}, 'post').then((re) => {
  117. // 设置非请求中
  118. this.isReqing = false;
  119. // 成功结果
  120. if (re.code == 'success') {
  121. // 赋值
  122. this.isMark = re.data;
  123. // 积分更新
  124. this.scoreInfo.score = re.data.reward + this.scoreInfo.score;
  125. // 更新打卡
  126. for (let i in this.clockinList) {
  127. // 如果小于等于连续打卡天数,设置为打卡
  128. if (this.clockinList[i].what_day <= this.isMark.finish_day) this.clockinList[i].is_finish = 1;
  129. }
  130. }
  131. });
  132. },
  133. getClockinList() {
  134. // 请求列表
  135. this.$http.request('api/score_clockin/get_list', this.requestParam).then((re) => {
  136. // 成功结果
  137. if (re.code == 'success') {
  138. // 赋值
  139. this.clockinList = re.data.list;
  140. // 赋值
  141. this.isMark = re.data.is_mark;
  142. }
  143. });
  144. }
  145. }
  146. };
  147. </script>
  148. <style lang="less">
  149. page {
  150. background-color: #ffffff;
  151. }
  152. .main_view {
  153. display: block;
  154. height: 1000rpx;
  155. background: linear-gradient(to bottom, #fc335f 0%, #fb7224 50%, #ffffff 100%);
  156. .status_bar {
  157. width: 100%;
  158. height: 64rpx;
  159. display: block;
  160. padding-top: var(--status-bar-height);
  161. }
  162. .info_box {
  163. display: block;
  164. overflow: hidden;
  165. .left_box {
  166. float: left;
  167. width: 450rpx;
  168. .score_info {
  169. color: #ffffff;
  170. overflow: hidden;
  171. padding: 0rpx 35rpx;
  172. .score_title {
  173. width: 240rpx;
  174. height: 60rpx;
  175. display: block;
  176. font-size: 26rpx;
  177. line-height: 60rpx;
  178. }
  179. .score_current {
  180. width: 240rpx;
  181. height: 80rpx;
  182. display: block;
  183. font-size: 66rpx;
  184. line-height: 80rpx;
  185. }
  186. }
  187. .wait_info {
  188. color: #ffffff;
  189. display: block;
  190. overflow: hidden;
  191. padding: 0rpx 35rpx;
  192. margin-top: 20rpx;
  193. .wait_title {
  194. width: 240rpx;
  195. height: 40rpx;
  196. display: block;
  197. font-size: 24rpx;
  198. line-height: 40rpx;
  199. }
  200. .wait_score {
  201. width: 240rpx;
  202. height: 60rpx;
  203. display: block;
  204. font-size: 36rpx;
  205. line-height: 60rpx;
  206. }
  207. }
  208. }
  209. .right_box {
  210. float: right;
  211. overflow: hidden;
  212. margin-top: 60rpx;
  213. margin-right: 35rpx;
  214. .lottery_enter {
  215. display: block;
  216. overflow: hidden;
  217. text-align: center;
  218. .lottery_img {
  219. width: 150rpx;
  220. height: 150rpx;
  221. display: block;
  222. margin: 0 auto;
  223. }
  224. .lottery_text {
  225. color: #ffffff;
  226. height: 60rpx;
  227. font-size: 28rpx;
  228. line-height: 60rpx;
  229. }
  230. }
  231. }
  232. }
  233. .clockin_box {
  234. z-index: 9;
  235. display: block;
  236. width: 700rpx;
  237. height: 800rpx;
  238. margin: 0rpx auto;
  239. position: relative;
  240. border-radius: 40rpx;
  241. background-color: #ffffff;
  242. box-shadow: 5rpx 5rpx 2rpx 0rpx #dddddd;
  243. .box_title {
  244. height: 80rpx;
  245. color: #999999;
  246. text-align: center;
  247. line-height: 80rpx;
  248. }
  249. .clockin_list {
  250. display: block;
  251. overflow: hidden;
  252. .clockin_item {
  253. float: left;
  254. width: 145rpx;
  255. height: 240rpx;
  256. text-align: center;
  257. margin-left: 25rpx;
  258. border-radius: 20rpx;
  259. margin-bottom: 20rpx;
  260. background-color: #f8f8f8;
  261. .what_day {
  262. display: block;
  263. height: 60rpx;
  264. font-size: 24rpx;
  265. line-height: 60rpx;
  266. }
  267. .score_one {
  268. display: block;
  269. height: 80rpx;
  270. margin: 10rpx auto;
  271. position: relative;
  272. .score_icon {
  273. display: block;
  274. width: 80rpx;
  275. height: 80rpx;
  276. margin: 0rpx auto;
  277. }
  278. }
  279. .score_tow {
  280. display: block;
  281. height: 80rpx;
  282. margin: 10rpx auto;
  283. position: relative;
  284. .score_icon {
  285. display: block;
  286. width: 80rpx;
  287. height: 80rpx;
  288. margin: 0rpx auto;
  289. }
  290. .score_icon:nth-child(1) {
  291. top: 0rpx;
  292. left: 10rpx;
  293. width: 80rpx;
  294. height: 80rpx;
  295. position: absolute;
  296. }
  297. .score_icon:nth-child(2) {
  298. top: 0rpx;
  299. left: 55rpx;
  300. width: 80rpx;
  301. height: 80rpx;
  302. position: absolute;
  303. }
  304. }
  305. .score_the {
  306. width: 200rpx;
  307. display: block;
  308. height: 100rpx;
  309. margin: 10rpx auto;
  310. position: relative;
  311. .score_icon {
  312. display: block;
  313. width: 80rpx;
  314. height: 80rpx;
  315. margin: 0rpx auto;
  316. }
  317. .score_icon:nth-child(1) {
  318. top: 15rpx;
  319. left: 20rpx;
  320. width: 80rpx;
  321. height: 80rpx;
  322. position: absolute;
  323. }
  324. .score_icon:nth-child(2) {
  325. top: 15rpx;
  326. left: 95rpx;
  327. width: 80rpx;
  328. height: 80rpx;
  329. position: absolute;
  330. }
  331. .score_icon:nth-child(3) {
  332. top: 0rpx;
  333. left: 60rpx;
  334. width: 80rpx;
  335. height: 80rpx;
  336. position: absolute;
  337. }
  338. }
  339. .give_score {
  340. display: block;
  341. height: 60rpx;
  342. font-size: 24rpx;
  343. line-height: 60rpx;
  344. }
  345. }
  346. .clockin_item:nth-child(7) {
  347. width: 315rpx;
  348. }
  349. .clockin_item.acitve {
  350. color: #ffffff;
  351. background-color: #e03519;
  352. }
  353. }
  354. .clockin_btn {
  355. width: 660rpx;
  356. color: #ffffff;
  357. font-size: 30rpx;
  358. margin: 0rpx auto;
  359. padding: 0rpx 0rpx;
  360. border-radius: 60rpx;
  361. background-color: #e03519;
  362. border: 0rpx solid transparent;
  363. }
  364. .clockin_btn.active {
  365. color: #ffffff;
  366. background-color: #aaaaaa;
  367. }
  368. .clockin_btn::after {
  369. border: 0rpx solid transparent;
  370. }
  371. .score_record {
  372. height: 80rpx;
  373. display: block;
  374. color: #999999;
  375. font-size: 24rpx;
  376. margin-top: 30rpx;
  377. text-align: center;
  378. line-height: 80rpx;
  379. }
  380. }
  381. }
  382. </style>