clockin.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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. onShow() {
  84. // 请求打卡列表
  85. this.getClockinList();
  86. // 登录提示
  87. if( !this.$checkAccess.alterLogin() ) return ;
  88. // 请求中,不允许刷新
  89. if( this.isReqing ) return ;
  90. // 设置请求中
  91. this.isReqing = true;
  92. // 请求列表
  93. this.$http.request('/api/custom_score/get_info',this.requestParam).then((re)=>{
  94. // 设置非请求中
  95. this.isReqing = false;
  96. // 成功结果
  97. if( re.code == 'success' ){
  98. this.scoreInfo = re.data;
  99. }
  100. });
  101. },
  102. methods: {
  103. toClockin(){
  104. // 如果已经打卡
  105. if( this.isMark.is_clockin ) return ;
  106. // 登录提示
  107. if( !this.$checkAccess.alterLogin() ) return ;
  108. // 请求中,不允许刷新
  109. if( this.isReqing ) return ;
  110. // 设置请求中
  111. this.isReqing = true;
  112. // 请求列表
  113. this.$http.request('api/score_clockin/finish',{},'post').then((re)=>{
  114. // 设置非请求中
  115. this.isReqing = false;
  116. // 成功结果
  117. if( re.code == 'success' ){
  118. // 赋值
  119. this.isMark = re.data;
  120. // 积分更新
  121. this.scoreInfo.score = re.data.reward + this.scoreInfo.score;
  122. // 更新打卡
  123. for (let i in this.clockinList) {
  124. // 如果小于等于连续打卡天数,设置为打卡
  125. if(this.clockinList[i].what_day <= this.isMark.finish_day ) this.clockinList[i].is_finish = 1;
  126. }
  127. }
  128. });
  129. },
  130. getClockinList(){
  131. // 请求列表
  132. this.$http.request('api/score_clockin/get_list',this.requestParam).then((re)=>{
  133. // 成功结果
  134. if( re.code == 'success' ) {
  135. // 赋值
  136. this.clockinList= re.data.list;
  137. // 赋值
  138. this.isMark = re.data.is_mark;
  139. }
  140. });
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="less">
  146. page{
  147. background-color: #FFFFFF;
  148. }
  149. .main_view{
  150. display: block;
  151. height: 1000rpx;
  152. background: linear-gradient(to bottom, #FC335F 0%, #FB7224 50%, #FFFFFF 100%);
  153. .status_bar {
  154. width: 100%;
  155. height: 64rpx;
  156. display: block;
  157. padding-top: var(--status-bar-height);
  158. }
  159. .info_box{
  160. display: block;
  161. overflow: hidden;
  162. .left_box{
  163. float: left;
  164. width: 450rpx;
  165. .finish_box{
  166. color: #FFFFFF;
  167. overflow: hidden;
  168. padding: 0rpx 35rpx;
  169. .finish_title{
  170. width: 240rpx;
  171. height: 60rpx;
  172. display: block;
  173. font-size: 26rpx;
  174. line-height: 60rpx;
  175. }
  176. .finish_day{
  177. width: 240rpx;
  178. height: 80rpx;
  179. display: block;
  180. font-size: 66rpx;
  181. line-height: 80rpx;
  182. }
  183. }
  184. .score_box{
  185. color: #FFFFFF;
  186. margin-top: 40rpx;
  187. padding: 0rpx 35rpx;
  188. overflow: hidden;
  189. .score_title{
  190. height: 40rpx;
  191. display: block;
  192. font-size: 26rpx;
  193. line-height: 40rpx;
  194. overflow: hidden;
  195. .title_item{
  196. float: left;
  197. width: 190rpx;
  198. }
  199. }
  200. .score{
  201. height: 80rpx;
  202. display: block;
  203. font-size: 26rpx;
  204. line-height: 60rpx;
  205. .score_item{
  206. float: left;
  207. width: 190rpx;
  208. }
  209. }
  210. }
  211. }
  212. .right_box{
  213. float: right;
  214. width: 300rpx;
  215. margin-top: 100rpx;
  216. .score_icon{
  217. width: 300rpx;
  218. height: 300rpx;
  219. }
  220. }
  221. }
  222. .clockin_box{
  223. z-index: 9;
  224. display: block;
  225. width: 700rpx;
  226. height: 800rpx;
  227. margin: 0rpx auto;
  228. position: relative;
  229. margin-top: -80rpx;
  230. border-radius: 40rpx;
  231. background-color: #FFFFFF;
  232. box-shadow: 5rpx 5rpx 2rpx 0rpx #DDDDDD;
  233. .box_title{
  234. height: 80rpx;
  235. color: #999999;
  236. text-align: center;
  237. line-height: 80rpx;
  238. }
  239. .clockin_list{
  240. display: block;
  241. overflow: hidden;
  242. .clockin_item{
  243. float: left;
  244. width: 145rpx;
  245. height: 240rpx;
  246. text-align: center;
  247. margin-left: 25rpx;
  248. border-radius: 20rpx;
  249. margin-bottom: 20rpx;
  250. background-color: #F8F8F8;
  251. .what_day{
  252. display: block;
  253. height: 60rpx;
  254. font-size: 24rpx;
  255. line-height: 60rpx;
  256. }
  257. .score_one{
  258. display: block;
  259. height: 80rpx;
  260. margin: 10rpx auto;
  261. position: relative;
  262. .score_icon{
  263. display: block;
  264. width: 80rpx;
  265. height: 80rpx;
  266. margin: 0rpx auto;
  267. }
  268. }
  269. .score_tow{
  270. display: block;
  271. height: 80rpx;
  272. margin: 10rpx auto;
  273. position: relative;
  274. .score_icon{
  275. display: block;
  276. width: 80rpx;
  277. height: 80rpx;
  278. margin: 0rpx auto;
  279. }
  280. .score_icon:nth-child(1){
  281. top: 0rpx;
  282. left: 10rpx;
  283. width: 80rpx;
  284. height: 80rpx;
  285. position: absolute;
  286. }
  287. .score_icon:nth-child(2){
  288. top: 0rpx;
  289. left: 55rpx;
  290. width: 80rpx;
  291. height: 80rpx;
  292. position: absolute;
  293. }
  294. }
  295. .score_the{
  296. width: 200rpx;
  297. display: block;
  298. height: 100rpx;
  299. margin: 10rpx auto;
  300. position: relative;
  301. .score_icon{
  302. display: block;
  303. width: 80rpx;
  304. height: 80rpx;
  305. margin: 0rpx auto;
  306. }
  307. .score_icon:nth-child(1){
  308. top: 15rpx;
  309. left: 20rpx;
  310. width: 80rpx;
  311. height: 80rpx;
  312. position: absolute;
  313. }
  314. .score_icon:nth-child(2){
  315. top: 15rpx;
  316. left: 95rpx;
  317. width: 80rpx;
  318. height: 80rpx;
  319. position: absolute;
  320. }
  321. .score_icon:nth-child(3){
  322. top: 0rpx;
  323. left: 60rpx;
  324. width: 80rpx;
  325. height: 80rpx;
  326. position: absolute;
  327. }
  328. }
  329. .give_score{
  330. display: block;
  331. height: 60rpx;
  332. font-size: 24rpx;
  333. line-height: 60rpx;
  334. }
  335. }
  336. .clockin_item:nth-child(7){
  337. width: 315rpx;
  338. }
  339. .clockin_item.acitve{
  340. color: #FFFFFF;
  341. background-color: #E03519;
  342. }
  343. }
  344. .clockin_btn{
  345. width: 660rpx;
  346. color: #FFFFFF;
  347. font-size: 30rpx;
  348. margin: 0rpx auto;
  349. padding: 0rpx 0rpx;
  350. border-radius: 60rpx;
  351. background-color: #E03519;
  352. border: 0rpx solid transparent;
  353. }
  354. .clockin_btn.active{
  355. color: #FFFFFF;
  356. background-color: #AAAAAA;
  357. }
  358. .clockin_btn::after{
  359. border: 0rpx solid transparent;
  360. }
  361. .score_record{
  362. height: 80rpx;
  363. display: block;
  364. color: #999999;
  365. font-size: 24rpx;
  366. margin-top: 30rpx;
  367. text-align: center;
  368. line-height: 80rpx;
  369. }
  370. }
  371. }
  372. </style>