|
|
@@ -1,7 +1,32 @@
|
|
|
-import { Input, View } from "@tarojs/components";
|
|
|
+import { update } from "@/services/user";
|
|
|
+import { Input, View, Text } from "@tarojs/components";
|
|
|
+import Taro from "@tarojs/taro";
|
|
|
+import { useState } from "react";
|
|
|
+import { useDispatch, useSelector } from "react-redux";
|
|
|
|
|
|
export default function Page() {
|
|
|
+ const user = useSelector((state: any) => state.user);
|
|
|
+ const [value, setValue] = useState(user.nickname);
|
|
|
+ const dispatch = useDispatch();
|
|
|
+
|
|
|
+ const handleChange = (e) => {
|
|
|
+ setValue(e.target.value);
|
|
|
+ };
|
|
|
+
|
|
|
+ function save() {
|
|
|
+ if (value.length == 0) {
|
|
|
+ Taro.showToast({
|
|
|
+ title: '请输入昵称',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ dispatch(update({nickname:value}) as any)
|
|
|
+ }
|
|
|
+
|
|
|
return <View>
|
|
|
- <Input type="nickname" placeholder="请输入昵称" style={{color:'#fff'}}/>
|
|
|
+ <Input type="nickname" placeholder="请输入昵称" style={{ color: '#fff' }} value={value} onInput={handleChange} />
|
|
|
+
|
|
|
+ <Text onClick={save} style={{ color: '#fff' }}>保存</Text>
|
|
|
</View>
|
|
|
}
|