You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
238 lines
4.5 KiB
238 lines
4.5 KiB
// pages/feedback/feedback.js
|
|
const request = require('../../utils/http')
|
|
const app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
array: ['请选择', 'bug问题', '业务问题', '功能使用问题', '其他'],
|
|
problemArray: [{
|
|
id: 0,
|
|
name: '请选择'
|
|
},
|
|
{
|
|
id: 1,
|
|
name: 'bug问题'
|
|
},
|
|
{
|
|
id: 2,
|
|
name: '业务问题'
|
|
},
|
|
{
|
|
id: 3,
|
|
name: '功能使用问题'
|
|
},
|
|
{
|
|
id: 4,
|
|
name: '其他'
|
|
}
|
|
],
|
|
index: 0, //问题下标
|
|
problemStr: '',
|
|
//图片数组
|
|
addImgBtn: {
|
|
isBtn: true,
|
|
text: "+",
|
|
func: "addImage"
|
|
},
|
|
imageArr: [], //显示图片列表
|
|
upImageArr: [], //需要上传的图片路径
|
|
},
|
|
|
|
bindPickerChange(e) {
|
|
this.setData({
|
|
index: e.detail.value
|
|
})
|
|
},
|
|
|
|
//记录问题
|
|
problemUr(e) {
|
|
console.log(e.detail.value);
|
|
this.setData({
|
|
problemStr: e.detail.value
|
|
})
|
|
},
|
|
|
|
//提交数据
|
|
goMyorder() {
|
|
//判断是否选择问题类型
|
|
|
|
if (this.data.index === 0) {
|
|
wx.showToast({
|
|
title: '请选择问题类型',
|
|
icon: 'error'
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (this.data.upImageArr.length === 0) {
|
|
wx.showToast({
|
|
title: '至少上传一张图片',
|
|
icon: 'error'
|
|
})
|
|
return;
|
|
}
|
|
|
|
//当没有描述时,弹框提示,但不是强制性。
|
|
if (this.data.problemStr.length === 0) {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '如果有问题描述,可以帮助技术人员更快的解决问题,点击取消添加描述',
|
|
complete: (res) => {
|
|
if (res.confirm) {
|
|
this.submitProblem();
|
|
}
|
|
}
|
|
})
|
|
} else {
|
|
this.submitProblem();
|
|
}
|
|
|
|
},
|
|
|
|
//提交反馈
|
|
submitProblem() {
|
|
//提示成功后,点击确定,返回上一页。
|
|
var data = {
|
|
'type': this.data.index,
|
|
'describe': this.data.problemStr,
|
|
'imgs': this.data.upImageArr.join(',')
|
|
}
|
|
|
|
request.post(`/feedBack/push`, data).then(res => {
|
|
if (res.data.code < 400) {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '问题已经提交',
|
|
showCancel: false,
|
|
complete: (res) => {
|
|
if (res.confirm) {
|
|
wx.switchTab({
|
|
url: '../about/about',
|
|
})
|
|
}
|
|
}
|
|
})
|
|
|
|
} else {
|
|
wx.showToast({
|
|
title: res.data.message,
|
|
})
|
|
}
|
|
});
|
|
},
|
|
|
|
//添加图片
|
|
addImage() {
|
|
var _this = this;
|
|
wx.chooseMedia({
|
|
count: 1,
|
|
mediaType: ['image'],
|
|
sourceType: ['album'],
|
|
sizeType: ['compressed'],
|
|
success: res => {
|
|
var imgSrc = res.tempFiles[0].tempFilePath;
|
|
_this.addCallBackImage(imgSrc);
|
|
_this.upImg(imgSrc); //点击提交时统一上传
|
|
}
|
|
})
|
|
},
|
|
|
|
//显示回调图片
|
|
addCallBackImage(imageSrc) {
|
|
var temp = {
|
|
isBtn: false,
|
|
imgUrl: imageSrc,
|
|
text: imageSrc,
|
|
func: ""
|
|
};
|
|
this.data.imageArr.unshift(temp);
|
|
this.setData({
|
|
imageArr: this.data.imageArr
|
|
});
|
|
},
|
|
|
|
//上传图片接口地址
|
|
upImg(imageSrc) {
|
|
request.upImgFile(`/feedBack/upload`, imageSrc).then(res => {
|
|
var resObj = JSON.parse(res.data);
|
|
if (resObj.code > 400) {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: resObj.message,
|
|
complete: (res) => {
|
|
if (res.cancel) {}
|
|
if (res.confirm) {}
|
|
//上传失败后移除图片
|
|
|
|
}
|
|
})
|
|
} else {
|
|
//保存图片路径到数组
|
|
this.data.upImageArr.push(resObj.data.url);
|
|
}
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
console.log("token=" + app.globalData.token);
|
|
//初始化添加按钮
|
|
this.setData({
|
|
imageArr: [this.data.addImgBtn]
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
}) |