客服电话换接口获取

This commit is contained in:
BAKEYi 2026-04-17 14:27:31 +08:00
parent e89470df68
commit 126e236cc2
1 changed files with 56 additions and 42 deletions

View File

@ -26,71 +26,85 @@
<script>
import permissionUtils from "@/utils/per";
import locationService from "@/utils/locationService";
export default {
data() {
return {
isShowPer: false, //
phone: '19950079687'
import request from "@/utils/request";
export default {
data() {
return {
isShowPer: false, //
phone: '19950079687' // 使
}
},
onLoad(options) {
//
this.getCustomerService();
},
methods: {
//
async getCustomerService() {
try {
const res = await request.post('/sj/poster/getCustomerService');
if (res.code === 200 && res.data && res.data.phone) {
this.phone = res.data.phone;
}
} catch (error) {
console.error('获取客服电话失败', error);
}
},
onLoad(options) {
this.phone = options.phone || '19950079687'
},
methods: {
//
async callPhone() {
const systemInfo = uni.getSystemInfoSync();
if (systemInfo.platform === "ios") {
uni.makePhoneCall({ phoneNumber: this.phone });
} else {
let permission = "android.permission.CALL_PHONE";
this.isShowPer = true;
//
async callPhone() {
const systemInfo = uni.getSystemInfoSync();
if (systemInfo.platform === "ios") {
uni.makePhoneCall({ phoneNumber: this.phone });
} else {
let permission = "android.permission.CALL_PHONE";
this.isShowPer = true;
// 1.
const { granted } = await permissionUtils.checkPermission(
// 1.
const { granted } = await permissionUtils.checkPermission(
"phone",
"需要拨打电话权限,方便您联系客服"
);
if (granted) {
);
if (granted) {
this.isShowPer = false;
uni.makePhoneCall({ phoneNumber: this.phone });
return;
}
}
this.isShowPer = false;
// 2.
const confirm = await this.showPermissionDialog(
this.isShowPer = false;
// 2.
const confirm = await this.showPermissionDialog(
"拨打电话权限申请",
"我们需要拨打电话权限,方便您联系客服"
);
if (!confirm) return;
);
if (!confirm) return;
// 3.
const result = await permissionUtils.requestPermission(
// 3.
const result = await permissionUtils.requestPermission(
"phone",
"需要拨打电话权限,方便您联系客服"
);
if (result) {
);
if (result) {
uni.makePhoneCall({ phoneNumber: this.phone });
} else {
} else {
locationService.openAppSettings();
}
}
},
showPermissionDialog(title, content) {
}
},
showPermissionDialog(title, content) {
return new Promise((resolve) => {
uni.showModal({
title,
content,
confirmText: "去开启",
success(res) {
resolve(res.confirm);
}
title,
content,
confirmText: "去开启",
success(res) {
resolve(res.confirm);
}
});
});
}
}
}
}
</script>
<style>