- 兼容接口中 code 返回 0 和 200 两种成功状态 - 在扫码登录确认接口添加日志输出,调试响应数据 - 重构扫码登录确认页面逻辑,支持主动扫码和URL扫码两种场景 - 兼容多种token参数名,支持URL编码和旧参数解析 - URL扫码场景自动确认登录,未登录用户自动跳转登录页 - 新增主动扫码功能,支持二维码内容多格式解析(URL/JSON/纯token) - 优化确认登录后页面交互,支持自动返回或提示用户回PC端刷新 - 增加状态视觉反馈,包括加载、成功、失败及初始状态 - 优化UI细节,使用圆角样式及布局调整提升视觉体验 - 新增页面底部帮助提示文字,提升用户指引 - 新增多页面配置,设置导航栏标题及样式统一管理 - 新增应用密钥凭证、应用操作动态、应用成员、应用版本发布等增删改查功能模块及接口定义 - 新增对应页面表单组件,实现应用相关实体的新增和编辑功能
99 lines
2.4 KiB
TypeScript
99 lines
2.4 KiB
TypeScript
import {useEffect, useState, useRef} from "react";
|
|
import {useRouter} from '@tarojs/taro'
|
|
import {Button, Loading, CellGroup, Input, TextArea, Form} from '@nutui/nutui-react-taro'
|
|
import Taro from '@tarojs/taro'
|
|
import {View} from '@tarojs/components'
|
|
import {AppUser} from "@/api/app/appUser/model";
|
|
import {getAppUser, listAppUser, updateAppUser, addAppUser} from "@/api/app/appUser";
|
|
|
|
const AddAppUser = () => {
|
|
const {params} = useRouter();
|
|
const [loading, setLoading] = useState<boolean>(true)
|
|
const [FormData, setFormData] = useState<AppUser>({})
|
|
const formRef = useRef<any>(null)
|
|
|
|
const reload = async () => {
|
|
if (params.id) {
|
|
const data = await getAppUser(Number(params.id))
|
|
setFormData(data)
|
|
} else {
|
|
setFormData({})
|
|
}
|
|
}
|
|
|
|
// 提交表单
|
|
const submitSucceed = async (values: any) => {
|
|
try {
|
|
if (params.id) {
|
|
// 编辑模式
|
|
await updateAppUser({
|
|
...values,
|
|
id: Number(params.id)
|
|
})
|
|
} else {
|
|
// 新增模式
|
|
await addAppUser(values)
|
|
}
|
|
|
|
Taro.showToast({
|
|
title: `操作成功`,
|
|
icon: 'success'
|
|
})
|
|
|
|
setTimeout(() => {
|
|
return Taro.navigateBack()
|
|
}, 1000)
|
|
} catch (error) {
|
|
Taro.showToast({
|
|
title: `操作失败`,
|
|
icon: 'error'
|
|
});
|
|
}
|
|
}
|
|
|
|
const submitFailed = (error: any) => {
|
|
console.log(error, 'err...')
|
|
}
|
|
|
|
useEffect(() => {
|
|
reload().then(() => {
|
|
setLoading(false)
|
|
})
|
|
}, []);
|
|
|
|
if (loading) {
|
|
return <Loading className={'px-2'}>加载中</Loading>
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<Form
|
|
ref={formRef}
|
|
divider
|
|
initialValues={FormData}
|
|
labelPosition="left"
|
|
onFinish={(values) => submitSucceed(values)}
|
|
onFinishFailed={(errors) => submitFailed(errors)}
|
|
footer={
|
|
<div
|
|
style={{
|
|
display: 'flex',
|
|
justifyContent: 'center',
|
|
width: '100%'
|
|
}}
|
|
>
|
|
<Button
|
|
nativeType="submit"
|
|
type="success"
|
|
size="large"
|
|
className={'w-full'}
|
|
block
|
|
>
|
|
{params.id ? '更新' : '保存'}
|
|
</Button>
|
|
</div>
|
|
}
|
|
>
|
|
<CellGroup style={{padding: '4px 0'}}>
|
|
<Form.Item name="websiteId" label="关联应用ID" initialValue={FormData.websiteId} required>
|