|
|
@@ -223,62 +223,66 @@ Page({ |
|
|
|
/* 表单上传 */ |
|
|
|
submit(){ |
|
|
|
this.validateForm().then(res => { |
|
|
|
let ossForm = this.data.ossForm |
|
|
|
let temp = [] |
|
|
|
if (this.data.imageList.length > 0) { |
|
|
|
wx.showLoading({title:"上传中",mask:true}) |
|
|
|
temp = this.data.imageList.map(item => { |
|
|
|
// 设置文件上传路径 |
|
|
|
const randomString = Math.random().toString(36).slice(2) |
|
|
|
const timestamp = new Date().getTime() |
|
|
|
const key = `imagedir/${randomString}_${timestamp}.png` |
|
|
|
// 上传图片 |
|
|
|
return new Promise((resolve, reject)=> { |
|
|
|
wx.uploadFile({ |
|
|
|
url: 'https://ta-tech-image.oss-cn-shanghai.aliyuncs.com', |
|
|
|
filePath: item, |
|
|
|
name: 'file', |
|
|
|
formData: { |
|
|
|
key, |
|
|
|
OSSAccessKeyId: ossForm.OSSAccessKeyId, |
|
|
|
signature: ossForm.signature, |
|
|
|
policy: ossForm.policy, |
|
|
|
'x-oss-security-token': ossForm.SecurityToken |
|
|
|
}, |
|
|
|
success: (res)=> { |
|
|
|
if(res.statusCode === 204) { |
|
|
|
// 上传成功,将图片路径resolve出去 |
|
|
|
resolve(key) |
|
|
|
} else { |
|
|
|
wx.showToast({ |
|
|
|
title: '图片上传失败', |
|
|
|
}) |
|
|
|
if(res) { |
|
|
|
let ossForm = this.data.ossForm |
|
|
|
let temp = [] |
|
|
|
if (this.data.imageList.length > 0) { |
|
|
|
wx.showLoading({title:"上传中",mask:true}) |
|
|
|
temp = this.data.imageList.map(item => { |
|
|
|
// 设置文件上传路径 |
|
|
|
const randomString = Math.random().toString(36).slice(2) |
|
|
|
const timestamp = new Date().getTime() |
|
|
|
const key = `imagedir/${randomString}_${timestamp}.png` |
|
|
|
// 上传图片 |
|
|
|
return new Promise((resolve, reject)=> { |
|
|
|
wx.uploadFile({ |
|
|
|
url: 'https://ta-tech-image.oss-cn-shanghai.aliyuncs.com', |
|
|
|
filePath: item, |
|
|
|
name: 'file', |
|
|
|
formData: { |
|
|
|
key, |
|
|
|
OSSAccessKeyId: ossForm.OSSAccessKeyId, |
|
|
|
signature: ossForm.signature, |
|
|
|
policy: ossForm.policy, |
|
|
|
'x-oss-security-token': ossForm.SecurityToken |
|
|
|
}, |
|
|
|
success: (res)=> { |
|
|
|
if(res.statusCode === 204) { |
|
|
|
// 上传成功,将图片路径resolve出去 |
|
|
|
resolve(key) |
|
|
|
} else { |
|
|
|
wx.showToast({ |
|
|
|
title: '图片上传失败', |
|
|
|
}) |
|
|
|
reject('图片上传失败') |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: (e)=> { |
|
|
|
console.log(e); |
|
|
|
reject('图片上传失败') |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: (e)=> { |
|
|
|
console.log(e); |
|
|
|
reject('图片上传失败') |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
Promise.all(temp).then((res)=> { |
|
|
|
let form = this.data.form; |
|
|
|
form.feedbackUrl = res.join(',') |
|
|
|
feedbackPosition(form).then(res => { |
|
|
|
if (res.code === 0) { |
|
|
|
wx.reLaunch({ |
|
|
|
url: '/package_A/pages/submitSuccess/index', |
|
|
|
}) |
|
|
|
} |
|
|
|
}).finally(()=>{ |
|
|
|
wx.hideLoading(); |
|
|
|
Promise.all(temp).then((res)=> { |
|
|
|
let form = this.data.form; |
|
|
|
form.feedbackUrl = res.join(',') |
|
|
|
|
|
|
|
feedbackPosition(form).then(res => { |
|
|
|
if (res.code === 0) { |
|
|
|
wx.reLaunch({ |
|
|
|
url: '/package_A/pages/submitSuccess/index', |
|
|
|
}) |
|
|
|
} |
|
|
|
}).finally(()=>{ |
|
|
|
wx.hideLoading(); |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
}).catch(()=> { |
|
|
|
wx.hideLoading() |
|
|
|
}) |
|
|
|
|
|
|
|
}).catch(()=> { |
|
|
|
wx.hideLoading() |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
|