//index.js
//获取应用实例
const app = getApp()
const util = require('../../utils/util.js')
Page({
remindTime:0,
clockShow:false,
clockHeight:0,
mTime:10000,
timeStr:'01:00',
rate:'',
timer:null,
audio: null,
data: {
time: '1',
cateArr:[
{
icon:'work',
text:'工作'
},
{
icon:'study',
text:"学习",
},
{
icon:'think',
text:'思考'
},
{
icon:'write',
text:'写作'
},
{
icon:'sport',
text:'运动'
},
{
icon:'read',
text:"阅读"
}
],
cateActive:'0',
okShow:false,
pauseShow:true,
continueCancleShow:false,
val:'',
task_list_data:[],
},
//task_data
//事件处理函数
bindViewTap: function() {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad: function () {
var res = wx.getSystemInfoSync();
var rate = 750 / res.windowWidth;
this.setData({
rate: rate,
clockHeight: rate * res.windowHeight
})
},
getUserInfo: function(e) {
app.globalData.userInfo = e.detail.userInfo
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
},
slideChange: function (e) {
this.setData({
time : e.detail.value
})
},
clickCate:function (e) {
this.setData({
cateActive: e.currentTarget.dataset.index
})
},
start: function() {
this.setData({
clockShow:true,
mTime: this.data.time*60*1000,
remindTime: this.data.time*60*1000,
timeStr:parseInt(this.data.time) >= 10 ? this.data.time+':00' : '0'+this.data.time +':00'
})
this.drawBg();
var that = this;
var n = 5;
if(this.data.time <= 25) {
that.drawActive();
} else {
that.drawActive();
setTimeout(function() {
that.pause();
that.drawActiveBreak25(n);
setTimeout(function() {
that.continue();
}, n * 60 * 1000);
}, 25 * 60 * 1000);
}
},
drawBg:function () {
var lineWidth = 6 / this.data.rate; // px
var ctx =wx.createCanvasContext('progress_bg');
ctx.setLineWidth(lineWidth);
ctx.setStrokeStyle('#000000');
ctx.setLineCap('round');
ctx.beginPath();
ctx.arc(400/this.data.rate/2,400/this.data.rate/2,400/this.data.rate/2 - 2* lineWidth,0,2*Math.PI,false);
ctx.stroke();
ctx.draw();
},
drawActive: function () {
var _this = this;
var timer = setInterval(function () {
var angle = 1.5 + 2*(_this.data.time*60*1000 - _this.data.mTime)/(_this.data.time*60*1000);
var currentTime = _this.data.mTime - 100
_this.setData({
mTime: currentTime
});
if(angle < 3.5) {
if(currentTime % 1000 == 0) {
var timeStr1 = currentTime / 1000; // s
var timeStr2 = parseInt(timeStr1 / 60) // m
var timeStr3 = (timeStr1 - timeStr2 * 60) >= 10 ? (timeStr1 - timeStr2 * 60) : '0' + (timeStr1 - timeStr2 * 60);
var timeStr2 = timeStr2 >= 10 ? timeStr2:'0'+timeStr2;
_this.setData({
timeStr:timeStr2 + ':' + timeStr3
})
}
var lineWidth = 6 / _this.data.rate; // px
var ctx = wx.createCanvasContext('progress_active');
ctx.setLineWidth(lineWidth);
ctx.setStrokeStyle('#ffffff');
ctx.setLineCap('round');
ctx.beginPath();
ctx.arc(400 / _this.data.rate / 2, 400 / _this.data.rate / 2, 400 / _this.data.rate / 2 - 2 * lineWidth, 1.5 * Math.PI, angle * Math.PI, false);
ctx.stroke();
ctx.draw();
} else {
var logs = wx.getStorageSync('logs') || [];
if (_this.data.time != undefined && _this.data.time > 0) {
logs.unshift({
date: util.formatTime(new Date),
cate: _this.data.cateActive,
time: _this.data.time
});
}
wx.setStorageSync('logs', logs);
_this.setData({
timeStr:'00:00',
okShow:true,
pauseShow: false,
continueCancleShow: false
})
clearInterval(timer);
_this.playAudioHun(_this);
}
},100);
_this.setData({
timer:timer
})
},
pause : function() {
clearInterval(this.data.timer);
this.setData({
pauseShow: false,
continueCancleShow: true,
okShow: false
})
},
continue: function () {
this.drawActive();
this.setData({
pauseShow: true,
continueCancleShow: false,
okShow: false
})
},
cancle: function (){
clearInterval(this.data.timer);
this.message('不要轻言放弃哦~');
this.setData({
pauseShow: true,
continueCancleShow: false,
okShow: false,
clockShow:false
})
},
ok: function () {
clearInterval(this.data.timer);
this.setData({
pauseShow: true,
continueCancleShow: false,
okShow: false,
clockShow: false
}),
this.data.audio.stop();
if (parseInt(this.data.remindTime) >= 40*60*1000) {
this.message('请及时注意休息哦')
} else {
this.message('按时完成了任务,继续加油!')
}
},
playAudioHun: function(obj) {
const audioP = wx.createInnerAudioContext();
audioP.src = '/audio/audio.mp3';
audioP.play();
obj.setData({
audio: audioP
})
},
message: function(info) {
wx.showToast({
title: info,
icon: 'none',
duration: 1500
})
},
// Todo list
getval(e){
this.setData({ val: e.detail.value})
},
add() {
var data1 = this.data.task_list_data;
if (this.data.val == '') {
this.message("不能添加空任务")
return
}
data1.push(this.data.val)
this.setData({
task_list_data:data1,
val:''})
},
del(e) {
var i = e.target.dataset.index;
var data2 = this.data.task_list_data;
data2.splice(i, 1)
this.setData({
task_list_data: data2
})
},
start_task() {
this.start();
},
drawActiveBreak25: function (n) {
var _this = this;
var breakTime = parseInt(n);
var mbreakTime = breakTime * 60 * 1000;
var currentTime = mbreakTime;
var timer = setInterval(function () {
var angle = 1.5 + 2*(breakTime*60*1000 - mbreakTime)/(breakTime*60*1000);
currentTime = mbreakTime - 100
mbreakTime = currentTime;
if(angle < 3.5) {
if(currentTime % 1000 == 0) {
var timeStr1 = currentTime / 1000; // s
var timeStr2 = parseInt(timeStr1 / 60) // m
var timeStr3 = (timeStr1 - timeStr2 * 60) >= 10 ? (timeStr1 - timeStr2 * 60) : '0' + (timeStr1 - timeStr2 * 60);
var timeStr2 = timeStr2 >= 10 ? timeStr2:'0'+timeStr2;
_this.setData({
timeStr:timeStr2 + ':' + timeStr3
})
}
var lineWidth = 6 / _this.data.rate; // px
var ctx = wx.createCanvasContext('progress_active');
ctx.setLineWidth(lineWidth);
ctx.setStrokeStyle('#ffffff');
ctx.setLineCap('round');
ctx.beginPath();
ctx.arc(400 / _this.data.rate / 2, 400 / _this.data.rate / 2, 400 / _this.data.rate / 2 - 2 * lineWidth, 1.5 * Math.PI, angle * Math.PI, false);
ctx.stroke();
ctx.draw();
} else {
clearInterval(timer);
}
},100);
_this.setData({
continueCancleShow: false,
})
},
})
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
小程序完整源码,项目可正常运行。 环境说明: 开发语言:Java 前端框架:小程序 JDK版本:JDK1.8 数据库:mysql 5.7+ 部署容器:tomcat7+ 数据库工具:Navicat11+ 开发软件:eclipse/myeclipse/idea(推荐idea) Maven包:Maven3.3.9
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计之基于微信小程序的todo番茄钟设计与实现源码.zip (28个子文件)
项目文档说明.zip 63KB
myProject
项目文档说明.zip 63KB
tomatoClock
sitemap.json 191B
pages
index
index.wxml 2KB
index.js 7KB
index.json 46B
index.wxss 3KB
logs
logs.json 65B
logs.js 2KB
logs.wxml 1KB
logs.wxss 1KB
app.json 708B
project.config.json 1KB
app.js 1KB
utils
util.js 472B
app.wxss 194B
audio
audio.mp3 297KB
sitemap44.json 191B
images
think.png 3KB
write.png 3KB
tongji.png 3KB
jishi.png 3KB
tongji2.png 3KB
sport.png 3KB
jishi2.png 3KB
study.png 2KB
read.png 3KB
work.png 1KB
共 28 条
- 1
资源评论
大学生资源网
- 粉丝: 138
- 资源: 1334
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功