- 新增微信小程序手机号一键授权登录功能 - 添加扫码登录确认页面实现二维码登录流程 - 集成统一扫码功能支持登录和核销场景 - 更新协议页面从CMS动态加载内容并添加加载状态 - 修改登录注册页面UI和导航逻辑 - 配置文件添加新的路由页面入口 - 更新API基础URL配置 - 实现邀请参数解析和推广跟踪功能 - 添加微信OpenID自动获取和存储机制 - 优化页面跳转和重定向逻辑处理
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { useEffect, useState } from 'react'
|
|
import Taro from '@tarojs/taro'
|
|
import { Loading } from '@nutui/nutui-react-taro'
|
|
import { RichText, View } from '@tarojs/components'
|
|
import { getByCode } from '@/api/cms/cmsArticle'
|
|
import { wxParse } from '@/utils/common'
|
|
|
|
const Agreement = () => {
|
|
const [loading, setLoading] = useState(true)
|
|
const [content, setContent] = useState<string>('')
|
|
|
|
const reload = async () => {
|
|
try {
|
|
Taro.hideTabBar()
|
|
} catch (_) {
|
|
// ignore (e.g. H5 / unsupported env)
|
|
}
|
|
|
|
try {
|
|
const article = await getByCode('xieyi')
|
|
setContent(article?.content ? wxParse(article.content) : '<p>暂无协议内容</p>')
|
|
} catch (e) {
|
|
// Keep UI usable even if CMS/API fails.
|
|
// eslint-disable-next-line no-console
|
|
console.error('load agreement failed', e)
|
|
setContent('<p>协议内容加载失败</p>')
|
|
Taro.showToast({ title: '协议加载失败', icon: 'none' })
|
|
} finally {
|
|
setLoading(false)
|
|
}
|
|
}
|
|
|
|
useEffect(() => {
|
|
reload()
|
|
}, [])
|
|
|
|
if (loading) {
|
|
return <Loading className={'px-2'}>加载中</Loading>
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<View className={'content text-gray-700 text-sm p-4'}>
|
|
<RichText nodes={content} />
|
|
</View>
|
|
</>
|
|
)
|
|
}
|
|
export default Agreement
|