修复拨打客服电话失效,修改首页公司昵称

This commit is contained in:
WindowBird 2025-09-01 10:22:32 +08:00
parent 6a865ff750
commit 7e6843fb09
3 changed files with 75 additions and 32 deletions

View File

@ -48,7 +48,7 @@
</template>
<script setup>
import { ref, defineProps, defineEmits, onMounted } from 'vue'
import { ref, defineProps, defineEmits, onMounted, watch } from 'vue'
import { getCustomerList } from '../../api/customer/customer'
// props
@ -77,6 +77,15 @@ const handleOverlayClick = () => {
//
const handleCall = service => {
//
console.log('拨打电话 - service对象:', service)
console.log('工作时间字段:', {
startTime: service.startTime,
entTime: service.entTime,
hasStartTime: !!service.startTime,
hasEntTime: !!service.entTime
})
uni.showModal({
title: '确认拨打电话',
content: `是否拨打 ${service.name} 的电话 ${service.contact}`,
@ -86,13 +95,52 @@ const handleCall = service => {
const now = new Date()
const currentTime = now.getHours() * 10000 + now.getMinutes() * 100 + now.getSeconds()
//
const [startTime, endTime] = service.workTime.split('~')
const start = parseInt(startTime.replace(/:/g, ''))
const end = parseInt(endTime.replace(/:/g, ''))
// - 使 startTime entTime
if (service.startTime && service.entTime) {
const start = parseInt(service.startTime.replace(/:/g, ''))
const end = parseInt(service.entTime.replace(/:/g, ''))
if (currentTime >= start && currentTime <= end) {
//
if (currentTime >= start && currentTime <= end) {
//
uni.makePhoneCall({
phoneNumber: service.contact,
success: () => {
console.log('拨打电话成功')
},
fail: err => {
console.error('拨打电话失败:', err)
uni.showToast({
title: '拨打电话失败',
icon: 'none',
})
},
})
} else {
//
uni.showModal({
title: '温馨提示',
content: `${service.name} 当前不在工作时间内,是否仍要拨打?`,
success: res => {
if (res.confirm) {
uni.makePhoneCall({
phoneNumber: service.contact,
success: () => {
console.log('拨打电话成功')
},
fail: err => {
console.error('拨打电话失败:', err)
uni.showToast({
title: '拨打电话失败',
icon: 'none',
})
},
})
}
},
})
}
} else {
//
uni.makePhoneCall({
phoneNumber: service.contact,
success: () => {
@ -106,29 +154,6 @@ const handleCall = service => {
})
},
})
} else {
//
uni.showModal({
title: '温馨提示',
content: `${service.name} 当前不在工作时间内,是否仍要拨打?`,
success: res => {
if (res.confirm) {
uni.makePhoneCall({
phoneNumber: service.contact,
success: () => {
console.log('拨打电话成功')
},
fail: err => {
console.error('拨打电话失败:', err)
uni.showToast({
title: '拨打电话失败',
icon: 'none',
})
},
})
}
},
})
}
}
},
@ -147,6 +172,17 @@ const fetchCustomerList = async () => {
if (response && response.data) {
serviceList.value = response.data
console.log('客服列表获取成功:', serviceList.value)
//
if (serviceList.value.length > 0) {
console.log('第一个客服对象结构:', serviceList.value[0])
console.log('所有客服对象:', serviceList.value.map(service => ({
name: service.name,
contact: service.contact,
startTime: service.startTime,
entTime: service.entTime
})))
}
} else {
console.warn('API响应中没有data字段:', response)
}
@ -167,6 +203,13 @@ onMounted(() => {
console.log('组件挂载visible状态:', props.visible)
fetchCustomerList()
})
// visible
watch(props.visible, (newVal, oldVal) => {
if (newVal && !oldVal) {
fetchCustomerList()
}
}, { immediate: true }) // immediate: true
</script>
<style scoped>

View File

@ -4,7 +4,7 @@
<custom-nav-bar
background-color="#FFDECB"
title="福鼎创特物联科技有限公司"
title="湖北幺娘子厨燃能源科技有限公司"
title-align="left"
></custom-nav-bar>

View File

@ -232,7 +232,7 @@ export function request(options = {}) {
header: getRequestHeaders(options.header),
timeout: options.timeout || 60000, // 默认60秒超时
success: res => {
console.log('成功发送请求:', res)
console.log('成功发送请求的相应结果:', res)
// 隐藏加载状态
if (options.showLoading !== false) {
hideLoading()