Commit 27caa73f by 李伟康

Merge branch 'v1.0.7' of http://192.168.3.233:8090/glsx/gl_tape into v1.0.7

2 parents 62fdd1a4 fb87ef72
...@@ -24,6 +24,7 @@ Vue.component("UpdateBox", UpdateBox); ...@@ -24,6 +24,7 @@ Vue.component("UpdateBox", UpdateBox);
uni.$api = api; uni.$api = api;
uni.$storage = new Storage(); uni.$storage = new Storage();
uni.$throttle = utils.throttle; uni.$throttle = utils.throttle;
uni.$isNetWork = utils.isNetWork;
Vue.config.productionTip = false; Vue.config.productionTip = false;
App.mpType = "app"; App.mpType = "app";
Vue.prototype.$ossDomain = config.OSS_DOMAIN; Vue.prototype.$ossDomain = config.OSS_DOMAIN;
......
...@@ -77,11 +77,6 @@ export default { ...@@ -77,11 +77,6 @@ export default {
this.times = 0; this.times = 0;
this.$refs.tipBox?.close(); this.$refs.tipBox?.close();
}, },
//检查缓存录音
checkVoice() {
const file = uni.$storage.get("storageFile");
if (file) this.uploadVoice(file);
},
getParams() { getParams() {
const { shopMerchantId, phone, sceneType } = uni.$storage.get("userInfo"), const { shopMerchantId, phone, sceneType } = uni.$storage.get("userInfo"),
{ customerName, phoneNumber, salesUuid, carModel, staffName } = { customerName, phoneNumber, salesUuid, carModel, staffName } =
...@@ -112,60 +107,6 @@ export default { ...@@ -112,60 +107,6 @@ export default {
}; };
return params; return params;
}, },
//保存录音记录及其他信息
async uploadVoice(tempFilePath) {
try {
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,
};
}),
{ receptionStartTime, receptionEndTime, endReasonType } =
this.audioInfo,
params = {
carModel,
endReasonType, //原因 1.异常 0.正常
customerName,
phoneNumber,
loginPhone: phone,
salesName: staffName,
salesUuid,
receptionStatus: this.receptionStatus, //接待结果 1.成交 0.战败
recordUrlList: tempFilePath,
receptionStartTime,
receptionEndTime,
receptionCustomerPaySourceList, //1.付款凭证文件路径 2.客户购车发票文件路径 3.客户延保合同文件路径
merchantId: shopMerchantId,
bussinessType: sceneType == 0 ? 1 : 2, // sceneType 0延保 1精品。 bussinessType 1.延保 2.轻改
};
console.log(
customerName,
phoneNumber,
salesUuid,
carModel,
tempFilePath
);
if (customerName && phoneNumber && salesUuid) {
uni.$api.commonApi.saveRecCustomer(params).then((res) => {
console.log(res, params);
});
}
this.setBooks([]);
this.$store.dispatch("clearCustomerInfo");
this.setReceptionStatus(1);
this.setAudioInfo({ endReasonType: 0, audioStatus: "finish" });
uni.$storage.set("storageFile", "");
} catch (error) {
this.$store.dispatch("clearCustomerInfo");
console.log(error);
}
},
//开始录音 //开始录音
async startAudio() { async startAudio() {
if (this.audioInfo.audioStatus == "start") return; if (this.audioInfo.audioStatus == "start") return;
...@@ -194,41 +135,34 @@ export default { ...@@ -194,41 +135,34 @@ export default {
}); });
return; return;
} }
// const isContinue = this.hasErrorFile(); const saveResult = await uni.saveFile({
// if (isContinue) { tempFilePath: res.tempFilePath,
// this.handleErrorFile(res.tempFilePath); }); // 保存文件到本地
// if (this.audioInfo.audioStatus == 'end') { //删除默认文件
// this.saveRecord(); uni.removeSavedFile({
// } filePath: res.tempFilePath,
// return; complete: function (res) {
// } console.log(res);
const result = await this.checkUploadFile(res.tempFilePath); },
if (result instanceof Error) { });
console.error("上传失败:", result); this.handleSave(saveResult);
const { customerName, phoneNumber, salesUuid, carModel, staffName } =
this.$store.state.user.customerInfo;
const { name } = uni.$storage.get("userInfo");
this.$sendSentry(
`重试多次失败:手机号-${phoneNumber} 姓名-${customerName} 销售-${staffName} 车型-${carModel} 员工-${name},失败原因-${result}`
);
// this.handleErrorFile(res.tempFilePath, UPLOAD_STATUS.fail);
// return;
} else {
// this.handleErrorFile(result, UPLOAD_STATUS.success);
}
const storageFile = [...this.audioInfo.audioList, result];
uni.$storage.set("storageFile", storageFile);
this.setAudioInfo({ audioList: storageFile });
if (this.audioInfo.audioStatus == "start") {
return;
}
this.uploadVoice(storageFile);
}); });
}, },
handleSave(file) {
if (this.audioInfo.audioStatus == "end") {
this.saveRecord();
this.setBooks([]);
this.$store.dispatch("clearCustomerInfo");
this.setReceptionStatus(1);
this.setAudioInfo({ endReasonType: 0, audioStatus: "finish" });
} else {
const audioList = [...this.audioInfo.audioList, file];
this.setAudioInfo({ audioList });
}
},
/**保存记录*/ /**保存记录*/
saveRecord() { saveRecord() {
const recordUrlList = JSON.parse(uni.$storage.get("errorFile") || "[]"); const recordUrlList = this.audioInfo.audioList;
let recordList = JSON.parse(uni.$storage.get("recordList") || "[]"); let recordList = JSON.parse(uni.$storage.get("recordList") || "[]");
recordList = [ recordList = [
...recordList, ...recordList,
...@@ -239,67 +173,6 @@ export default { ...@@ -239,67 +173,6 @@ export default {
]; ];
uni.$storage.set("recordList", JSON.stringify(recordList)); uni.$storage.set("recordList", JSON.stringify(recordList));
}, },
/**是否存在错误文件*/
hasErrorFile() {
const fileList = JSON.parse(uni.$storage.get("errorFile") || "[]");
const errorFileList = fileList.filter(
(item) => item.status == UPLOAD_STATUS.fail
);
return errorFileList.length > 0;
},
/**处理失败的文件*/
handleErrorFile(file, status) {
const errorFileList = JSON.parse(uni.$storage.get("errorFile") || "[]");
const errorFile = [...errorFileList, { file, status }];
uni.$storage.set("errorFile", JSON.stringify(errorFile));
},
/**上传记录*/
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 < 5) {
try {
const result = await upload(tempFilePath);
// 上传成功
return result;
} catch (error) {
if (attempt == 0) {
this.$sendSentry(`第一次上传失败:文件${tempFilePath}`);
}
errorMsg = error;
attempt++;
// 等待一段时间后重试
await new Promise((resolve) => setTimeout(resolve, 3000)); // 3秒后重试
}
}
// 达到最大尝试次数后,如果上传仍然失败,可以进行相应的处理
console.error("上传失败,达到最大尝试次数");
// 返回一个错误或者进行其他操作
return new Error(errorMsg);
},
//结束接待 //结束接待
stopAudio: utils.throttle(async function (status) { stopAudio: utils.throttle(async function (status) {
// const result = await this.$permision.requestAndroidPermission( // const result = await this.$permision.requestAndroidPermission(
...@@ -322,12 +195,7 @@ export default { ...@@ -322,12 +195,7 @@ export default {
if (!status) { if (!status) {
uni.showLoading({ uni.showLoading({
mask: true, mask: true,
title: "处理中请稍后...",
}); });
// setTimeout(() => {
// uni.hideLoading();
// clearInterval(finish_timer);
// }, 1000 * 60);
} }
this.times = 0; this.times = 0;
clearInterval(this.timer); clearInterval(this.timer);
......
const UPLOAD_STATUS = {
// 上传状态
success: 1,
fail: 2,
};
import upload from "@/utils/ossUploadFile/uploadFile.js";
import utils from "@/utils/utils.js";
export default {
mounted() {
// this.checkRecord();
// setInterval(() => {
// this.checkRecord();
// }, 1000 * 60 * 10);
},
methods: {
checkRecord() {
utils.isNetWork().then(async (res) => {
let recordList = JSON.parse(uni.$storage.get("recordList") || "[]");
console.log(recordList, "recordList");
for (let i = 0; i < recordList.length; i++) {
await this.handleRerord(recordList[i]);
}
});
},
/**上传记录*/
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 filePath = i.file;
console.log(filePath, "filePath");
const result = await this.checkFileUpload(filePath);
if (!(result instanceof Error)) {
i.status = UPLOAD_STATUS.success;
i.file = result;
}
}
}
// 判断是否全部上传成功
if (recordUrlList.every((i) => i.status == UPLOAD_STATUS.success)) {
val.recordUrlList = val.recordUrlList.map((i) => i.file);
try {
const res = await uni.$api.commonApi.saveRecCustomer(val);
console.log(res, val);
recordList.splice(idx, 1);
uni.$storage.set("recordList", JSON.stringify(recordList));
} catch (err) {
Promise.reject(error);
}
}
},
async checkFileUpload(tempFilePath) {
console.log(tempFilePath);
let attempt = 0;
let errorMsg = "";
while (attempt < 2) {
try {
const result = await upload(tempFilePath);
// 上传成功
return result;
} catch (error) {
errorMsg = error;
attempt++;
// 等待一段时间后重试
await new Promise((resolve) => setTimeout(resolve, 3000)); // 3秒后重试
}
}
// 达到最大尝试次数后,如果上传仍然失败,可以进行相应的处理
console.error("上传失败,达到最大尝试次数");
// 返回一个错误或者进行其他操作
return new Error(errorMsg);
},
},
};
<!--
* @Description:
* @Author: huyue
* @Date: 2024-06-24 16:35:00
* @LastEditors: huyue
* @LastEditTime: 2024-06-25 13:53:14
-->
<template>
<view class="layout">
<wnCanvas
:drawStatus="penSwitch"
:canvasId="`c-${madiaId}`"
custom
>
<template slot="customContent">
<view class="title">{{title}}</view>
<image
class="icon-car"
src="https://img02.glsx.com.cn/weapp/resource/app-tape/media/common/icon-car.webp"
/>
<view class="container">
<view class="left-tab" >
<view class="tab-item" v-for="item in list" :key="item.id" @click="tabChange(item)" :class="[item.id == activeIndex ? 'active' : '']">{{item.name}}</view>
</view>
<view class="content">
<template v-if="activeIndex == 2">
<image
:key="imgKey" :class="direction"
class="content-image"
:src="`https://img02.glsx.com.cn/weapp/resource/app-tape/media/common/${list[activeIndex - 1].urlName}-${tabIndex}.webp`"
/>
<view class="content-tab">
<view class="tab-item" @click="tabSwitch(1)"></view>
<view class="tab-item" @click="tabSwitch(2)"></view>
</view>
</template>
<template v-else>
<image
:key="imgKey" :class="direction"
class="content-image"
:src="`https://img02.glsx.com.cn/weapp/resource/app-tape/media/common/${list[activeIndex - 1].urlName}.webp`"
/>
</template>
</view>
</view>
</template>
</wnCanvas>
</view>
</template>
<script type='text/ecmascript-6'>
export default {
props: {
views: Array,
penSwitch: Boolean,
title: String,
madiaId: Number,
},
name: 'MediaComponent',
data () {
return {
activeIndex: 1,
list: [
{
id: 1,
name: '整车质保',
urlName: '5-1'
},
{
id: 2,
name: '零部件范围及质保期',
urlName: '5-2'
},
{
id: 3,
name: '三包凭证',
urlName: '5-3'
}
],
direction: 'bottom',
imgKey: Date.now(),
tabIndex: 1
}
},
mounted () {
},
methods: {
tabChange(item) {
if (this.activeIndex === id) return
const { id } = item
this.direction = ''
console.log(id, this.activeIndex,' !!!!!!!!!!')
this.direction = id > this.activeIndex ? 'bottom' : 'top'
this.activeIndex = id
this.imgKey = Date.now()
},
tabSwitch(val) {
console.log(val)
if (val == this.tabIndex) return
this.tabIndex = val
}
}
}
</script>
<style scoped lang='scss'>
.layout {
width: 100vw;
height: 100vh;
position: relative;
background-image: url("@/assets/images/media/media-bg.webp");
background-size: 100%;
.title {
position: absolute;
left: 0;
top: 112rpx;
font-weight: 500;
font-size: 48rpx;
color: #1a1a1a;
letter-spacing: 4rpx;
line-height: 64rpx;
text-align: center;
width: 100%;
z-index: 2;
}
.container {
display: flex;
align-items: center;
padding-top: 248rpx;
padding-bottom: 96rpx;
height: 100%;
margin: 0 80rpx;
.left-tab {
width: 360rpx;
margin-right: 48rpx;
.tab-item {
display: flex;
padding: 0 76rpx;
box-sizing: border-box;
align-items: center;
// justify-content: center;
width: 100%;
height: 312rpx;
background: #F2F5FF;
border: 4rpx solid hsl(0, 80%, 100%);
box-shadow: inset 0 0 16rpx 0 #FFFFFF;
border-radius: 32rpx;
margin-bottom: 48rpx;
font-weight: 500;
font-size: 40rpx;
color: #1A1A1A;
&:last-child {
margin-bottom: 0;
}
&.active {
color: #fff;
background-image: linear-gradient(180deg, #6795FF 0%, #4A84F9 100%);
box-shadow: 16px 16px 24px 0 #849dc240, inset 0 0 16px 0 #FFFFFF;
}
}
}
.content {
background-color: rgba(255, 255, 255, 0.4);
backdrop-filter: blur(4px);
z-index: 1;
border-radius: 64rpx;
position: relative;
&-tab {
display: flex;
position: absolute;
width: 100%;
top: 0;
height: 112rpx;
z-index: 1;
.tab-item {
width: 50%;
height: 100%;
}
}
}
.content-image {
width: 1778rpx;
height: 1192rpx;
}
}
.icon-car {
position: absolute;
bottom: 0;
right: 0;
width: 952rpx;
height: 248rpx;
}
}
.top {
animation: show-view-top 0.5s;
}
.bottom {
animation: show-view-bottom 0.3s;
}
@keyframes show-view-top {
0% {
opacity: 0;
transform: translateY(-224rpx);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
@keyframes show-view-bottom {
0% {
opacity: 0;
transform: translateY(100%);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
</style>
\ No newline at end of file \ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* @Author: huyue * @Author: huyue
* @Date: 2024-04-08 11:30:30 * @Date: 2024-04-08 11:30:30
* @LastEditors: huyue * @LastEditors: huyue
* @LastEditTime: 2024-06-24 13:52:12 * @LastEditTime: 2024-06-24 16:41:54
--> -->
<template> <template>
<view <view
...@@ -72,6 +72,7 @@ import Reception from "./components/Reception.vue"; ...@@ -72,6 +72,7 @@ import Reception from "./components/Reception.vue";
import MediaComponent from "./components/MediaComponent.vue"; import MediaComponent from "./components/MediaComponent.vue";
import Media_6 from "./components/Media_6.vue"; import Media_6 from "./components/Media_6.vue";
import History from "./components/History.vue"; import History from "./components/History.vue";
import ThreeGuarantees from "./components/ThreeGuarantees.vue";
import Guarantee from './components/Guarantee.vue'; import Guarantee from './components/Guarantee.vue';
import payPop from "./components/payPop.vue"; import payPop from "./components/payPop.vue";
import FinishStep from '@/components/FinishStep.vue'; import FinishStep from '@/components/FinishStep.vue';
...@@ -85,7 +86,8 @@ export default { ...@@ -85,7 +86,8 @@ export default {
payPop, payPop,
FinishStep, FinishStep,
Guarantee, Guarantee,
History History,
ThreeGuarantees
}, },
props: { props: {
id: [String, Number], id: [String, Number],
......
...@@ -16,7 +16,8 @@ export const STORAGE_OBJECTkEY = { ...@@ -16,7 +16,8 @@ export const STORAGE_OBJECTkEY = {
noSignInUuid: "noSignInUuid", noSignInUuid: "noSignInUuid",
noviceGuideStatus: "noviceGuideStatus", noviceGuideStatus: "noviceGuideStatus",
carBrandList:'carBrandList', carBrandList:'carBrandList',
employeeList:'employeeList' employeeList:'employeeList',
recordList: "recordList",
}; };
// export const IMG_VERSION = async () => { // export const IMG_VERSION = async () => {
......
...@@ -76,10 +76,25 @@ var throttle = function (fn, delay) { ...@@ -76,10 +76,25 @@ var throttle = function (fn, delay) {
}, delay); }, delay);
}; };
}; };
//检查是否有网络
var isNetWork = function () {
return new Promise((resolve, reject) => {
uni.getNetworkType({
complete: function (res) {
if (res.networkType == "none") {
reject();
} else {
resolve();
}
},
});
});
};
export default { export default {
convertDateTimeFormat, convertDateTimeFormat,
deepClone, deepClone,
accDiv, accDiv,
debounce, debounce,
throttle, throttle,
isNetWork,
}; };
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!