物流端
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.
yyt-mall-wl/pages/feedback/feedback.js

243 lines
4.6 KiB

1 year ago
// pages/feedback/feedback.js
const request = require('../../utils/http')
const app = getApp();
1 year ago
Page({
/**
* 页面的初始数据
*/
data: {
array: ['请选择', 'bug问题', '业务问题', '功能使用问题', '其他'],
1 year ago
problemArray: [{
1 year ago
id: 0,
name: '请选择'
1 year ago
},
{
id: 1,
name: 'bug问题'
},
{
id: 2,
name: '业务问题'
},
{
id: 3,
name: '功能使用问题'
},
{
id: 4,
name: '其他'
}
],
1 year ago
index: 0, //问题下标
problemStr: '',
//图片数组
addImgBtn: {
isBtn: true,
text: "+",
func: "addImage"
},
1 year ago
imageArr: [], //显示图片列表
upImageArr: [], //需要上传的图片路径
1 year ago
},
bindPickerChange(e) {
1 year ago
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) {
1 year ago
wx.showToast({
title: '至少上传一张图片',
icon: 'error'
1 year ago
})
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,
})
}
});
1 year ago
},
//添加图片
addImage() {
var _this = this;
1 year ago
wx.chooseMedia({
count: 1,
mediaType: ['image'],
sourceType: ['album'],
1 year ago
sizeType: ['compressed'],
success: res => {
var imgSrc = res.tempFiles[0].tempFilePath;
_this.addCallBackImage(imgSrc);
_this.upImg(imgSrc); //点击提交时统一上传
1 year ago
}
})
},
//删除照片
delImage(e){
console.log(e)
//TODO
},
1 year ago
//显示回调图片
addCallBackImage(imageSrc) {
var temp = {
isBtn: false,
imgUrl: imageSrc,
text: imageSrc,
func: "delImage"
};
this.data.imageArr.unshift(temp);
this.setData({
imageArr: this.data.imageArr
});
},
1 year ago
//上传图片接口地址
upImg(imageSrc) {
request.upImgFile(`/feedBack/upload`, imageSrc).then(res => {
var resObj = JSON.parse(res.data);
1 year ago
if (resObj.code > 400) {
wx.showModal({
title: '提示',
content: resObj.message,
complete: (res) => {
1 year ago
if (res.cancel) {}
if (res.confirm) {}
//上传失败后移除图片
}
})
1 year ago
} else {
//保存图片路径到数组
this.data.upImageArr.push(resObj.data.url);
}
});
},
1 year ago
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log("token=" + app.globalData.token);
//初始化添加按钮
this.setData({
imageArr: [this.data.addImgBtn]
});
1 year ago
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})