checkIn.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. <template>
  2. <view class="page">
  3. <view class="headers">
  4. <view class="dis a-c j-start">
  5. <u-icon name="arrow-left" size="40" color="#000" @tap="back"></u-icon>
  6. <text style="margin:auto;">签到有礼</text>
  7. </view>
  8. </view>
  9. <view class="content">
  10. <view class="growthValue">
  11. <text>{{growthValue}}</text>
  12. <text>成长值</text>
  13. </view>
  14. <view class="checkIn">
  15. <view class="header dis a-c ">
  16. <text>2024年11月</text>
  17. <image src="../../static/image/index/checkIn-img/checkIn.png" mode=""></image>
  18. </view>
  19. <view class="mockData dis f-c">
  20. <view class="dis a-c j-s labelHeader">
  21. <text>签到日历</text>
  22. <text>连续签到7天后,每天得2成长值</text>
  23. </view>
  24. <view class="dis a-c j-s">
  25. <view class="dis f-c a-c" v-for="(item,index) in checkINList" :key="index">
  26. <text class="dateName">{{item.weekDay}}</text>
  27. <view class="checkInDate"
  28. :style="{background:item.time=='今'?'linear-gradient( 180deg, #FF9345 0%, #FED7A1 100%)':item.time>getdatevalue?'#FFF7D3':item.isMissedSignIn?'#F4F4F4':'#FFF9EC',color:item.time=='今'?'#fff':item.isMissedSignIn?'#C5C5C5':'#F1AA29'}">
  29. <text>{{item.time}}</text>
  30. <image
  31. :src="item.isMissedSignIn?'../../static/image/index/checkIn-img/icon1.png':item.checkInShow?'../../static/image/index/checkIn-img/icon3.png':'../../static/image/index/checkIn-img/icon2.png'"
  32. mode=""></image>
  33. </view>
  34. </view>
  35. </view>
  36. <button type="primary" :disabled="disabled" class="check-btn" :class="{'bg-hover-color':disabled}"
  37. @click="checkbtn">{{disabled?'已签到':'签到'}}
  38. </button>
  39. </view>
  40. </view>
  41. <view class="advertisement">
  42. <text class="title">守护您的健康</text>
  43. <view class="dis a-c j-s textBlock">
  44. <view class="dis a-c j-s">
  45. <image src="../../static/image/index/checkIn-img/frame1.png" mode=""></image>
  46. <view>成年人生活压力大, 健康风险不断攀升</view>
  47. </view>
  48. <view class="dis a-c j-s">
  49. <image src="../../static/image/index/checkIn-img/frame2.png" mode=""></image>
  50. <view>不幸患大病将面临巨 额治疗费与收入损失</view>
  51. </view>
  52. </view>
  53. <view class="insuranceText dis f-c">
  54. <text class="description">配置重疾险,确诊配一大笔钱,治病养病都不愁</text>
  55. <text class="insuranceText-title">健康福 ·重疾险(保1年)</text>
  56. <image class="tag" src="../../static/image/index/checkIn-img/frame3.png" mode=""></image>
  57. <view class="content-block dis f-c">
  58. <view class="dis a-c j-s">
  59. <image src="../../static/image/index/checkIn-img/frame4.png" mode=""></image>
  60. <view class="dis f-c">
  61. <text>最高可赔</text>
  62. <text>50万</text>
  63. </view>
  64. <view class="dis f-c">
  65. <text>疾病保障</text>
  66. <text>180种</text>
  67. </view>
  68. <view class="dis f-c">
  69. <text>赔付方式</text>
  70. <text>确诊赔付</text>
  71. </view>
  72. </view>
  73. <view class="dis a-c j-s mt-2 mb-1">
  74. <view class="dis a-end">
  75. <text>27.0</text>
  76. <text>元起</text>
  77. </view>
  78. <view class="btn dis a-c j-c">
  79. 去看看
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </template>
  88. <script>
  89. export default {
  90. data() {
  91. return {
  92. growthValue: "25",
  93. checkINList: [],
  94. getdatevalue: "",
  95. disabled: false,
  96. }
  97. },
  98. onShow() {},
  99. async onLoad() {
  100. const currentWeekDays = await this.getCurrentWeekDays();
  101. this.checkINList = currentWeekDays;
  102. const today = new Date();
  103. this.getdatevalue = today.getDate();
  104. },
  105. methods: {
  106. checkbtn() {
  107. this.checkINList.map(val => {
  108. if (val.time == '今') {
  109. val.checkInShow = true;
  110. this.disabled = true;
  111. uni.showToast({
  112. icon: 'none',
  113. title: "已签到"
  114. })
  115. }
  116. return val;
  117. })
  118. },
  119. /**
  120. * @param {boolean} checkInShow 是否签到
  121. * @param {boolean} isMissedSignIn 是否漏签
  122. * @param {string} weekDay 日期代名词
  123. */
  124. getCurrentWeekDays() {
  125. const today = new Date();
  126. const checkINList = [{
  127. weekDay: "一",
  128. checkInShow: false,
  129. isMissedSignIn: false,
  130. },
  131. {
  132. weekDay: "二",
  133. checkInShow: false,
  134. isMissedSignIn: false,
  135. },
  136. {
  137. weekDay: "三",
  138. checkInShow: false,
  139. isMissedSignIn: false,
  140. },
  141. {
  142. weekDay: "四",
  143. checkInShow: false,
  144. isMissedSignIn: false,
  145. },
  146. {
  147. weekDay: "五",
  148. checkInShow: false,
  149. isMissedSignIn: false,
  150. },
  151. {
  152. weekDay: "六",
  153. checkInShow: false,
  154. isMissedSignIn: false,
  155. },
  156. {
  157. weekDay: "日",
  158. checkInShow: false,
  159. isMissedSignIn: false,
  160. },
  161. ];
  162. // 获取今天是星期几 (0-6) 其中 0 代表星期日,6 代表星期六
  163. const dayOfWeek = today.getDay();
  164. // 计算今天是本周第几天(将 Sunday 从 0 转为 7,便于计算)
  165. const startOfWeek = dayOfWeek === 0 ? -6 : 1 - dayOfWeek;
  166. // 获取本周的七天
  167. for (let i = 0; i < 7; i++) {
  168. const currentDate = new Date(today);
  169. currentDate.setDate(today.getDate() + startOfWeek + i);
  170. // 检查当前日期是否是今天
  171. if (currentDate.toDateString() === today.toDateString()) {
  172. checkINList[i].time = "今"; // 将今天的 time 替换为 "今天"
  173. } else {
  174. checkINList[i].time = currentDate.getDate(); // 其他日期保持原有
  175. }
  176. }
  177. return checkINList;
  178. },
  179. //页面返回按钮
  180. back() {
  181. uni.navigateBack({
  182. delta: 1, // 返回的页面数,如果是1表示返回上一页
  183. success: function() {}
  184. });
  185. },
  186. }
  187. }
  188. </script>
  189. <style lang="scss" scoped>
  190. .page {
  191. height: 100vh;
  192. background-image: url('/static/image/index/checkIn-img/back.png');
  193. background-size: 100% 100%;
  194. padding: 110px 14px 0;
  195. }
  196. .headers {
  197. position: fixed;
  198. top: 0;
  199. left: 0;
  200. height: auto;
  201. width: 100%;
  202. z-index: 999999;
  203. padding: 50px 16px 14px;
  204. height: auto;
  205. background: transparent;
  206. text {
  207. font-size: 18px;
  208. font-weight: bold;
  209. color: #000;
  210. }
  211. }
  212. .content {
  213. .growthValue {
  214. text:first-child {
  215. color: #63300D;
  216. font-size: 72rpx;
  217. font-weight: bold;
  218. }
  219. text:last-child {
  220. color: #553B22;
  221. font-size: 28rpx;
  222. margin-left: 12rpx;
  223. }
  224. }
  225. .checkIn {
  226. background: linear-gradient(180deg, #FFFBF7 0%, #FEFEFE 100%);
  227. border-radius: 6px;
  228. .header {
  229. height: 72rpx;
  230. background: #FFF6DD;
  231. box-shadow: inset 0px 2px 4px 0px rgba(255, 255, 255, 0.5);
  232. border-radius: 6px 6px 0px 0px;
  233. position: relative;
  234. color: #C68948;
  235. font-size: 14px;
  236. padding: 16rpx 24rpx;
  237. font-weight: bold;
  238. image {
  239. width: 220rpx;
  240. height: 220rpx;
  241. position: absolute;
  242. bottom: 0;
  243. right: 25rpx;
  244. }
  245. }
  246. .mockData {
  247. padding: 20rpx 24rpx;
  248. .labelHeader {
  249. text:first-child {
  250. color: #553B22;
  251. font-size: 32rpx;
  252. font-weight: bold;
  253. }
  254. text:last-child {
  255. color: #553B22;
  256. font-size: 22rpx;
  257. }
  258. }
  259. .dateName {
  260. color: #B3B4B5;
  261. font-size: 32rpx;
  262. }
  263. .checkInDate {
  264. width: 77rpx;
  265. border-radius: 10px;
  266. margin-top: 18rpx;
  267. position: relative;
  268. padding: 20rpx 20rpx 60rpx;
  269. font-size: 32rpx;
  270. font-weight: bold;
  271. image {
  272. width: 60rpx;
  273. height: 60rpx;
  274. position: absolute;
  275. left: 0;
  276. right: 0;
  277. bottom: -30rpx;
  278. margin: auto;
  279. }
  280. }
  281. .check-btn {
  282. width: 412rpx;
  283. height: 76rpx;
  284. background: linear-gradient(90deg, #FFDBAF 0%, #F9C88E 100%);
  285. border-radius: 56rpx;
  286. margin: 68rpx auto 0;
  287. color: #553B22;
  288. font-size: 32rpx;
  289. font-weight: bold;
  290. }
  291. .bg-hover-color {
  292. opacity: 0.7;
  293. }
  294. }
  295. }
  296. .advertisement {
  297. background: linear-gradient(180deg, #FFF9E8 0%, #FEFEFE 100%);
  298. border-radius: 6px;
  299. padding: 25rpx;
  300. margin-top: 32rpx;
  301. .title {
  302. color: #553B22;
  303. font-size: 32rpx;
  304. font-weight: bold;
  305. }
  306. .textBlock {
  307. >view {
  308. width: 50%;
  309. padding: 24rpx;
  310. image {
  311. width: 40rpx;
  312. height: 40rpx;
  313. }
  314. view {
  315. width: 75%;
  316. color: #A17352;
  317. font-size: 20rpx;
  318. }
  319. }
  320. }
  321. .insuranceText {
  322. background: linear-gradient(150deg, #FFE3C0 0%, #FFEFC4 100%);
  323. border-radius: 10px;
  324. padding: 24rpx 24rpx 0;
  325. .description {
  326. color: #CE7711;
  327. font-size: 22rpx;
  328. }
  329. .insuranceText-title {
  330. color: #553B22;
  331. font-size: 28rpx;
  332. font-weight: bold;
  333. }
  334. .tag {
  335. width: 340rpx;
  336. height: 47rpx;
  337. margin-left: -30rpx;
  338. }
  339. .content-block {
  340. padding-top: 10px;
  341. >view:first-child {
  342. padding-right: 20px;
  343. image {
  344. width: 100rpx;
  345. height: 100rpx;
  346. }
  347. view {
  348. text:first-child {
  349. color: #A47210;
  350. font-size: 20rpx;
  351. }
  352. text:last-child {
  353. color: #A47210;
  354. font-size: 24rpx;
  355. font-weight: bold;
  356. }
  357. }
  358. }
  359. >view:last-child {
  360. view:first-child {
  361. text:first-child {
  362. color: #FB731B;
  363. font-size: 44rpx;
  364. font-weight: bold;
  365. line-height: 1;
  366. }
  367. text:last-child {
  368. color: #FB731B;
  369. font-size: 20rpx;
  370. margin-left: 6rpx;
  371. }
  372. }
  373. }
  374. }
  375. .btn {
  376. width: 254rpx;
  377. height: 60rpx;
  378. background: linear-gradient(180deg, #FD794E 0%, #FF5F05 100%);
  379. box-shadow: inset 2rpx 2rpx 8rpx 0rpx #FCFCFC;
  380. border-radius: 78rpx;
  381. border: 1px solid;
  382. border-image: linear-gradient(180deg, rgba(251, 114, 41, 1), rgba(250, 97, 15, 1));
  383. color: #fff;
  384. font-weight: bold;
  385. }
  386. }
  387. }
  388. }
  389. </style>