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>
<scroll-view
class="record-box"
scroll-y
@scrolltolower="pageonReachBottom"
@scroll="scroll"
>
<view class="record-box">
<view class="record-content">
<view class="data-box">
<template v-for="(i, index) in dataList">
<view
:class="['data-item', i.type]"
:key="index"
>
<image
:src="i.icon"
class="data-item-bg"
/>
<view :class="['data-item', i.type]" :key="index">
<image :src="i.icon" class="data-item-bg" />
<view class="title">{{ dateList[index].text }}</view>
<view class="content">
<view class="total">
......@@ -37,82 +26,121 @@
</view>
</template>
</view>
<view :class="['data-tabs-box', { sticky: sticky }]">
<view class="data-tabs">
<template v-for="(i, index) in dateList">
<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="['tab flex', { active: dateIndex == index }]"
:key="index"
@click="changeIndex(index)"
>{{ i.text }}</view>
</template>
<view :class="['active-btn', `active-btn-${dateIndex}`]"></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>
<view class="list">
<template v-if="flag">
<template v-if="list.length && list[0] && list[0].length">
<template v-for="i in list">
<template v-for="item in i">
<view
class="item"
:key="item.id"
>
<view :class="[
'status flex',
{ deal: item.receptionStatus == 1 },
]">{{
{
1: "成交",
0: "战败",
}[item.receptionStatus]
}}</view>
<view class="name">
{{ item.customerName }}
</view>
<view class="goods-name">{{ item.carModel }}</view>
<template v-for="(k, ind) in itemObject">
<view
class="info flex"
:key="ind"
>
<view class="label">{{ k.label }}</view>
<view class="value">{{ item[k.key] || "-" }}</view>
<view class="tabs-bottom"></view>
<view v-if="firstIndex == 0" class="data-tabs-box">
<view class="data-tabs">
<template v-for="(i, index) in dateList">
<view
:class="['tab flex', { active: dateIndex == index }]"
:key="index"
@click="changeIndex(index)"
>{{ i.text }}</view
>
</template>
<view :class="['active-btn', `active-btn-${dateIndex}`]"></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">
<template v-if="flag">
<template v-if="list.length && list[0] && list[0].length">
<template v-for="i in list">
<template v-for="item in i">
<view class="item" :key="item.id">
<view
:class="[
'status flex',
{ deal: item.receptionStatus == 1 },
]"
>{{
{
1: "成交",
0: "战败",
}[item.receptionStatus]
}}</view
>
<view class="name">
{{ item.customerName }}
</view>
<view class="goods-name">{{ item.carModel }}</view>
<template v-for="(k, ind) in itemObject">
<view class="info flex" :key="ind">
<view class="label">{{ k.label }}</view>
<view class="value">{{ item[k.key] || "-" }}</view>
</view>
</template>
</view>
</template>
</template>
</template>
<template v-else>
<view class="nothing flex">
<image
class="icon"
src="../../../assets/images/home/nothing.webp"
/>
暂无接待记录
</view>
</template>
</template>
</view>
<template v-if="nothing">
<view class="end-text">到底了!</view>
</template>
<template v-else>
<view class="nothing flex">
<image
class="icon"
src="../../../assets/images/home/nothing.webp"
/>
暂无接待记录
</view>
</template>
</template>
</scroll-view>
</view>
<template v-if="nothing">
<view class="end-text">到底了!</view>
</template>
<view class="bottom-mask"></view>
</view>
<view class="bottom-mask"></view>
</scroll-view>
</view>
</template>
<script type="text/ecmascript-6">
import dayjs from 'dayjs'
const dayImgUrl = require('@/assets/images/common/day.webp')
const weekImgUrl = require('@/assets/images/common/week.webp')
const monthImgUrl = require('@/assets/images/common/month.webp')
import utils from "@/utils/utils.js";
export default {
name: '',
data () {
return {
sexType: {
'男': 'icon-male',
'女': 'icon-female'
},
dataList: [
{
label: '客户接待数',
......@@ -130,6 +158,13 @@ export default {
icon: monthImgUrl
}
],
typeList: [
{ tabName: '已上传' },
{ tabName: '待上传',num:true },
],
firstIndex: 0,
firstLeft: ['0rpx', '352rpx', '756rpx'],
firstClass: ['first-nav', 'second-nav', 'second-nav'],
dateList: [
{ text: '今日' },
{ text: '本周' },
......@@ -142,6 +177,7 @@ export default {
{ label: '开始接待', key: 'startTime' },
{ label: '结束接待', key: 'endTime' },
],
recordFailList:[],
dateIndex: 0,
pageNum: 1,
total: 0,
......@@ -154,11 +190,54 @@ export default {
},
mounted () {
this.init()
this.getRecordNum()
},
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) {
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 () {
this.dateList.map((e, index) => {
const tatget = ['day', 'week', 'month'][index]
......@@ -193,7 +272,6 @@ export default {
this.$set(this.dataList, index, { ...this.dataList[index], ...data })
if (index < 2) this.getReceptionStatistics(++index)
} catch (error) {
}
},
async getReceptionList () {
......@@ -221,11 +299,12 @@ export default {
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)
})
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.total = total
} catch (error) {
uni.hideLoading()
this.flag = true
}
},
......@@ -252,8 +331,8 @@ export default {
return formattedTime
}
},
changeIndex (index) {
if (this.dateIndex == index) return
changeIndex (index,isType = false) {
if (this.dateIndex == index && !isType) return
this.flag = false
this.nothing = false
this.total = 0
......@@ -265,6 +344,7 @@ export default {
},
pageonReachBottom () {
let { pageNum, total, nothing, pageSize } = this
console.log(pageNum, total, nothing, pageSize)
if (!nothing) nothing = 'nothing'
if (Math.ceil(total / pageSize) > pageNum) {
this.pageNum += 1
......@@ -288,7 +368,6 @@ export default {
} else {
return 'Invalid type';
}
return {
startTime: dayjs(startTime).format("YYYY-MM-DD") + ' 00:00:00',
endTime: dayjs(endTime).format("YYYY-MM-DD") + ' 23:59:59'
......@@ -297,7 +376,6 @@ export default {
}
}
</script>
<style scoped lang="scss">
@font-face {
font-family: "numberBold";
......@@ -308,19 +386,71 @@ export default {
height: 100%;
.record-content {
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 {
display: flex;
flex-wrap: wrap;
gap: 48rpx 60rpx;
padding-top: 48rpx;
padding: 0rpx 64rpx 20rpx;
.item {
width: 640rpx;
width: 608rpx;
background: #ffffff;
border-radius: 16rpx;
box-sizing: border-box;
padding: 24rpx 32rpx;
position: relative;
box-shadow: 0 8rpx 24rpx 0 #2c66f71a;
border-radius: 16rpx;
.status {
position: absolute;
top: 24rpx;
......@@ -421,7 +551,6 @@ export default {
font-family: "numberBold";
font-size: 48rpx;
font-weight: 700;
margin: 0 4rpx;
}
.unit {
font-weight: 500;
......@@ -432,7 +561,6 @@ export default {
.total {
padding-left: 96rpx;
}
.duration {
.num-box {
display: flex;
......@@ -460,61 +588,64 @@ export default {
}
}
}
.tabs-bottom {
margin-top: -45rpx;
background: #fff;
height: 45rpx;
position: relative;
z-index: 3;
}
.data-tabs-box {
position: relative;
top: 0;
z-index: 3;
width: calc(100% + 120rpx);
transform: translateX(-60rpx);
padding-top: 80rpx;
.data-tabs {
display: flex;
justify-content: space-between;
width: 784rpx;
height: 70rpx;
border-radius: 370rpx;
margin: 0 auto;
width: 552rpx;
height: 76rpx;
background-color: #f2f2f2;
border-radius: 16rpx;
margin-left: 60rpx;
position: relative;
&::after {
position: absolute;
z-index: -2;
background: #ffffffb3;
background: #ffffff;
width: 100%;
height: 100%;
border-radius: 370rpx;
left: 0;
top: 0;
content: "";
}
.tab {
width: 240rpx;
height: 70rpx;
width: 184rpx;
height: 76rpx;
justify-content: center;
font-weight: 500;
font-size: 32rpx;
color: #333333;
color: #1f2133;
z-index: 10;
}
.active {
color: #ffffff;
}
.active-btn {
position: absolute;
width: 240rpx;
height: 70rpx;
background: #3b73ff;
border-radius: 360rpx;
top: 0;
z-index: -1;
width: 180rpx;
height: 68rpx;
background: #ffffff;
top: 4rpx;
transition: all 0.15s;
border-radius: 16rpx;
}
.active-btn-0 {
left: 0;
left: 4rpx;
}
.active-btn-1 {
left: 272rpx;
left: 184rpx;
}
.active-btn-2 {
left: 544rpx;
left: 368rpx;
}
}
}
......
......@@ -24,6 +24,7 @@ Vue.component("UpdateBox", UpdateBox);
uni.$api = api;
uni.$storage = new Storage();
uni.$throttle = utils.throttle;
uni.$isNetWork = utils.isNetWork;
Vue.config.productionTip = false;
App.mpType = "app";
Vue.prototype.$ossDomain = config.OSS_DOMAIN;
......
......@@ -77,11 +77,6 @@ export default {
this.times = 0;
this.$refs.tipBox?.close();
},
//检查缓存录音
checkVoice() {
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 } =
......@@ -112,60 +107,6 @@ export default {
};
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() {
if (this.audioInfo.audioStatus == "start") return;
......@@ -194,41 +135,34 @@ export default {
});
return;
}
// const isContinue = this.hasErrorFile();
// if (isContinue) {
// this.handleErrorFile(res.tempFilePath);
// if (this.audioInfo.audioStatus == 'end') {
// this.saveRecord();
// }
// return;
// }
const result = await this.checkUploadFile(res.tempFilePath);
if (result instanceof Error) {
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} 员工-${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);
const saveResult = await uni.saveFile({
tempFilePath: res.tempFilePath,
}); // 保存文件到本地
//删除默认文件
uni.removeSavedFile({
filePath: res.tempFilePath,
complete: function (res) {
console.log(res);
},
});
this.handleSave(saveResult);
});
},
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() {
const recordUrlList = JSON.parse(uni.$storage.get("errorFile") || "[]");
const recordUrlList = this.audioInfo.audioList;
let recordList = JSON.parse(uni.$storage.get("recordList") || "[]");
recordList = [
...recordList,
......@@ -239,67 +173,6 @@ export default {
];
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) {
// const result = await this.$permision.requestAndroidPermission(
......@@ -322,12 +195,7 @@ export default {
if (!status) {
uni.showLoading({
mask: true,
title: "处理中请稍后...",
});
// setTimeout(() => {
// uni.hideLoading();
// clearInterval(finish_timer);
// }, 1000 * 60);
}
this.times = 0;
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 = {
noSignInUuid: "noSignInUuid",
noviceGuideStatus: "noviceGuideStatus",
accountLength: "accountLength",
carBrandList:'carBrandList',
employeeList:'employeeList'
carBrandList: "carBrandList",
employeeList: "employeeList",
recordList: "recordList",
};
// export const IMG_VERSION = async () => {
......
......@@ -76,10 +76,25 @@ var throttle = function (fn, delay) {
}, delay);
};
};
//检查是否有网络
var isNetWork = function () {
return new Promise((resolve, reject) => {
uni.getNetworkType({
complete: function (res) {
if (res.networkType == "none") {
reject();
} else {
resolve();
}
},
});
});
};
export default {
convertDateTimeFormat,
deepClone,
accDiv,
debounce,
throttle,
isNetWork,
};
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!