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

183 lines
3.3 KiB

// pages/feedback/feedback.js
const request = require('../../utils/http')
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
array: ['请选择', 'bug问题', '业务问题', '功能使用问题', '其他'],
objectArray: [{
id: 0,
name: '请选择'
},
{
id: 1,
name: 'bug问题'
},
{
id: 2,
name: '业务问题'
},
{
id: 3,
name: '功能使用问题'
},
{
id: 4,
name: '其他'
}
],
index: 0,
srxI: '',
//图片数组
addImgBtn: {
isBtn: true,
text: "+",
func: "addImage"
},
imageArr: []
},
bindPickerChange(e) {
this.setData({
index: e.detail.value
})
},
//提交数据
goMyorder() {
if(this.data.index === 0){
wx.showToast({
title: '请选择问题类型',
});
return;
}
var problem = objectArray[this.data.index]; //问题类型
request.post(`/feedBack/push?type=${this.data.index}&describe=${problem}`).then(res=>{
});
// 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) {
console.log("imgSrc=" + 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 === 500){
wx.showModal({
title: '提示',
content: resObj.message,
complete: (res) => {
if (res.cancel) {
}
if (res.confirm) {
}
//移除图片
}
})
}
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log("token=" + app.globalData.token);
//初始化添加按钮
this.setData({
imageArr: [this.data.addImgBtn]
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})