studyplus/pages/feedBack/feedBack.js
Rain Sun 3b4ba85b9d 性能优化
取消无用的setData方法,提升运算性能
2018-10-02 13:24:04 +08:00

152 lines
2.8 KiB
JavaScript

// pages/feedBack/feedBack.js
Page({
/**
* 页面的初始数据
*/
data: {
box_1_style: true,
box_2_style: false,
box_3_style: false,
type: "程序错误",
feedBack: "",
qqNum: "",
feedBack_error: false,
qqNum_error: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
},
box_1() { //程序错误点击事件
this.setData({
box_1_style: true,
box_2_style: false,
box_3_style: false,
type: "程序错误"
})
console.log(this.data.type)
},
box_2() { //优化改进点击事件
this.setData({
box_1_style: false,
box_2_style: true,
box_3_style: false,
type: "优化改进"
})
console.log(this.data.type)
},
box_3() { //新功能点击事件
this.setData({
box_1_style: false,
box_2_style: false,
box_3_style: true,
type: "新功能"
})
console.log(this.data.type)
},
fankui(e) { //反馈内容输入
this.data.feedBack = e.detail.value
},
qqNum(e) { //qq号码输入
this.data.qqNum = e.detail.value
},
submit() {
var qqNUm_ok = 0;
var feedBack_ok = 0;
if (this.data.qqNum) { //qq号码状态判断
var reg = /^[1-9][0-9]{4,9}$/gim;
if (reg.test(this.data.qqNum)) {
console.log('QQ号码格式输入正确');
qqNUm_ok = 1;
this.setData({
qqNum_error: false
})
} else {
console.log('请输入正确格式的QQ号码');
this.setData({
qqNum_error: true
})
}
} else {
qqNUm_ok = 1;
}
if (this.data.feedBack) { //反馈状态判断
feedBack_ok = 1;
this.setData({
feedBack_error: false
})
} else {
this.setData({
feedBack_error: true
})
}
// console.log("类型为", this.data.type)
// console.log("反馈内容为", this.data.feedBack)
// console.log("qq号码为", this.data.qqNum)
// console.log("反馈", feedBack_ok)
// console.log("qq", qqNUm_ok)
wx.showLoading();
wx.hideLoading();
if (qqNUm_ok && feedBack_ok) {
wx.switchTab({
url: '../user/user'
})
}
}
})