studyplus/pages/feedBack/feedBack.js
2020-02-14 23:12:58 +08:00

191 lines
4.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// pages/feedBack/feedBack.js
import {
DBPost
} from '../../db/DBpost.js';
Page({
/**
* 页面的初始数据
*/
data: {
box_1_style: true,
box_2_style: false,
box_3_style: false,
_type: "程序错误",
feedBack: "",
qqNum: "",
feedBack_error: false,
qqNum_error: false,
placeholder:"首先恭喜你遇到了Bug我们一起来干掉它如何"
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
var dbPost = new DBPost();
this.setData({
xuehao: dbPost.getxuehaoData(),
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
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: "程序错误",
placeholder:"首先恭喜你遇到了Bug我们一起来干掉它如何"
})
console.log(this.data._type)
},
box_2() { //优化改进点击事件
this.setData({
box_1_style: false,
box_2_style: true,
box_3_style: false,
_type: "优化改进",
placeholder: "觉得界面太丑你有好的点子欢迎成为我们的UI设计师"
})
console.log(this.data._type)
},
box_3() { //新功能点击事件
this.setData({
box_1_style: false,
box_2_style: false,
box_3_style: true,
_type: "新功能",
placeholder: "Come on! 来点紧张刺激的怎么样~"
})
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)
var that=this;
if (qqNUm_ok && feedBack_ok) {
wx.showLoading({
title: '提交中',
})
wx.request({
url: 'https://powerrain.cn/rcs/API/feedBack.php', //仅为示例,并非真实的接口地址
data: {
types:that.data._type,
qqNum:that.data.qqNum,
feedBack:that.data.feedBack,
xueHao:that.data.xuehao
},
header: {
'content-type': 'application/json' // 默认值
},
success: function (res) {
console.log(res);
wx.hideLoading();
wx.switchTab({
url: '../user/user'
})
wx.showToast({
title: "提交成功"
})
},
fail:function(){
wx.hideLoading();
wx.showToast({
title:"提交失败",
icon:"none"
})
}
})
}
}
})