Commit 91e7612d by 前端

上传优化

1 parent 32a5259b
...@@ -21,7 +21,7 @@ export default { ...@@ -21,7 +21,7 @@ export default {
voicePath: "", voicePath: "",
timer: null, timer: null,
times: 0, times: 0,
timeout: 3, timeout: 240,
reaction: 1, reaction: 1,
}; };
}, },
...@@ -84,7 +84,6 @@ export default { ...@@ -84,7 +84,6 @@ export default {
this.setAudioInfo({ endReasonType: 1 }); this.setAudioInfo({ endReasonType: 1 });
}, },
getParams() { getParams() {
console.log(this.$store.state.user.customerInfo);
const { shopMerchantId, phone, sceneType,uuid,name,merchantId } = uni.$storage.get("userInfo"), const { shopMerchantId, phone, sceneType,uuid,name,merchantId } = uni.$storage.get("userInfo"),
{ customerName, phoneNumber, salesUuid, carModel, staffName } = { customerName, phoneNumber, salesUuid, carModel, staffName } =
this.$store.state.user.customerInfo, this.$store.state.user.customerInfo,
...@@ -213,7 +212,7 @@ export default { ...@@ -213,7 +212,7 @@ export default {
recorderManager.stop(); recorderManager.stop();
return; return;
} }
if (this.audioInfo.audioStatus == "abnormal") { if (this.audioInfo.audioStatus == "abnormal" && status != true) {
this.setAudioInfo({ audioStatus: "end" }); this.setAudioInfo({ audioStatus: "end" });
this.handleSave(); this.handleSave();
return; return;
......
...@@ -36,25 +36,30 @@ export default { ...@@ -36,25 +36,30 @@ export default {
* @throws {Error} 如果解构对象时缺少关键属性,将抛出错误 * @throws {Error} 如果解构对象时缺少关键属性,将抛出错误
*/ */
handlerMessage(result) { handlerMessage(result) {
const { code, fileName, data, recordId, filePath, filePathOnClient = filePath + fileName } = result.detail.data[0] try{
if (code == 0) { const { code, fileName, data, recordId, filePath, filePathOnClient = filePath + fileName } = result.detail.data[0]
const filePathOnServer = data.oss.res.requestUrls[0].split('?')[0] if (code == 0) {
this.uploadSuccess(recordId, filePathOnServer, filePathOnClient, fileName) const filePathOnServer = data.oss.res.requestUrls[0].split('?')[0]
} else { this.uploadSuccess(recordId, filePathOnServer, filePathOnClient, fileName)
this.reportError(recordId,filePathOnClient) } else {
this.polling() this.reportError(recordId,fileName,data.oss.res)
this.$sendSentry(`上传失败:文件名-${fileName} 错误码-${data.oss.res.status},失败原因-${JSON.stringify(data.oss.res)}`); this.polling()
// this.$sendSentry(`上传失败:文件名-${fileName} 错误码-${data.oss.res.status},失败原因-${JSON.stringify(data.oss.res)}`);
}
}catch(e) {
console.log(e)
} }
}, },
/** /**
* 上报文件上传失败日志 * 上报文件上传失败日志
*/ */
reportError(recordId, filePath) { reportError(recordId, filePath,res) {
const { customerName, phoneNumber, carModel, salesName } = const { customerName, phoneNumber, carModel, salesName } =
uni.$recordManager.getRecordById(recordId) || {}; uni.$recordManager.getRecordById(recordId) || {};
const { name } = uni.$storage.get("userInfo"); const { name } = uni.$storage.get("userInfo");
this.$sendSentry( this.$sendSentry(
`上传失败:文件-${filePath} 手机号-${phoneNumber} 姓名-${customerName} 销售-${salesName} 车型-${carModel} 员工-${name}` `上传失败:文件-${filePath} 手机号-${phoneNumber} 姓名-${customerName} 销售-${salesName} 车型-${carModel} 员工-${name}-错误码-${res.status},失败原因-${JSON.stringify(res)}`
); );
}, },
/** /**
...@@ -229,14 +234,13 @@ export default { ...@@ -229,14 +234,13 @@ export default {
*/ */
flattenData(records) { flattenData(records) {
const result = records.reduce((acc, cur) => { const result = records.reduce((acc, cur) => {
acc = acc.concat( const recordUrlList = cur.recordUrlList.map(file => {
cur.recordUrlList.map(file => { const aFullPath = file.file.split('/')
const aFullPath = file.file.split('/') const fileName = aFullPath.pop()
const fileName = aFullPath.pop() const filePath = aFullPath.join('/') + '/'
const filePath = aFullPath.join('/') + '/' return file.status ? { ...file, recordId: cur.id, fileName, filePath } : []
return { ...file, recordId: cur.id, fileName, filePath } })
}) acc = acc.concat(...recordUrlList)
)
return acc return acc
}, []) }, [])
return result return result
...@@ -268,9 +272,9 @@ export default { ...@@ -268,9 +272,9 @@ export default {
this.pollingLater(interval) this.pollingLater(interval)
} else { } else {
let record = this.snapshot.dequeue() let record = this.snapshot.dequeue()
while(record.file.startsWith('http')) { // while(record.file.startsWith('http')) {
record = this.snapshot.dequeue() // record = this.snapshot.dequeue()
} // }
this.uploadRecord(record) this.uploadRecord(record)
} }
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!