动态客服弹窗

This commit is contained in:
WindowBird 2025-08-30 10:07:50 +08:00
parent b0efd89b49
commit 76f237ecab
5 changed files with 52 additions and 23 deletions

5
api/customer/customer.js Normal file
View File

@ -0,0 +1,5 @@
import { get } from '../../utils/request'
export function getCustomerList() {
return get('/app/customer/list')
}

View File

@ -24,11 +24,11 @@
<view class="service-info">
<view class="service-name">
<text class="name">{{ service.name }}</text>
<text class="phone">{{ service.phone }}</text>
<text class="phone">{{ service.contact }}</text>
</view>
<view class="work-time">
<text class="time-label">工作时间:</text>
<text class="time-value">{{ service.workTime }}</text>
<text class="time-value">{{ service.startTime }}~{{ service.entTime }}</text>
</view>
</view>
<view class="call-btn" @click="handleCall(service)">
@ -48,7 +48,8 @@
</template>
<script setup>
import { ref, defineProps, defineEmits } from 'vue'
import { ref, defineProps, defineEmits, onMounted } from 'vue'
import { getCustomerList } from '../../api/customer/customer'
// props
const props = defineProps({
@ -61,19 +62,8 @@ const props = defineProps({
// emits
const emit = defineEmits(['close'])
//
const serviceList = ref([
{
name: '阿帮',
phone: '13376970966',
workTime: '08:00:00~23:00:00',
},
{
name: '小翔',
phone: '13105875911',
workTime: '07:00:00~22:00:00',
},
])
//
const serviceList = ref([])
//
const handleClose = () => {
@ -89,7 +79,7 @@ const handleOverlayClick = () => {
const handleCall = service => {
uni.showModal({
title: '确认拨打电话',
content: `是否拨打 ${service.name} 的电话 ${service.phone}`,
content: `是否拨打 ${service.name} 的电话 ${service.contact}`,
success: res => {
if (res.confirm) {
//
@ -104,7 +94,7 @@ const handleCall = service => {
if (currentTime >= start && currentTime <= end) {
//
uni.makePhoneCall({
phoneNumber: service.phone,
phoneNumber: service.contact,
success: () => {
console.log('拨打电话成功')
},
@ -124,7 +114,7 @@ const handleCall = service => {
success: res => {
if (res.confirm) {
uni.makePhoneCall({
phoneNumber: service.phone,
phoneNumber: service.contact,
success: () => {
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>
<style scoped>

View File

@ -2,7 +2,7 @@
export const DEV_CONFIG = {
// 临时token用于开发测试
TEMP_TOKEN:
'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjQzMjljNzhjLTFmN2YtNGRkMS1iMDllLTZjNGRhZGI4MWUzZSJ9.S6TisMbcX1V1LqGilCG9BGye-p_36pWzgaF67O3DxN2exLR48oZLEAxYdbjNU5cqEtg4x5WJ3rpVs2gQer3xig',
'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjA2NzFkNWMzLTViZTEtNGFjZi1hYmFjLTMxZWZjYjY0NTg2MyJ9.dPnZkiM7f3v-uP1MMRwwIwNjPciZdQcHsz79n8WehiDPtFMGm_VsfJE4P_gN2N8nVcJJ5lf7YcKZW3HRUautXQ',
// 是否使用临时token
USE_TEMP_TOKEN: true,

View File

@ -149,6 +149,7 @@ export default {
deviceNum: 0,
rentAmount: 0,
},
CustomerList: [],
loading: false,
isAgent: false,
}

View File

@ -19,17 +19,17 @@ const ENV_CONFIG = {
develop: {
// 开发环境
// baseUrl: 'http://192.168.2.174:4501',
baseUrl: 'http://192.168.2.174:4601',
baseUrl: 'http://192.168.2.244:4601',
appId: 1, // TODO: 根据实际后端配置调整
},
trial: {
// 体验版
baseUrl: 'http://192.168.2.174:4601',
baseUrl: 'http://192.168.2.244:4601',
appId: 1, // TODO: 根据实际后端配置调整
},
release: {
// 正式版
baseUrl: 'http://192.168.2.174:4601',
baseUrl: 'http://192.168.2.244:4601',
appId: 1, // TODO: 根据实际后端配置调整
},
}