使用微信小程序开发制作一个简易的闹钟提醒应用

import 'wx.request.js';

// 创建App实例 App({ // 全局数据 globalData: { alarmList: [], // 闹钟列表 currentAlarm: null // 当前选中的闹钟 },

// 应用启动时触发 onLaunch: function () { // 从本地存储中加载闹钟列表 const alarmList = wx.getStorageSync('alarmList') || []; this.globalData.alarmList = alarmList;

// 设置闹钟提醒
this.setAlarmReminder();

},

// 设置闹钟提醒 setAlarmReminder: function () { const alarmList = this.globalData.alarmList; alarmList.forEach(function (alarm) { // 设置定时器,到达设定的时间时触发提醒 const timestamp = new Date(alarm.time).getTime(); const now = new Date().getTime(); const timeDiff = timestamp - now;

  if (timeDiff > 0) {
    setTimeout(function () {
      this.showAlarmReminder(alarm);
    }, timeDiff);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值