// pages/index/index.js
var stepList = ['立论阶段', '驳立论阶段', '质辩阶段','自由辩论','陈词阶段'];
var leftMove = 0 ; //左边初始偏移的角度
var rightMove = 0 ; //右边初始偏移的角度
Page({
data:{
currentStep:{}, //当前第一个阶段
currentStepList:[], //当前可利用阶段对象,包含第一个元素名字,第二个为描述,第三个为时间限制,都为数组,位置一一对应
leftAnimationData:{},
rightAnimationData:{}
},
onLoad:function(options){
// 页面初始化 options为页面跳转所带来的参数
},
onReady:function(){
// 页面渲染完成
},
onShow:function(){
// 页面显示
//在缓存中取出每一阶段的设置
var configs = wx.getStorageSync('configs');
var currentStepList = [];
var currentStepNameList = []; //阶段名字list
var currentStepDescList = [];// 阶段描述list
var currentStepTimeList = [];//阶段时间list
var currentStep = {};
var current = true;
for(var config in configs){
var step = configs[config];
if(step.state){
currentStepNameList.push(step.name);
currentStepDescList.push(step.desc);
currentStepTimeList.push(step.time);
if(current){
var desc = step.desc.replace(/@/g,step.time + '秒'); //时间描述替换
currentStep.name = step.name;
currentStep.desc = desc;
this.setData({
currentStep:currentStep
})
current = !current;
}
}
}
currentStepList.push(currentStepNameList);
currentStepList.push(currentStepDescList);
currentStepList.push(currentStepTimeList);
this.setData({
currentStepList:currentStepList
})
},
onHide:function(){
// 页面隐藏
},
onUnload:function(){
// 页面关闭
},
//改变阶段
changeStep:function(){
var page = this;
var currentStepList = this.data.currentStepList;
var currentStepNameList = currentStepList[0];//名字
var currentStepdescList = currentStepList[1];//描述
var currentStepTimeList = currentStepList[2];//时间
if( !currentStepNameList || currentStepNameList.length == 0){
wx.showModal({
title: '小提示',
content: '请至少开启一个阶段',
success: function(res) {
if (res.confirm) {
wx.navigateTo({
url: '/pages/config/config',
success: function(res){
// success
},
fail: function() {
// fail
},
complete: function() {
// complete
}
})
}
}
})
}
wx.showActionSheet({
itemList: currentStepNameList,
success: function(res) {
if (!res.cancel) {
var index = res.tapIndex;
var currentStep= {};
currentStep.name = currentStepNameList[index];
currentStep.desc = currentStepdescList[index].replace(/@/g,currentStepTimeList[index] + '秒');
page.setData({
currentStep:currentStep
})
}
}
})
},
//leftStart --正方
leftStart:function(){
var animation = this.createAnimation();
animation.rotate(leftMove+=100).step();
this.setData({
leftAnimationData:animation.export()
});
},
//rightStart 反方
rightStart:function(){
var animation = this.createAnimation();
animation.rotate(rightMove+=100).step();
this.setData({
rightAnimationData:animation.export()
});
},
//创建动画对象
createAnimation:function(){
var animation = wx.createAnimation({
duration: 1000,
timingFunction: 'linear', // "linear","ease","ease-in","ease-in-out","ease-out","step-start","step-end"
delay: 0,
transformOrigin: '50% 50% 0'
});
return animation;
}
})
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
微信小程序-辩论倒计时-程序源码.zip (16个子文件)
微信小程序-辩论倒计时-程序源码
timing
pages
index
index.wxml 973B
index.js 4KB
index.json 2B
index.wxss 752B
config
config.wxml 4KB
config.wxss 398B
config.js 2KB
config.json 48B
app.json 803B
assets
images
time-selected.png 882B
time.png 890B
config.png 864B
config-selected.png 871B
app.js 2KB
utils
util.js 460B
app.wxss 604B
共 16 条
- 1
资源评论
TD程序员
- 粉丝: 2411
- 资源: 437
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功