Commit 91e7612d by 前端

上传优化

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