动态客服弹窗
This commit is contained in:
parent
b0efd89b49
commit
76f237ecab
5
api/customer/customer.js
Normal file
5
api/customer/customer.js
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { get } from '../../utils/request'
|
||||||
|
|
||||||
|
export function getCustomerList() {
|
||||||
|
return get('/app/customer/list')
|
||||||
|
}
|
||||||
|
|
@ -24,11 +24,11 @@
|
||||||
<view class="service-info">
|
<view class="service-info">
|
||||||
<view class="service-name">
|
<view class="service-name">
|
||||||
<text class="name">{{ service.name }}</text>
|
<text class="name">{{ service.name }}</text>
|
||||||
<text class="phone">{{ service.phone }}</text>
|
<text class="phone">{{ service.contact }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="work-time">
|
<view class="work-time">
|
||||||
<text class="time-label">工作时间:</text>
|
<text class="time-label">工作时间:</text>
|
||||||
<text class="time-value">{{ service.workTime }}</text>
|
<text class="time-value">{{ service.startTime }}~{{ service.entTime }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="call-btn" @click="handleCall(service)">
|
<view class="call-btn" @click="handleCall(service)">
|
||||||
|
|
@ -48,7 +48,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, defineProps, defineEmits } from 'vue'
|
import { ref, defineProps, defineEmits, onMounted } from 'vue'
|
||||||
|
import { getCustomerList } from '../../api/customer/customer'
|
||||||
|
|
||||||
// 定义props
|
// 定义props
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
|
@ -61,19 +62,8 @@ const props = defineProps({
|
||||||
// 定义emits
|
// 定义emits
|
||||||
const emit = defineEmits(['close'])
|
const emit = defineEmits(['close'])
|
||||||
|
|
||||||
// 客服数据
|
// 响应式数据
|
||||||
const serviceList = ref([
|
const serviceList = ref([])
|
||||||
{
|
|
||||||
name: '阿帮',
|
|
||||||
phone: '13376970966',
|
|
||||||
workTime: '08:00:00~23:00:00',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '小翔',
|
|
||||||
phone: '13105875911',
|
|
||||||
workTime: '07:00:00~22:00:00',
|
|
||||||
},
|
|
||||||
])
|
|
||||||
|
|
||||||
// 关闭弹窗
|
// 关闭弹窗
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
|
|
@ -89,7 +79,7 @@ const handleOverlayClick = () => {
|
||||||
const handleCall = service => {
|
const handleCall = service => {
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '确认拨打电话',
|
title: '确认拨打电话',
|
||||||
content: `是否拨打 ${service.name} 的电话 ${service.phone}?`,
|
content: `是否拨打 ${service.name} 的电话 ${service.contact}?`,
|
||||||
success: res => {
|
success: res => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
// 检查当前时间是否在工作时间内
|
// 检查当前时间是否在工作时间内
|
||||||
|
|
@ -104,7 +94,7 @@ const handleCall = service => {
|
||||||
if (currentTime >= start && currentTime <= end) {
|
if (currentTime >= start && currentTime <= end) {
|
||||||
// 在工作时间内,直接拨打电话
|
// 在工作时间内,直接拨打电话
|
||||||
uni.makePhoneCall({
|
uni.makePhoneCall({
|
||||||
phoneNumber: service.phone,
|
phoneNumber: service.contact,
|
||||||
success: () => {
|
success: () => {
|
||||||
console.log('拨打电话成功')
|
console.log('拨打电话成功')
|
||||||
},
|
},
|
||||||
|
|
@ -124,7 +114,7 @@ const handleCall = service => {
|
||||||
success: res => {
|
success: res => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
uni.makePhoneCall({
|
uni.makePhoneCall({
|
||||||
phoneNumber: service.phone,
|
phoneNumber: service.contact,
|
||||||
success: () => {
|
success: () => {
|
||||||
console.log('拨打电话成功')
|
console.log('拨打电话成功')
|
||||||
},
|
},
|
||||||
|
|
@ -144,6 +134,39 @@ const handleCall = service => {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取客服列表
|
||||||
|
const fetchCustomerList = async () => {
|
||||||
|
try {
|
||||||
|
console.log('开始获取客服列表...')
|
||||||
|
console.log('当前弹窗状态:', props.visible)
|
||||||
|
|
||||||
|
const response = await getCustomerList()
|
||||||
|
console.log('API响应:', response)
|
||||||
|
|
||||||
|
if (response && response.data) {
|
||||||
|
serviceList.value = response.data
|
||||||
|
console.log('客服列表获取成功:', serviceList.value)
|
||||||
|
} else {
|
||||||
|
console.warn('API响应中没有data字段:', response)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取客服列表失败:', error)
|
||||||
|
// 隐藏加载状态
|
||||||
|
uni.hideLoading()
|
||||||
|
|
||||||
|
uni.showToast({
|
||||||
|
title: '获取客服信息失败',
|
||||||
|
icon: 'none',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 组件挂载时也尝试获取一次数据
|
||||||
|
onMounted(() => {
|
||||||
|
console.log('组件挂载,visible状态:', props.visible)
|
||||||
|
fetchCustomerList()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
export const DEV_CONFIG = {
|
export const DEV_CONFIG = {
|
||||||
// 临时token,用于开发测试
|
// 临时token,用于开发测试
|
||||||
TEMP_TOKEN:
|
TEMP_TOKEN:
|
||||||
'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjQzMjljNzhjLTFmN2YtNGRkMS1iMDllLTZjNGRhZGI4MWUzZSJ9.S6TisMbcX1V1LqGilCG9BGye-p_36pWzgaF67O3DxN2exLR48oZLEAxYdbjNU5cqEtg4x5WJ3rpVs2gQer3xig',
|
'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjA2NzFkNWMzLTViZTEtNGFjZi1hYmFjLTMxZWZjYjY0NTg2MyJ9.dPnZkiM7f3v-uP1MMRwwIwNjPciZdQcHsz79n8WehiDPtFMGm_VsfJE4P_gN2N8nVcJJ5lf7YcKZW3HRUautXQ',
|
||||||
|
|
||||||
// 是否使用临时token
|
// 是否使用临时token
|
||||||
USE_TEMP_TOKEN: true,
|
USE_TEMP_TOKEN: true,
|
||||||
|
|
|
||||||
|
|
@ -149,6 +149,7 @@ export default {
|
||||||
deviceNum: 0,
|
deviceNum: 0,
|
||||||
rentAmount: 0,
|
rentAmount: 0,
|
||||||
},
|
},
|
||||||
|
CustomerList: [],
|
||||||
loading: false,
|
loading: false,
|
||||||
isAgent: false,
|
isAgent: false,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,17 +19,17 @@ const ENV_CONFIG = {
|
||||||
develop: {
|
develop: {
|
||||||
// 开发环境
|
// 开发环境
|
||||||
// baseUrl: 'http://192.168.2.174:4501',
|
// baseUrl: 'http://192.168.2.174:4501',
|
||||||
baseUrl: 'http://192.168.2.174:4601',
|
baseUrl: 'http://192.168.2.244:4601',
|
||||||
appId: 1, // TODO: 根据实际后端配置调整
|
appId: 1, // TODO: 根据实际后端配置调整
|
||||||
},
|
},
|
||||||
trial: {
|
trial: {
|
||||||
// 体验版
|
// 体验版
|
||||||
baseUrl: 'http://192.168.2.174:4601',
|
baseUrl: 'http://192.168.2.244:4601',
|
||||||
appId: 1, // TODO: 根据实际后端配置调整
|
appId: 1, // TODO: 根据实际后端配置调整
|
||||||
},
|
},
|
||||||
release: {
|
release: {
|
||||||
// 正式版
|
// 正式版
|
||||||
baseUrl: 'http://192.168.2.174:4601',
|
baseUrl: 'http://192.168.2.244:4601',
|
||||||
appId: 1, // TODO: 根据实际后端配置调整
|
appId: 1, // TODO: 根据实际后端配置调整
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user