Commit 39f0c8c4 by 前端

fixed

1 parent 48c56546
......@@ -8,6 +8,11 @@
*/
const recorderManager = uni.getRecorderManager();
const plug = uni.requireNativePlugin("html5app-recordaudio");
const UPLOAD_STATUS = {
// 上传状态
success: 1,
fail: 2,
};
import upload from "@/utils/ossUploadFile/uploadFile.js";
import { mapMutations, mapState } from "vuex";
import utils from "@/utils/utils.js";
......@@ -81,6 +86,34 @@ export default {
const file = uni.$storage.get("storageFile");
if (file) this.uploadVoice(file);
},
getParams() {
const { shopMerchantId, phone, sceneType } = uni.$storage.get("userInfo"),
{ customerName, phoneNumber, salesUuid, carModel, staffName } =
this.$store.state.user.customerInfo,
receptionCustomerPaySourceList = this.booksList.map((item) => {
return {
id: item.id,
sourceType: item.id,
sourceUrl: item.imgUrl,
};
}),
params = {
carModel,
endReasonType: this.endReasonType, //原因 1.异常 0.正常
customerName,
phoneNumber,
loginPhone: phone,
salesName: staffName,
salesUuid,
receptionStatus: this.receptionStatus, //接待结果 1.成交 0.战败
receptionStartTime: this.receptionStartTime,
receptionEndTime: this.receptionEndTime,
receptionCustomerPaySourceList, //1.付款凭证文件路径 2.客户购车发票文件路径 3.客户延保合同文件路径
merchantId: shopMerchantId,
bussinessType: sceneType == 0 ? 1 : 2, // sceneType 0延保 1精品。 bussinessType 1.延保 2.轻改
};
return params;
},
//保存录音记录及其他信息
async uploadVoice(tempFilePath) {
try {
......@@ -166,14 +199,15 @@ export default {
console.error("上传失败:", result);
const { customerName, phoneNumber, salesUuid, carModel, staffName } =
this.$store.state.user.customerInfo;
const { name } = uni.$storage.get("userInfo");
this.$sendSentry(
`上传文件失败:手机号-${phoneNumber} 姓名-${customerName} 销售-${staffName} 车型-${carModel} 销售-${salesUuid}`
`上传文件失败:手机号-${phoneNumber} 姓名-${customerName} 销售-${staffName} 车型-${carModel} 员工-${name},失败原因-${result}`
);
// this.handleErrorFile(res.tempFilePath, "error");
// this.handleErrorFile(res.tempFilePath, UPLOAD_STATUS.fail);
// return;
} else {
// this.handleErrorFile(result, "success");
// this.handleErrorFile(result, UPLOAD_STATUS.success);
}
const storageFile = [...this.audioList, result];
uni.$storage.set("storageFile", storageFile);
......@@ -185,12 +219,13 @@ export default {
},
/**保存记录*/
saveRecord() {
const fileList = JSON.parse(uni.$storage.get("errorFile") || "[]");
const recordUrlList = JSON.parse(uni.$storage.get("errorFile") || "[]");
let recordList = JSON.parse(uni.$storage.get("recordList") || "[]");
recordList = [
...recordList,
{
fileList,
...this.getParams(),
recordUrlList,
},
];
uni.$storage.set("recordList", JSON.stringify(recordList));
......@@ -198,7 +233,9 @@ export default {
/**是否存在错误文件*/
hasErrorFile() {
const fileList = JSON.parse(uni.$storage.get("errorFile") || "[]");
const errorFileList = fileList.filter((item) => item.status == "error");
const errorFileList = fileList.filter(
(item) => item.status == UPLOAD_STATUS.fail
);
return errorFileList.length > 0;
},
/**处理失败的文件*/
......@@ -207,15 +244,40 @@ export default {
const errorFile = [...errorFileList, { file, status }];
uni.$storage.set("errorFile", JSON.stringify(errorFile));
},
handleRerord() {},
/**上传记录*/
async handleRerord(val) {
let recordList = JSON.parse(uni.$storage.get("recordList") || "[]");
let idx = recordList.findIndex(
(item) => item.receptionStartTime == val.receptionStartTime
);
let recordUrlList = val.recordUrlList;
// 上传失败的记录
for (let i of recordUrlList) {
if (i.status == UPLOAD_STATUS.fail) {
const result = await this.checkUploadFile(i.file);
if (!(result instanceof Error)) {
i.status = UPLOAD_STATUS.success;
}
}
}
// 判断是否全部上传成功
if (recordUrlList.every((i) => i.status == UPLOAD_STATUS.success)) {
recordList.splice(idx, 1);
val.recordUrlList = val.recordUrlList.map((i) => i.file);
this.uploadVoice(val);
uni.$storage.set("recordList", JSON.stringify(recordList));
}
},
async checkUploadFile(tempFilePath) {
let attempt = 0;
let errorMsg = "";
while (attempt < 3) {
try {
const result = await upload(tempFilePath);
// 上传成功
return result;
} catch (error) {
errorMsg = error;
attempt++;
// 等待一段时间后重试
await new Promise((resolve) => setTimeout(resolve, 3000)); // 3秒后重试
......@@ -224,7 +286,7 @@ export default {
// 达到最大尝试次数后,如果上传仍然失败,可以进行相应的处理
console.error("上传失败,达到最大尝试次数");
// 返回一个错误或者进行其他操作
return new Error("上传失败");
return new Error(errorMsg);
},
//结束录音
stopAudio: utils.throttle(async function () {
......
......@@ -150,7 +150,7 @@ export default {
}
.box {
padding: 64rpx;
margin-top: 120rpx;
margin-top: 90rpx;
.input-box {
position: relative;
.input {
......@@ -192,7 +192,7 @@ export default {
}
}
.record-box {
height: calc(100vh - 300rpx);
height: calc(100vh - 250rpx);
padding-top: 48rpx;
}
.list {
......@@ -200,7 +200,7 @@ export default {
grid-template-columns: repeat(5, 1fr);
gap: 48rpx 50rpx;
.item {
height: 544rpx;
height: 536rpx;
background: #ffffff;
border-radius: 48rpx;
box-shadow: 0 8rpx 24rpx 0 #4673ff1a;
......@@ -223,7 +223,7 @@ export default {
}
.item-desc {
height: 140rpx;
padding: 28rpx 32rpx;
padding: 24rpx 28rpx;
font-size: 32rpx;
color: #333333;
border-radius: 48rpx;
......
......@@ -134,6 +134,9 @@ import Record from "@/mixin/record";
export default {
name: '',
mixins:[Record],
props: {
show: Boolean
},
data() {
return {
imageUrl: require('@/assets/images/noviceGuide/step1-1.webp'),
......@@ -153,13 +156,8 @@ export default {
],
}
},
computed: {
watchStatus () {
return this.$store.state.user.historyStatus
},
},
watch:{
watchStatus: {
show: {
handler() {
this.changeIndex(1,true)
},
......@@ -195,7 +193,6 @@ export default {
this.getRecordList()
},
getRecordList() {
const { pageNum, pageSize,groupIndex } = this,
userInfo = uni.$storage.get("userInfo"),
{ shopMerchantId } = userInfo;
......@@ -260,7 +257,7 @@ export default {
.box {
padding: 64rpx;
margin-top: 120rpx;
margin-top: 90rpx;
.data-tabs-box {
position: relative;
......@@ -322,7 +319,7 @@ export default {
}
}
.record-box {
height: calc(100vh - 300rpx);
height: calc(100vh - 250rpx);
padding-top: 48rpx;
}
.end-text {
......
......@@ -90,7 +90,6 @@ import Record from "@/mixin/record";
export default {
mixins: [Record],
props: {
customerType: Number,
show: Boolean
},
data () {
......@@ -109,13 +108,8 @@ export default {
chooseItem: {}
}
},
computed: {
watchStatus () {
return this.$store.state.user.historyStatus
},
},
watch:{
watchStatus:{
show:{
handler() {
this.init()
},
......@@ -236,7 +230,7 @@ export default {
}
.box {
padding: 64rpx;
margin-top: 120rpx;
margin-top: 90rpx;
.input-box {
position: relative;
.input {
......@@ -277,7 +271,7 @@ export default {
}
}
.record-box {
height: calc(100vh - 300rpx);
height: calc(100vh - 250rpx);
padding-top: 48rpx;
}
.end-text {
......
......@@ -34,12 +34,19 @@ export default {
this.title = tabName
this.sourceType = sourceType
this.detailUrl = detailUrl
const img = new Image()
img.onload = ()=> {
this.width = document.querySelector('.img-detail').offsetHeight*img.height/img.width
console.log(this.width)
}
img.src = detailUrl
const _this = this
uni.getImageInfo({
src: detailUrl, // 替换为你的图片路径
success (img) {
uni.createSelectorQuery().select('.img-detail').boundingClientRect(function(rect) {
_this.width = rect.height*img.height/img.width
}).exec();
},
fail: function (error) {
console.error('获取图片信息失败:', error);
}
});
},
methods: {
back() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!