├── php-api/ # 改造后的PHP接口层 ├── java-ad-service/ # 若依框架微服务(广告+VIP+分账) ├── uniapp-reader/ # UniApp前端项目 │ ├── pages/ # 各端页面 │ └──
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

reminder.js 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { request } from '@/utils/request'
  2. // 签到提醒系统
  3. export const useReminder = {
  4. // 检查是否需要提醒
  5. async checkSignReminder() {
  6. // 获取用户最后签到时间
  7. const lastSign = uni.getStorageSync('lastSignDate') || ''
  8. const today = new Date().toISOString().split('T')[0]
  9. // 今天已签到
  10. if (lastSign === today) return false
  11. // 获取用户设置
  12. const settings = uni.getStorageSync('userSettings') || {}
  13. if (settings.signReminder === false) return false
  14. // 检查服务器端签到状态
  15. try {
  16. const res = await request({
  17. url: '/sign/status',
  18. method: 'GET',
  19. headers: { 'Authorization': `Bearer ${uni.getStorageSync('token')}` }
  20. })
  21. return !res.data.todaySigned
  22. } catch (e) {
  23. console.error('签到状态检查失败', e)
  24. return false
  25. }
  26. },
  27. // 显示签到提醒
  28. showReminder() {
  29. uni.showModal({
  30. title: '每日签到',
  31. content: '您今天还未签到,立即签到可获得金币奖励!',
  32. confirmText: '去签到',
  33. cancelText: '稍后提醒',
  34. success: (res) => {
  35. if (res.confirm) {
  36. uni.navigateTo({ url: '/pages/welfare/index' })
  37. } else {
  38. // 1小时后再次提醒
  39. setTimeout(this.showReminder, 60 * 60 * 1000)
  40. }
  41. }
  42. })
  43. },
  44. // 初始化签到提醒
  45. init() {
  46. // 每天10点检查签到
  47. setInterval(async () => {
  48. const shouldRemind = await this.checkSignReminder()
  49. if (shouldRemind) {
  50. this.showReminder()
  51. }
  52. }, 60 * 60 * 1000) // 每小时检查一次
  53. // 应用启动时检查
  54. this.checkSignReminder().then(shouldRemind => {
  55. if (shouldRemind) {
  56. setTimeout(() => this.showReminder(), 3000) // 3秒后显示
  57. }
  58. })
  59. }
  60. }