style:调整样式

This commit is contained in:
2025-10-28 18:32:23 +08:00
parent 449c63ecc4
commit 985d739324
9 changed files with 345 additions and 74 deletions
+51
View File
@@ -6,6 +6,8 @@ import {
URL,
appid
} from "@/config/url.js"
import { getCommonByBrand } from "@/config/api/system"
import { HELP_CONTENT } from "@/constants/help"
// import { GET_PHONE_NUMBER_URL } from "../config/url"
// 微信登录方法
@@ -30,6 +32,11 @@ export const wxLogin = () => {
uni.setStorageSync('token', result.data.LoginWxVo.access_token)
uni.setStorageSync('client_id', result.data.LoginWxVo.client_id)
// 4. 登录成功后获取并缓存客服电话
fetchAndCacheCustomerPhone().catch(err => {
console.error('获取客服电话失败,但不影响登录', err)
})
resolve(result.data)
} else {
throw new Error(result.message || '登录失败')
@@ -173,4 +180,48 @@ export const getQueryString = function(url, name) {
return r[2]
}
return null;
}
// 获取并缓存客服电话
export const fetchAndCacheCustomerPhone = async () => {
try {
// 获取当前语言
const locale = uni.getLocale ? uni.getLocale() : uni.getSystemInfoSync().language
const isEnglish = locale && (locale.toLowerCase().startsWith('en') || locale.toLowerCase().includes('en'))
// 根据语言设置品牌名称
const brandName = isEnglish ? 'fdzpower' : '风电者'
console.log('获取客服电话,当前语言:', locale, '品牌名称:', brandName)
// 调用接口获取客服电话
const res = await getCommonByBrand(brandName)
if (res.code === 200 && res.data && res.data.servicePhone) {
const phone = res.data.servicePhone
// 缓存客服电话
uni.setStorageSync('customerPhone', phone)
console.log('客服电话已缓存:', phone)
return phone
} else {
console.warn('获取客服电话失败,使用内置默认电话')
// 使用内置默认电话并缓存
const defaultPhone = HELP_CONTENT.CONTACT.PHONE.VALUE
uni.setStorageSync('customerPhone', defaultPhone)
return defaultPhone
}
} catch (error) {
console.error('获取客服电话出错,使用内置默认电话:', error)
// 使用内置默认电话并缓存
const defaultPhone = HELP_CONTENT.CONTACT.PHONE.VALUE
uni.setStorageSync('customerPhone', defaultPhone)
return defaultPhone
}
}
// 从缓存获取客服电话
export const getCustomerPhone = () => {
const phone = uni.getStorageSync('customerPhone')
// 如果没有缓存,返回内置默认值
return phone || HELP_CONTENT.CONTACT.PHONE.VALUE
}