151 lines
2.9 KiB
JavaScript
151 lines
2.9 KiB
JavaScript
![]() |
const tabService = require("../../../utils/tab-serve");
|
|||
|
const util = require("../../../utils/utils")
|
|||
|
Page({
|
|||
|
|
|||
|
/**
|
|||
|
* 页面的初始数据
|
|||
|
*/
|
|||
|
data: {
|
|||
|
tabName: 'time', //time num nothing
|
|||
|
isPopupVisible: false,
|
|||
|
time: 60, //计时 单位:s
|
|||
|
number: 100, //计数
|
|||
|
timeStr:'01:00'
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面加载
|
|||
|
*/
|
|||
|
onLoad(options) {
|
|||
|
if (tabService.tabBar.length <= 0) {
|
|||
|
tabService.updateRole(this, 'parent')
|
|||
|
}
|
|||
|
},
|
|||
|
|
|||
|
//步进器
|
|||
|
setup(e) {
|
|||
|
if (this.data.tabName == 'time') {//计数
|
|||
|
//添加
|
|||
|
if (e.currentTarget.id == 'add') {
|
|||
|
this.setData({
|
|||
|
time:this.data.time + 15,
|
|||
|
timeStr:util.formatTimeStr(this.data.time + 15)
|
|||
|
})
|
|||
|
}else{
|
|||
|
if(this.data.time <= 30) return wx.showToast({
|
|||
|
title: '最少训练30秒哦~~',
|
|||
|
icon:'none'
|
|||
|
})
|
|||
|
if(this.data.time >= 3600) return wx.showToast({
|
|||
|
title: '最多训练60分钟哦~~',
|
|||
|
icon:'none'
|
|||
|
})
|
|||
|
this.setData({
|
|||
|
time:this.data.time - 15,
|
|||
|
timeStr:util.formatTimeStr(this.data.time - 15)
|
|||
|
})
|
|||
|
}
|
|||
|
} else {//计数
|
|||
|
//添加
|
|||
|
if (e.currentTarget.id == 'add') {
|
|||
|
this.setData({
|
|||
|
number:this.data.number + (this.data.number < 50? 10 : 50)
|
|||
|
})
|
|||
|
}else{
|
|||
|
if(this.data.number <= 10) return wx.showToast({
|
|||
|
title: '最少10个哦~~',
|
|||
|
icon:'none'
|
|||
|
})
|
|||
|
this.setData({
|
|||
|
number:this.data.number - (this.data.number <= 50? 10 : 50)
|
|||
|
})
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
|
|||
|
//跳转设置页面
|
|||
|
goSetting(){
|
|||
|
wx.navigateTo({
|
|||
|
url: '/subpackage/train/setting/setting',
|
|||
|
})
|
|||
|
},
|
|||
|
|
|||
|
changeTab(e) {
|
|||
|
const value = e.currentTarget.id
|
|||
|
this.setData({
|
|||
|
tabName: value
|
|||
|
})
|
|||
|
},
|
|||
|
|
|||
|
showPopup() {
|
|||
|
const data = `&type=${this.data.tabName}&time=${this.data.time}&number=${this.data.number}&theme=myself`
|
|||
|
wx.navigateTo({
|
|||
|
// url: '/module-sport/pages/sport-full-screen?sportKey=Rope-Skipping'+data,
|
|||
|
url: '/subpackage/train/check-type/check-page?sportKey=Rope-Skipping'+data,
|
|||
|
})
|
|||
|
},
|
|||
|
|
|||
|
handleCancel() {
|
|||
|
this.setData({
|
|||
|
isPopupVisible: false
|
|||
|
});
|
|||
|
},
|
|||
|
|
|||
|
handleConfirm() {
|
|||
|
this.setData({
|
|||
|
isPopupVisible: false
|
|||
|
});
|
|||
|
// 处理确认逻辑
|
|||
|
},
|
|||
|
|
|||
|
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面初次渲染完成
|
|||
|
*/
|
|||
|
onReady() {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面显示
|
|||
|
*/
|
|||
|
onShow() {
|
|||
|
tabService.updateIndex(this, 0)
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面隐藏
|
|||
|
*/
|
|||
|
onHide() {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面卸载
|
|||
|
*/
|
|||
|
onUnload() {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 页面相关事件处理函数--监听用户下拉动作
|
|||
|
*/
|
|||
|
onPullDownRefresh() {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 页面上拉触底事件的处理函数
|
|||
|
*/
|
|||
|
onReachBottom() {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 用户点击右上角分享
|
|||
|
*/
|
|||
|
onShareAppMessage() {
|
|||
|
|
|||
|
}
|
|||
|
})
|