物流端
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

193 lines
3.6 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
})
},
//提交数据
goMyorder() {
if (this.data.index === 0) {
wx.showToast({
title: '请选择问题类型',
});
return;
}
var problem = this.data.problemArray[this.data.index]; //问题类型
var data = {
'type': this.data.index,
'describe': this.data.problemStr,
'imgs':this.data.upImageArr.toString
}
console.log(JSON.stringify(data))
request.post(`/feedBack/push`, data).then(res => {
wx.showToast({
title: 'title',
})
console.log(JSON.stringify(res.data))
});
// wx.switchTab({
// url: '../about/about',
// })
//判断是否选择问题类型
//当没有描述时,弹框提示,但不是强制性。
//判断是否有上传截图
//提示成功后,点击确定,返回上一页。
},
//添加图片
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() {
}
})