Commit fb87ef72 by 胡悦

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

2 parents 182ccda0 f0896682
<template> <template>
<scroll-view <view class="record-box">
class="record-box"
scroll-y
@scrolltolower="pageonReachBottom"
@scroll="scroll"
>
<view class="record-content"> <view class="record-content">
<view class="data-box"> <view class="data-box">
<template v-for="(i, index) in dataList"> <template v-for="(i, index) in dataList">
<view <view :class="['data-item', i.type]" :key="index">
:class="['data-item', i.type]" <image :src="i.icon" class="data-item-bg" />
:key="index"
>
<image
:src="i.icon"
class="data-item-bg"
/>
<view class="title">{{ dateList[index].text }}</view> <view class="title">{{ dateList[index].text }}</view>
<view class="content"> <view class="content">
<view class="total"> <view class="total">
...@@ -37,45 +26,79 @@ ...@@ -37,45 +26,79 @@
</view> </view>
</template> </template>
</view> </view>
<view :class="['data-tabs-box', { sticky: sticky }]"> <view class="data-container">
<view :class="['type-box']">
<view
class="tab-item"
v-for="(i, index) in typeList"
:key="index"
@click="changeType(index, 'firstIndex')"
>
<view
class="sprite-icon"
:class="[
firstIndex == index ? `icon-${firstClass[index]} active` : '',
]"
:style="{ left: firstLeft[index] }"
></view>
<view class="text" :class="[firstIndex == index ? `active` : '']"
>{{ i.tabName
}}{{
i.num && recordFailList.length > 0
? `(${recordFailList.length})`
: ""
}}</view
>
</view>
</view>
<view class="tabs-bottom"></view>
<view v-if="firstIndex == 0" class="data-tabs-box">
<view class="data-tabs"> <view class="data-tabs">
<template v-for="(i, index) in dateList"> <template v-for="(i, index) in dateList">
<view <view
:class="['tab flex', { active: dateIndex == index }]" :class="['tab flex', { active: dateIndex == index }]"
:key="index" :key="index"
@click="changeIndex(index)" @click="changeIndex(index)"
>{{ i.text }}</view> >{{ i.text }}</view
>
</template> </template>
<view :class="['active-btn', `active-btn-${dateIndex}`]"></view> <view :class="['active-btn', `active-btn-${dateIndex}`]"></view>
</view> </view>
</view> </view>
<scroll-view
class="record-list"
:style="{
height:
firstIndex == 0 ? 'calc(100% - 300rpx)' : 'calc(100% - 180rpx)',
}"
scroll-y
@scrolltolower="pageonReachBottom"
@scroll="scroll"
>
<view class="list"> <view class="list">
<template v-if="flag"> <template v-if="flag">
<template v-if="list.length && list[0] && list[0].length"> <template v-if="list.length && list[0] && list[0].length">
<template v-for="i in list"> <template v-for="i in list">
<template v-for="item in i"> <template v-for="item in i">
<view class="item" :key="item.id">
<view <view
class="item" :class="[
:key="item.id"
>
<view :class="[
'status flex', 'status flex',
{ deal: item.receptionStatus == 1 }, { deal: item.receptionStatus == 1 },
]">{{ ]"
>{{
{ {
1: "成交", 1: "成交",
0: "战败", 0: "战败",
}[item.receptionStatus] }[item.receptionStatus]
}}</view> }}</view
>
<view class="name"> <view class="name">
{{ item.customerName }} {{ item.customerName }}
</view> </view>
<view class="goods-name">{{ item.carModel }}</view> <view class="goods-name">{{ item.carModel }}</view>
<template v-for="(k, ind) in itemObject"> <template v-for="(k, ind) in itemObject">
<view <view class="info flex" :key="ind">
class="info flex"
:key="ind"
>
<view class="label">{{ k.label }}</view> <view class="label">{{ k.label }}</view>
<view class="value">{{ item[k.key] || "-" }}</view> <view class="value">{{ item[k.key] || "-" }}</view>
</view> </view>
...@@ -98,21 +121,26 @@ ...@@ -98,21 +121,26 @@
<template v-if="nothing"> <template v-if="nothing">
<view class="end-text">到底了!</view> <view class="end-text">到底了!</view>
</template> </template>
</scroll-view>
</view> </view>
<view class="bottom-mask"></view> <view class="bottom-mask"></view>
</scroll-view> </view>
</view>
</template> </template>
<script type="text/ecmascript-6"> <script type="text/ecmascript-6">
import dayjs from 'dayjs' import dayjs from 'dayjs'
const dayImgUrl = require('@/assets/images/common/day.webp') const dayImgUrl = require('@/assets/images/common/day.webp')
const weekImgUrl = require('@/assets/images/common/week.webp') const weekImgUrl = require('@/assets/images/common/week.webp')
const monthImgUrl = require('@/assets/images/common/month.webp') const monthImgUrl = require('@/assets/images/common/month.webp')
import utils from "@/utils/utils.js";
export default { export default {
name: '', name: '',
data () { data () {
return { return {
sexType: {
'男': 'icon-male',
'女': 'icon-female'
},
dataList: [ dataList: [
{ {
label: '客户接待数', label: '客户接待数',
...@@ -130,6 +158,13 @@ export default { ...@@ -130,6 +158,13 @@ export default {
icon: monthImgUrl icon: monthImgUrl
} }
], ],
typeList: [
{ tabName: '已上传' },
{ tabName: '待上传',num:true },
],
firstIndex: 0,
firstLeft: ['0rpx', '352rpx', '756rpx'],
firstClass: ['first-nav', 'second-nav', 'second-nav'],
dateList: [ dateList: [
{ text: '今日' }, { text: '今日' },
{ text: '本周' }, { text: '本周' },
...@@ -142,6 +177,7 @@ export default { ...@@ -142,6 +177,7 @@ export default {
{ label: '开始接待', key: 'startTime' }, { label: '开始接待', key: 'startTime' },
{ label: '结束接待', key: 'endTime' }, { label: '结束接待', key: 'endTime' },
], ],
recordFailList:[],
dateIndex: 0, dateIndex: 0,
pageNum: 1, pageNum: 1,
total: 0, total: 0,
...@@ -154,11 +190,54 @@ export default { ...@@ -154,11 +190,54 @@ export default {
}, },
mounted () { mounted () {
this.init() this.init()
this.getRecordNum()
}, },
methods: { methods: {
changeType (index, name) {
if (this[name] == index) return // 点击同一个
this.direction = ''
console.log(index, name, this[name])
if (this[name] < index) {
this.direction = 'right'
} else {
this.direction = 'left'
}
this[name] = index
this.list=[]
this.pageNum = 1;
if(index == 0) {
this.changeIndex(this.dateIndex,true)
}else {
this.getRecordFail()
}
},
scroll (e) { scroll (e) {
this.sticky = e.detail.scrollTop >= 148 this.sticky = e.detail.scrollTop >= 148
}, },
getRecordNum() {
let recordFailListAll = JSON.parse(uni.$storage.get("recordList") || "[]");
const { shopMerchantId,sceneType } = uni.$storage.get("userInfo");
let recordFailList = recordFailListAll.filter(i=>{
console.log(i.bussinessType,sceneType)
return i.merchantId == shopMerchantId && i.bussinessType == (sceneType == 0 ? 1 : 2)
})
this.recordFailList = recordFailList
},
getRecordFail() {
this.getRecordNum()
this.list[0] = this.recordFailList.map(i=>{
return {
receptionStatus:i.receptionStatus,
phoneNumber:i.phoneNumber,
salesName:i.salesName,
customerName:i.customerName,
carModel:i.carModel,
duration:this.formatSeconds(new Date(i.receptionEndTime).getTime() - new Date(i.receptionStartTime).getTime()),
startTime: i.receptionStartTime.replace(/\//g,'.'),
endTime: i.receptionEndTime.replace(/\//g,'.')
}
})
},
init () { init () {
this.dateList.map((e, index) => { this.dateList.map((e, index) => {
const tatget = ['day', 'week', 'month'][index] const tatget = ['day', 'week', 'month'][index]
...@@ -193,7 +272,6 @@ export default { ...@@ -193,7 +272,6 @@ export default {
this.$set(this.dataList, index, { ...this.dataList[index], ...data }) this.$set(this.dataList, index, { ...this.dataList[index], ...data })
if (index < 2) this.getReceptionStatistics(++index) if (index < 2) this.getReceptionStatistics(++index)
} catch (error) { } catch (error) {
} }
}, },
async getReceptionList () { async getReceptionList () {
...@@ -221,11 +299,12 @@ export default { ...@@ -221,11 +299,12 @@ export default {
e.endTime = dayjs(e.receptionEndTime).format("YYYY.MM.DD HH:mm:ss") e.endTime = dayjs(e.receptionEndTime).format("YYYY.MM.DD HH:mm:ss")
e.phoneNumber = phoneNumber.slice(0, 3) + " " + phoneNumber.slice(3, 7) + " " + phoneNumber.slice(7) e.phoneNumber = phoneNumber.slice(0, 3) + " " + phoneNumber.slice(3, 7) + " " + phoneNumber.slice(7)
}) })
this.list[pageNum - 1] = list this.$set(this.list,pageNum - 1,list)
// this.list[pageNum - 1] = list
console.log(this.list)
this.flag = true this.flag = true
this.total = total this.total = total
} catch (error) { } catch (error) {
uni.hideLoading()
this.flag = true this.flag = true
} }
}, },
...@@ -252,8 +331,8 @@ export default { ...@@ -252,8 +331,8 @@ export default {
return formattedTime return formattedTime
} }
}, },
changeIndex (index) { changeIndex (index,isType = false) {
if (this.dateIndex == index) return if (this.dateIndex == index && !isType) return
this.flag = false this.flag = false
this.nothing = false this.nothing = false
this.total = 0 this.total = 0
...@@ -265,6 +344,7 @@ export default { ...@@ -265,6 +344,7 @@ export default {
}, },
pageonReachBottom () { pageonReachBottom () {
let { pageNum, total, nothing, pageSize } = this let { pageNum, total, nothing, pageSize } = this
console.log(pageNum, total, nothing, pageSize)
if (!nothing) nothing = 'nothing' if (!nothing) nothing = 'nothing'
if (Math.ceil(total / pageSize) > pageNum) { if (Math.ceil(total / pageSize) > pageNum) {
this.pageNum += 1 this.pageNum += 1
...@@ -288,7 +368,6 @@ export default { ...@@ -288,7 +368,6 @@ export default {
} else { } else {
return 'Invalid type'; return 'Invalid type';
} }
return { return {
startTime: dayjs(startTime).format("YYYY-MM-DD") + ' 00:00:00', startTime: dayjs(startTime).format("YYYY-MM-DD") + ' 00:00:00',
endTime: dayjs(endTime).format("YYYY-MM-DD") + ' 23:59:59' endTime: dayjs(endTime).format("YYYY-MM-DD") + ' 23:59:59'
...@@ -297,7 +376,6 @@ export default { ...@@ -297,7 +376,6 @@ export default {
} }
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@font-face { @font-face {
font-family: "numberBold"; font-family: "numberBold";
...@@ -308,19 +386,71 @@ export default { ...@@ -308,19 +386,71 @@ export default {
height: 100%; height: 100%;
.record-content { .record-content {
padding: 96rpx 0; padding: 96rpx 0;
.data-container {
background: #ffffff;
border-radius: 48rpx;
margin-top: 48rpx;
height: calc(100vh - 440rpx);
.type-box {
position: relative;
display: flex;
width: 100%;
background-color: #eef4fe;
height: 176rpx;
line-height: 128rpx;
border-radius: 48rpx 48rpx 0 0;
z-index: 0;
.tab-item {
width: 400rpx;
text-align: center;
font-weight: 500;
font-size: 40rpx;
color: #1f2133;
.text {
position: relative;
text-align: center;
width: 400rpx;
}
.active {
position: absolute;
top: 0;
z-index: -1;
font-weight: 700;
font-size: 40rpx;
color: #2c66f7;
&::after {
content: "";
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 48rpx;
height: 8rpx;
background-color: #2c66f7;
border-radius: 16rpx;
}
}
}
}
}
}
.record-list {
height: calc(100% - 380rpx);
margin-top: 24rpx;
} }
.list { .list {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
gap: 48rpx 60rpx; gap: 48rpx 60rpx;
padding-top: 48rpx; padding: 0rpx 64rpx 20rpx;
.item { .item {
width: 640rpx; width: 608rpx;
background: #ffffff; background: #ffffff;
border-radius: 16rpx;
box-sizing: border-box; box-sizing: border-box;
padding: 24rpx 32rpx; padding: 24rpx 32rpx;
position: relative; position: relative;
box-shadow: 0 8rpx 24rpx 0 #2c66f71a;
border-radius: 16rpx;
.status { .status {
position: absolute; position: absolute;
top: 24rpx; top: 24rpx;
...@@ -421,7 +551,6 @@ export default { ...@@ -421,7 +551,6 @@ export default {
font-family: "numberBold"; font-family: "numberBold";
font-size: 48rpx; font-size: 48rpx;
font-weight: 700; font-weight: 700;
margin: 0 4rpx;
} }
.unit { .unit {
font-weight: 500; font-weight: 500;
...@@ -432,7 +561,6 @@ export default { ...@@ -432,7 +561,6 @@ export default {
.total { .total {
padding-left: 96rpx; padding-left: 96rpx;
} }
.duration { .duration {
.num-box { .num-box {
display: flex; display: flex;
...@@ -460,61 +588,64 @@ export default { ...@@ -460,61 +588,64 @@ export default {
} }
} }
} }
.tabs-bottom {
margin-top: -45rpx;
background: #fff;
height: 45rpx;
position: relative;
z-index: 3;
}
.data-tabs-box { .data-tabs-box {
position: relative; position: relative;
top: 0; top: 0;
z-index: 3; z-index: 3;
width: calc(100% + 120rpx);
transform: translateX(-60rpx);
padding-top: 80rpx;
.data-tabs { .data-tabs {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
width: 784rpx; width: 552rpx;
height: 70rpx; height: 76rpx;
border-radius: 370rpx; background-color: #f2f2f2;
margin: 0 auto; border-radius: 16rpx;
margin-left: 60rpx;
position: relative; position: relative;
&::after { &::after {
position: absolute; position: absolute;
z-index: -2; z-index: -2;
background: #ffffffb3; background: #ffffff;
width: 100%; width: 100%;
height: 100%; height: 100%;
border-radius: 370rpx;
left: 0; left: 0;
top: 0; top: 0;
content: ""; content: "";
} }
.tab { .tab {
width: 240rpx; width: 184rpx;
height: 70rpx; height: 76rpx;
justify-content: center; justify-content: center;
font-weight: 500; font-weight: 500;
font-size: 32rpx; font-size: 32rpx;
color: #333333; color: #1f2133;
z-index: 10;
} }
.active { .active {
color: #ffffff;
} }
.active-btn { .active-btn {
position: absolute; position: absolute;
width: 240rpx; width: 180rpx;
height: 70rpx; height: 68rpx;
background: #3b73ff; background: #ffffff;
border-radius: 360rpx; top: 4rpx;
top: 0;
z-index: -1;
transition: all 0.15s; transition: all 0.15s;
border-radius: 16rpx;
} }
.active-btn-0 { .active-btn-0 {
left: 0; left: 4rpx;
} }
.active-btn-1 { .active-btn-1 {
left: 272rpx; left: 184rpx;
} }
.active-btn-2 { .active-btn-2 {
left: 544rpx; left: 368rpx;
} }
} }
} }
......
...@@ -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"); handleSave(file) {
this.$sendSentry( if (this.audioInfo.audioStatus == "end") {
`重试多次失败:手机号-${phoneNumber} 姓名-${customerName} 销售-${staffName} 车型-${carModel} 员工-${name},失败原因-${result}` this.saveRecord();
); this.setBooks([]);
this.$store.dispatch("clearCustomerInfo");
// this.handleErrorFile(res.tempFilePath, UPLOAD_STATUS.fail); this.setReceptionStatus(1);
// return; this.setAudioInfo({ endReasonType: 0, audioStatus: "finish" });
} else { } else {
// this.handleErrorFile(result, UPLOAD_STATUS.success); const audioList = [...this.audioInfo.audioList, file];
this.setAudioInfo({ audioList });
} }
const storageFile = [...this.audioInfo.audioList, result];
uni.$storage.set("storageFile", storageFile);
this.setAudioInfo({ audioList: storageFile });
if (this.audioInfo.audioStatus == "start") {
return;
}
this.uploadVoice(storageFile);
});
}, },
/**保存记录*/ /**保存记录*/
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);
},
},
};
...@@ -16,8 +16,9 @@ export const STORAGE_OBJECTkEY = { ...@@ -16,8 +16,9 @@ export const STORAGE_OBJECTkEY = {
noSignInUuid: "noSignInUuid", noSignInUuid: "noSignInUuid",
noviceGuideStatus: "noviceGuideStatus", noviceGuideStatus: "noviceGuideStatus",
accountLength: "accountLength", accountLength: "accountLength",
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!