clockin.vue 9.1 KB

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