fix:修复bug
This commit is contained in:
+13
-33
@@ -36,9 +36,9 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useI18n } from '@/utils/i18n.js'
|
||||
import { URL } from '@/config/url.js'
|
||||
import { getCurrentAgreement } from '@/config/api/system.js'
|
||||
|
||||
const { t: $t } = useI18n()
|
||||
const { t } = useI18n()
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(true)
|
||||
@@ -50,13 +50,6 @@
|
||||
remark: ''
|
||||
})
|
||||
|
||||
// 将语言代码转换为后端接受的格式
|
||||
const convertLanguageCode = (lang) => {
|
||||
// zh-CN -> zh-CN (保持不变)
|
||||
// en-US -> en_US (转换下划线)
|
||||
return lang.replace(/-/g, '_')
|
||||
}
|
||||
|
||||
// 加载协议内容
|
||||
const loadAgreement = async () => {
|
||||
loading.value = true
|
||||
@@ -64,35 +57,22 @@
|
||||
errorMessage.value = ''
|
||||
|
||||
try {
|
||||
// 获取当前语言设置
|
||||
const currentLang = uni.getStorageSync('language') || 'zh-CN'
|
||||
const languageCode = convertLanguageCode(currentLang)
|
||||
|
||||
console.log('加载隐私政策,语言:', currentLang, '转换后:', languageCode)
|
||||
console.log('加载隐私政策')
|
||||
|
||||
// 调用接口获取协议内容
|
||||
const res = await uni.request({
|
||||
url: `${URL}/device/agreementConfig/current`,
|
||||
method: 'GET',
|
||||
header: {
|
||||
'Content-Language': languageCode,
|
||||
'Authorization': 'Bearer ' + uni.getStorageSync('token'),
|
||||
'Clientid': uni.getStorageSync('client_id')
|
||||
},
|
||||
data: {
|
||||
agreementCode: 'PRIVACY_POLICY',
|
||||
appPlatform: 'wechat',
|
||||
appType: 'user'
|
||||
}
|
||||
const res = await getCurrentAgreement({
|
||||
agreementCode: 'PRIVACY_POLICY',
|
||||
appPlatform: 'wechat',
|
||||
appType: 'user'
|
||||
})
|
||||
|
||||
console.log('隐私政策响应:', res)
|
||||
|
||||
if (res.statusCode === 200 && res.data.code === 200 && res.data.data) {
|
||||
if (res && res.code === 200 && res.data) {
|
||||
agreementData.value = {
|
||||
title: res.data.data.title || $t('legal.privacy'),
|
||||
content: res.data.data.content || '',
|
||||
remark: res.data.data.remark || ''
|
||||
title: res.data.title || t('legal.privacy'),
|
||||
content: res.data.content || '',
|
||||
remark: res.data.remark || ''
|
||||
}
|
||||
|
||||
// 设置页面标题
|
||||
@@ -100,12 +80,12 @@
|
||||
title: agreementData.value.title
|
||||
})
|
||||
} else {
|
||||
throw new Error(res.data.msg || $t('common.loadFailed'))
|
||||
throw new Error(res?.msg || t('common.loadFailed'))
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('加载隐私政策失败:', err)
|
||||
error.value = true
|
||||
errorMessage.value = err.message || $t('common.loadFailed')
|
||||
errorMessage.value = err.message || t('common.loadFailed')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user