clockin.vue 10 KB

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