新增回调及反馈上传

新增将反馈上传至服务器,在request加入了失败的回调函数,优化体验。
This commit is contained in:
Rain Sun 2018-10-02 17:10:56 +08:00
parent bbccd24425
commit 3c1eef3297
4 changed files with 73 additions and 18 deletions

View File

@ -1,4 +1,7 @@
// pages/feedBack/feedBack.js
import {
DBPost
} from '../../db/DBpost.js';
Page({
/**
@ -8,7 +11,7 @@ Page({
box_1_style: true,
box_2_style: false,
box_3_style: false,
type: "程序错误",
_type: "程序错误",
feedBack: "",
qqNum: "",
feedBack_error: false,
@ -20,7 +23,10 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
var dbPost = new DBPost();
this.setData({
xuehao: dbPost.getxuehaoData(),
});
},
/**
@ -76,7 +82,7 @@ Page({
box_1_style: true,
box_2_style: false,
box_3_style: false,
type: "程序错误",
_type: "程序错误",
placeholder:"首先恭喜你遇到了Bug我们一起来干掉它如何"
})
console.log(this.data.type)
@ -86,7 +92,7 @@ Page({
box_1_style: false,
box_2_style: true,
box_3_style: false,
type: "优化改进",
_type: "优化改进",
placeholder: "觉得界面太丑你有好的点子欢迎成为我们的UI设计师"
})
@ -97,7 +103,7 @@ Page({
box_1_style: false,
box_2_style: false,
box_3_style: true,
type: "新功能",
_type: "新功能",
placeholder: "Come on! 来点紧张刺激的怎么样~"
})
@ -129,7 +135,6 @@ Page({
} else {
qqNUm_ok = 1;
}
if (this.data.feedBack) { //反馈状态判断
feedBack_ok = 1;
this.setData({
@ -140,17 +145,46 @@ Page({
feedBack_error: true
})
}
// console.log("类型为", this.data.type)
// 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();
var that=this;
if (qqNUm_ok && feedBack_ok) {
wx.switchTab({
url: '../user/user'
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"
})
}
})
}
}

View File

@ -15,7 +15,7 @@
<view class="{{feedBack_error?'showError':'showNormal'}}">请输入内容</view>
</view>
<textarea class="item" placeholder="{{placeholder}}" bindinput="fankui"></textarea>
<textarea class="item" placeholder="{{placeholder}}" bindinput="fankui" maxlength="300"></textarea>
<view class="title">
<view>联系方式(选填)</view>
<view class="{{qqNum_error?'showError':'showNormal'}}">请输入正确的qq号</view>

View File

@ -150,6 +150,13 @@ Page({
url: '../../pages/post/post'
})
}
},
fail: function () {
wx.hideLoading();
wx.showToast({
title: "登录失败",
icon: "none"
})
}
})
} else {

View File

@ -328,13 +328,27 @@ Page({
dbPost.newadmin(result.data.admin);
that.data.xuehao = result.data.xueHao;
console.log(that.data.xuehao);
wx.switchTab({
url: '../../pages/post/post'
})
if(that.data.xuehao){
wx.switchTab({
url: '../../pages/post/post'
})
wx.showToast({
title: '注册成功',
icon: 'success',
duration: 2000
})
}else{
wx.showToast({
title: "注册失败,请重试",
icon: "none"
})
}
},
fail:function(){
wx.showToast({
title: '注册成功',
icon: 'success',
duration: 2000
title: "网络不畅,注册失败",
icon: "none"
})
}
})