sign-in.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. <template>
  2. <view class="sign-in-page">
  3. <!-- 顶部导航栏 -->
  4. <view class="header">
  5. <view class="back-btn" @click="goBack">
  6. <text class="back-icon">‹</text>
  7. </view>
  8. <text class="header-title">签到</text>
  9. <view class="placeholder"></view>
  10. </view>
  11. <scroll-view scroll-y class="content">
  12. <!-- 签到日历标题 -->
  13. <view class="calendar-header">
  14. <text class="calendar-title">11月签到日历</text>
  15. <text class="calendar-subtitle">红线相系,良缘成就一生欢喜。</text>
  16. </view>
  17. <!-- 月份选择 -->
  18. <view class="month-selector">
  19. <text class="month-text">2025年 11月</text>
  20. <view class="streak-badge">
  21. <text class="streak-text">红线季良缘</text>
  22. </view>
  23. <view class="calendar-icon">📅</view>
  24. </view>
  25. <!-- 日历 -->
  26. <view class="calendar">
  27. <view class="weekdays">
  28. <text class="weekday">日</text>
  29. <text class="weekday">一</text>
  30. <text class="weekday">二</text>
  31. <text class="weekday">三</text>
  32. <text class="weekday">四</text>
  33. <text class="weekday">五</text>
  34. <text class="weekday">六</text>
  35. </view>
  36. <view class="days">
  37. <view
  38. v-for="(day, index) in calendarDays"
  39. :key="index"
  40. class="day-item"
  41. :class="{
  42. 'other-month': day.isOtherMonth,
  43. 'signed': day.isSigned,
  44. 'today': day.isToday
  45. }"
  46. >
  47. <text class="day-number">{{ day.day }}</text>
  48. </view>
  49. </view>
  50. </view>
  51. <!-- 签到统计 -->
  52. <view class="sign-stats">
  53. <view class="stat-item">
  54. <text class="stat-icon">📊</text>
  55. <text class="stat-text">累计签到: {{ totalSignDays }}天</text>
  56. </view>
  57. <view class="stat-item">
  58. <text class="stat-icon">💗</text>
  59. <text class="stat-text">可用积分: {{ availablePoints }}</text>
  60. </view>
  61. <view class="gift-icon">🎁</view>
  62. </view>
  63. <!-- 连续签到进度 -->
  64. <view class="streak-progress">
  65. <text class="progress-label">连续签到奖励</text>
  66. <text class="progress-days">连续{{ consecutiveDays }}天</text>
  67. </view>
  68. <view class="progress-bar">
  69. <view class="progress-fill" :style="{ width: progressWidth }"></view>
  70. </view>
  71. <!-- 签到按钮 -->
  72. <view class="sign-button" :class="{ disabled: isSigned }" @click="handleSignIn">
  73. <text class="button-text">{{ isSigned ? '今日已签到' : '今日签到 +10积分' }}</text>
  74. </view>
  75. <!-- 提示文字 -->
  76. <view class="tips">
  77. <text class="tips-text">坚持签到,缘分更近一步</text>
  78. <text class="tips-sub">品牌出品 | 青鸟之恋1跟平台</text>
  79. </view>
  80. </scroll-view>
  81. </view>
  82. </template>
  83. <script>
  84. export default {
  85. data() {
  86. return {
  87. currentYear: 2025,
  88. currentMonth: 11,
  89. totalSignDays: 0,
  90. availablePoints: 0,
  91. consecutiveDays: 0,
  92. isSigned: false,
  93. calendarDays: [],
  94. signedDates: [] // 已签到的日期
  95. }
  96. },
  97. computed: {
  98. progressWidth() {
  99. // 假设7天为一个周期
  100. const progress = (this.consecutiveDays % 7) / 7 * 100
  101. return progress + '%'
  102. }
  103. },
  104. onLoad() {
  105. this.loadSignInData()
  106. this.generateCalendar()
  107. },
  108. methods: {
  109. goBack() {
  110. uni.navigateBack()
  111. },
  112. async loadSignInData() {
  113. // 模拟加载签到数据
  114. this.totalSignDays = 0
  115. this.availablePoints = 0
  116. this.consecutiveDays = 0
  117. this.isSigned = false
  118. // 模拟已签到日期
  119. this.signedDates = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 30]
  120. },
  121. generateCalendar() {
  122. const year = this.currentYear
  123. const month = this.currentMonth
  124. // 获取当月第一天是星期几
  125. const firstDay = new Date(year, month - 1, 1).getDay()
  126. // 获取当月天数
  127. const daysInMonth = new Date(year, month, 0).getDate()
  128. // 获取上月天数
  129. const prevMonthDays = new Date(year, month - 1, 0).getDate()
  130. const days = []
  131. // 添加上月日期
  132. for (let i = firstDay - 1; i >= 0; i--) {
  133. days.push({
  134. day: prevMonthDays - i,
  135. isOtherMonth: true,
  136. isSigned: false,
  137. isToday: false
  138. })
  139. }
  140. // 添加当月日期
  141. const today = new Date().getDate()
  142. const currentMonthNow = new Date().getMonth() + 1
  143. for (let i = 1; i <= daysInMonth; i++) {
  144. days.push({
  145. day: i,
  146. isOtherMonth: false,
  147. isSigned: this.signedDates.includes(i),
  148. isToday: i === today && month === currentMonthNow
  149. })
  150. }
  151. // 添加下月日期补齐
  152. const remainingDays = 42 - days.length // 6行7列
  153. for (let i = 1; i <= remainingDays; i++) {
  154. days.push({
  155. day: i,
  156. isOtherMonth: true,
  157. isSigned: false,
  158. isToday: false
  159. })
  160. }
  161. this.calendarDays = days
  162. },
  163. handleSignIn() {
  164. if (this.isSigned) {
  165. uni.showToast({
  166. title: '今日已签到',
  167. icon: 'none'
  168. })
  169. return
  170. }
  171. // 执行签到
  172. this.isSigned = true
  173. this.totalSignDays++
  174. this.availablePoints += 10
  175. this.consecutiveDays++
  176. // 更新今天的签到状态
  177. const today = new Date().getDate()
  178. this.signedDates.push(today)
  179. this.generateCalendar()
  180. uni.showToast({
  181. title: '签到成功 +10积分',
  182. icon: 'success'
  183. })
  184. }
  185. }
  186. }
  187. </script>
  188. <style lang="scss" scoped>
  189. .sign-in-page {
  190. min-height: 100vh;
  191. background: linear-gradient(180deg, #F3E5F5 0%, #FFF9F9 40%);
  192. display: flex;
  193. flex-direction: column;
  194. }
  195. /* 顶部导航栏 */
  196. .header {
  197. display: flex;
  198. align-items: center;
  199. justify-content: space-between;
  200. padding: 20rpx 30rpx;
  201. padding-top: calc(20rpx + env(safe-area-inset-top));
  202. background: transparent;
  203. .back-btn {
  204. width: 50rpx;
  205. height: 50rpx;
  206. display: flex;
  207. align-items: center;
  208. justify-content: center;
  209. .back-icon {
  210. font-size: 40rpx;
  211. color: #333;
  212. }
  213. }
  214. .header-title {
  215. font-size: 32rpx;
  216. font-weight: bold;
  217. color: #333;
  218. }
  219. .placeholder {
  220. width: 50rpx;
  221. }
  222. }
  223. .content {
  224. flex: 1;
  225. padding: 10rpx 20rpx 20rpx;
  226. }
  227. /* 日历标题 */
  228. .calendar-header {
  229. margin-bottom: 20rpx;
  230. .calendar-title {
  231. display: block;
  232. font-size: 32rpx;
  233. font-weight: bold;
  234. color: #333;
  235. margin-bottom: 8rpx;
  236. }
  237. .calendar-subtitle {
  238. display: block;
  239. font-size: 24rpx;
  240. color: #FF6B9D;
  241. }
  242. }
  243. /* 月份选择 */
  244. .month-selector {
  245. display: flex;
  246. align-items: center;
  247. justify-content: space-between;
  248. margin-bottom: 20rpx;
  249. .month-text {
  250. font-size: 28rpx;
  251. font-weight: bold;
  252. color: #7B1FA2;
  253. }
  254. .streak-badge {
  255. background: linear-gradient(135deg, #9C27B0 0%, #BA68C8 100%);
  256. color: #FFFFFF;
  257. font-size: 22rpx;
  258. font-weight: bold;
  259. padding: 6rpx 14rpx;
  260. border-radius: 12rpx;
  261. }
  262. .calendar-icon {
  263. font-size: 32rpx;
  264. }
  265. }
  266. /* 日历 */
  267. .calendar {
  268. background: #FFFFFF;
  269. border-radius: 16rpx;
  270. padding: 20rpx;
  271. margin-bottom: 20rpx;
  272. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  273. .weekdays {
  274. display: grid;
  275. grid-template-columns: repeat(7, 1fr);
  276. margin-bottom: 15rpx;
  277. .weekday {
  278. text-align: center;
  279. font-size: 24rpx;
  280. color: #666;
  281. font-weight: bold;
  282. }
  283. }
  284. .days {
  285. display: grid;
  286. grid-template-columns: repeat(7, 1fr);
  287. gap: 8rpx;
  288. .day-item {
  289. aspect-ratio: 1;
  290. display: flex;
  291. align-items: center;
  292. justify-content: center;
  293. border-radius: 12rpx;
  294. background: #F5F5F5;
  295. &.other-month {
  296. background: transparent;
  297. .day-number {
  298. color: #CCC;
  299. }
  300. }
  301. &.signed {
  302. background: linear-gradient(135deg, #CE93D8 0%, #BA68C8 100%);
  303. .day-number {
  304. color: #FFFFFF;
  305. font-weight: bold;
  306. }
  307. }
  308. &.today {
  309. border: 2rpx solid #9C27B0;
  310. }
  311. .day-number {
  312. font-size: 24rpx;
  313. color: #333;
  314. }
  315. }
  316. }
  317. }
  318. /* 签到统计 */
  319. .sign-stats {
  320. display: flex;
  321. align-items: center;
  322. justify-content: space-between;
  323. background: #FFFFFF;
  324. border-radius: 16rpx;
  325. padding: 15rpx 20rpx;
  326. margin-bottom: 15rpx;
  327. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  328. .stat-item {
  329. display: flex;
  330. align-items: center;
  331. gap: 8rpx;
  332. flex: 1;
  333. .stat-icon {
  334. font-size: 24rpx;
  335. }
  336. .stat-text {
  337. font-size: 24rpx;
  338. color: #666;
  339. }
  340. }
  341. .gift-icon {
  342. font-size: 32rpx;
  343. }
  344. }
  345. /* 连续签到进度 */
  346. .streak-progress {
  347. display: flex;
  348. align-items: center;
  349. justify-content: space-between;
  350. margin-bottom: 10rpx;
  351. .progress-label {
  352. font-size: 24rpx;
  353. color: #666;
  354. }
  355. .progress-days {
  356. font-size: 24rpx;
  357. color: #9C27B0;
  358. font-weight: bold;
  359. }
  360. }
  361. .progress-bar {
  362. width: 100%;
  363. height: 12rpx;
  364. background: #E0E0E0;
  365. border-radius: 6rpx;
  366. margin-bottom: 25rpx;
  367. overflow: hidden;
  368. .progress-fill {
  369. height: 100%;
  370. background: linear-gradient(90deg, #9C27B0 0%, #BA68C8 100%);
  371. border-radius: 6rpx;
  372. transition: width 0.3s ease;
  373. }
  374. }
  375. /* 签到按钮 */
  376. .sign-button {
  377. background: linear-gradient(135deg, #9C27B0 0%, #BA68C8 100%);
  378. border-radius: 16rpx;
  379. padding: 20rpx;
  380. margin-bottom: 20rpx;
  381. box-shadow: 0 4rpx 12rpx rgba(156, 39, 176, 0.3);
  382. &.disabled {
  383. background: #E0E0E0;
  384. box-shadow: none;
  385. }
  386. .button-text {
  387. display: block;
  388. text-align: center;
  389. font-size: 28rpx;
  390. font-weight: bold;
  391. color: #FFFFFF;
  392. }
  393. }
  394. /* 提示文字 */
  395. .tips {
  396. text-align: center;
  397. .tips-text {
  398. display: block;
  399. font-size: 26rpx;
  400. color: #666;
  401. margin-bottom: 8rpx;
  402. }
  403. .tips-sub {
  404. display: block;
  405. font-size: 22rpx;
  406. color: #999;
  407. }
  408. }
  409. </style>