|
|
|
@ -10,7 +10,8 @@ Page({
|
|
|
|
|
myData:{ |
|
|
|
|
contact:'', |
|
|
|
|
contactDetail:'', |
|
|
|
|
suggestion:'' |
|
|
|
|
suggestion:'', |
|
|
|
|
attachment:[] |
|
|
|
|
}, |
|
|
|
|
files: [], |
|
|
|
|
filesUrl:'' |
|
|
|
@ -90,6 +91,24 @@ Page({
|
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
submit(){ |
|
|
|
|
this.data.myData.attachment=this.data.myData.attachment.join(',') |
|
|
|
|
$api.feedback(this.data.myData).then(res=>{ |
|
|
|
|
if(res.msg=='ok'){ |
|
|
|
|
wx.showToast({ |
|
|
|
|
title: '成功', |
|
|
|
|
icon: 'success', |
|
|
|
|
duration: 2000 |
|
|
|
|
}) |
|
|
|
|
this.setData({ |
|
|
|
|
myData:{ |
|
|
|
|
contact:'', |
|
|
|
|
contactDetail:'', |
|
|
|
|
suggestion:'', |
|
|
|
|
attachment:[] |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
console.log(this.data.myData) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -122,16 +141,9 @@ uplaodFile(files) {
|
|
|
|
|
resolve(object); |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
deleteFile(e){ |
|
|
|
|
this.data.myData.attachment.splice(e.detail.index,1); |
|
|
|
|
}, |
|
|
|
|
selectFile(files) { |
|
|
|
|
console.log('files', files) |
|
|
|
|
// 返回false可以阻止某次文件上传
|
|
|
|
@ -141,8 +153,29 @@ uplaodFile(files) {
|
|
|
|
|
}, |
|
|
|
|
uploadSuccess(e) { |
|
|
|
|
|
|
|
|
|
console.log(e.detail) |
|
|
|
|
|
|
|
|
|
const _this=this; |
|
|
|
|
let token = wx.getStorageSync('access_token') |
|
|
|
|
let Authorization =token?`Bearer ${token}`:'Basic YXBwOmFwcA==' |
|
|
|
|
let formData = new FormData(); |
|
|
|
|
formData.appendFile("file", e.detail.urls[0]); |
|
|
|
|
let data = formData.getData(); |
|
|
|
|
wx.request({ |
|
|
|
|
url: 'http://192.168.24.3:9002/file', |
|
|
|
|
header: { |
|
|
|
|
'content-type': data.contentType, |
|
|
|
|
'Authorization': Authorization, |
|
|
|
|
}, |
|
|
|
|
method: "POST", |
|
|
|
|
data: data.buffer, |
|
|
|
|
success(res) { |
|
|
|
|
// console.log(res)
|
|
|
|
|
_this.data.myData.attachment.push(res.data.data.path) |
|
|
|
|
}, |
|
|
|
|
fail(err) { |
|
|
|
|
//请求失败
|
|
|
|
|
console.log(err) |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
// $api.uploadImg(formData).then(res=>{
|
|
|
|
|
// console.log(res)
|
|
|
|
|
// })
|
|
|
|
|