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

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> </template>
<script setup> <script setup>
import { ref, defineProps, defineEmits, onMounted } from 'vue' import { ref, defineProps, defineEmits, onMounted, watch } from 'vue'
import { getCustomerList } from '../../api/customer/customer' import { getCustomerList } from '../../api/customer/customer'
// props // props
@ -77,6 +77,15 @@ const handleOverlayClick = () => {
// //
const handleCall = service => { const handleCall = service => {
//
console.log('拨打电话 - service对象:', service)
console.log('工作时间字段:', {
startTime: service.startTime,
entTime: service.entTime,
hasStartTime: !!service.startTime,
hasEntTime: !!service.entTime
})
uni.showModal({ uni.showModal({
title: '确认拨打电话', title: '确认拨打电话',
content: `是否拨打 ${service.name} 的电话 ${service.contact}`, content: `是否拨打 ${service.name} 的电话 ${service.contact}`,
@ -86,13 +95,52 @@ const handleCall = service => {
const now = new Date() const now = new Date()
const currentTime = now.getHours() * 10000 + now.getMinutes() * 100 + now.getSeconds() const currentTime = now.getHours() * 10000 + now.getMinutes() * 100 + now.getSeconds()
// // - 使 startTime entTime
const [startTime, endTime] = service.workTime.split('~') if (service.startTime && service.entTime) {
const start = parseInt(startTime.replace(/:/g, '')) const start = parseInt(service.startTime.replace(/:/g, ''))
const end = parseInt(endTime.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({ uni.makePhoneCall({
phoneNumber: service.contact, phoneNumber: service.contact,
success: () => { 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) { if (response && response.data) {
serviceList.value = response.data serviceList.value = response.data
console.log('客服列表获取成功:', serviceList.value) 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 { } else {
console.warn('API响应中没有data字段:', response) console.warn('API响应中没有data字段:', response)
} }
@ -167,6 +203,13 @@ onMounted(() => {
console.log('组件挂载visible状态:', props.visible) console.log('组件挂载visible状态:', props.visible)
fetchCustomerList() fetchCustomerList()
}) })
// visible
watch(props.visible, (newVal, oldVal) => {
if (newVal && !oldVal) {
fetchCustomerList()
}
}, { immediate: true }) // immediate: true
</script> </script>
<style scoped> <style scoped>

View File

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

View File

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