feat: 用户头像数据/昵称
This commit is contained in:
@@ -63,13 +63,22 @@ export default function Index() {
|
|||||||
console.log("Page loaded.");
|
console.log("Page loaded.");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 获取用户标识符
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
try {
|
// 获取路由参数
|
||||||
let getuserInfo = Taro.getStorageSync("userInfo");
|
const params = Taro.getCurrentInstance().router.params;
|
||||||
if (getuserInfo) {
|
console.log("params", params);
|
||||||
setuserInfo(getuserInfo);
|
// const [wxid, openId] = params;
|
||||||
console.log("本地用户信息存在");
|
|
||||||
} else {
|
// debug
|
||||||
|
params.wxid = "wxid_4413224132412";
|
||||||
|
if (params?.wxid) {
|
||||||
|
setuserInfo({
|
||||||
|
wxid: params?.wxid, //个人号wxid
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
// 本地存储
|
||||||
|
Taro.setStorageSync("wxid", params?.wxid ?? "");
|
||||||
Taro.login({
|
Taro.login({
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
if (res.code) {
|
if (res.code) {
|
||||||
@@ -78,7 +87,7 @@ export default function Index() {
|
|||||||
url: "http://127.0.0.1:28369/login",
|
url: "http://127.0.0.1:28369/login",
|
||||||
data: {
|
data: {
|
||||||
code: res.code,
|
code: res.code,
|
||||||
wxid: userInfo?.wxid ?? "wxid_4413224132412", //debug eric 的wxid
|
wxid: params?.wxid ?? null, //debug eric 的wxid
|
||||||
},
|
},
|
||||||
success: function (resUser) {
|
success: function (resUser) {
|
||||||
console.log(resUser);
|
console.log(resUser);
|
||||||
@@ -96,29 +105,19 @@ export default function Index() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log("error", e);
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// 获取用户标识符
|
|
||||||
useEffect(() => {
|
|
||||||
// 获取路由参数
|
|
||||||
const params = Taro.getCurrentInstance().router.params;
|
|
||||||
console.log("params", params);
|
|
||||||
// const [wxid, openId] = params;
|
|
||||||
|
|
||||||
if (params.wxid) {
|
|
||||||
setuserInfo({
|
|
||||||
wxid: params?.wxid, //个人号wxid
|
|
||||||
// openId: params?.openId, //小程序openid
|
|
||||||
});
|
|
||||||
// 本地存储
|
|
||||||
|
|
||||||
try {
|
|
||||||
Taro.setStorageSync("wxid", params?.wxid ?? "");
|
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
let getuserInfo = Taro.getStorageSync("userInfo");
|
||||||
|
if (getuserInfo) {
|
||||||
|
setuserInfo(getuserInfo);
|
||||||
|
console.log("本地用户信息存在");
|
||||||
|
} else {
|
||||||
|
console.log("本地用户信息,不存在");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log("error", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -264,17 +263,14 @@ export default function Index() {
|
|||||||
<View className="index">
|
<View className="index">
|
||||||
<View className="indexHome">
|
<View className="indexHome">
|
||||||
{/* 顶部 */}
|
{/* 顶部 */}
|
||||||
<View className="indexHeader">
|
{userInfo?.smallhead ? (
|
||||||
{/* 头像 */}
|
<View className="indexHeader">
|
||||||
<AtAvatar
|
{/* 头像 */}
|
||||||
circle
|
<AtAvatar circle image={userInfo?.smallhead ?? touxiang}></AtAvatar>
|
||||||
image={
|
{/* color="#F00" */}
|
||||||
Object.keys(userInfo).length > 0 ? userInfo.smallhead : touxiang
|
<AtIcon value="chevron-down" size="30"></AtIcon>
|
||||||
}
|
</View>
|
||||||
></AtAvatar>
|
) : null}
|
||||||
{/* color="#F00" */}
|
|
||||||
<AtIcon value="chevron-down" size="30"></AtIcon>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
{/* 省份标签 */}
|
{/* 省份标签 */}
|
||||||
<View className="provinceTag">
|
<View className="provinceTag">
|
||||||
|
|||||||
@@ -21,11 +21,15 @@ import TabbarCom from "@/componments/TabbarCom";
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
const my = () => {
|
const my = () => {
|
||||||
const [open, setopen] = useState(false);
|
const [open, setopen] = useState(false);
|
||||||
useEffect(()=>{
|
const [localuserInfo, setlocaluserInfo] = useState(
|
||||||
|
Taro.getStorageSync("userInfo")
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
// 获取路由参数
|
// 获取路由参数
|
||||||
const params= Taro.getCurrentInstance().router.params
|
const params = Taro.getCurrentInstance().router.params;
|
||||||
console.log('params',params)
|
console.log("params", params);
|
||||||
},[])
|
}, []);
|
||||||
|
|
||||||
const handleClick = (value) => {
|
const handleClick = (value) => {
|
||||||
setopen(true);
|
setopen(true);
|
||||||
@@ -35,9 +39,12 @@ const my = () => {
|
|||||||
<View className="myContent">
|
<View className="myContent">
|
||||||
<View className="myHeader">
|
<View className="myHeader">
|
||||||
{/* 头像 */}
|
{/* 头像 */}
|
||||||
<AtAvatar circle image={touxiang}></AtAvatar>
|
<AtAvatar
|
||||||
|
circle
|
||||||
|
image={localuserInfo?.smallhead ?? touxiang}
|
||||||
|
></AtAvatar>
|
||||||
<View>
|
<View>
|
||||||
<AtTag size="small">星球新居民</AtTag>
|
<AtTag size="small">{localuserInfo?.nickname??星球新居民}</AtTag>
|
||||||
{/* <AtTag size="small">女</AtTag> */}
|
{/* <AtTag size="small">女</AtTag> */}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
@@ -54,11 +61,11 @@ const my = () => {
|
|||||||
// note="描述信息"
|
// note="描述信息"
|
||||||
arrow="right"
|
arrow="right"
|
||||||
thumb="http://img10.360buyimg.com/jdphoto/s72x72_jfs/t5872/209/5240187906/2872/8fa98cd/595c3b2aN4155b931.png"
|
thumb="http://img10.360buyimg.com/jdphoto/s72x72_jfs/t5872/209/5240187906/2872/8fa98cd/595c3b2aN4155b931.png"
|
||||||
onClick={()=>{
|
onClick={() => {
|
||||||
// 跳转到目的页面,打开新页面
|
// 跳转到目的页面,打开新页面
|
||||||
Taro.navigateTo({
|
Taro.navigateTo({
|
||||||
url: '/pages/my/componments/Log/index',
|
url: "/pages/my/componments/Log/index",
|
||||||
})
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<AtListItem
|
<AtListItem
|
||||||
@@ -70,7 +77,6 @@ Taro.navigateTo({
|
|||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
|
||||||
{/* 个人客服 */}
|
{/* 个人客服 */}
|
||||||
{/* <View className="wechat">
|
{/* <View className="wechat">
|
||||||
<Button open-type="contact" className="wecahtBtn">
|
<Button open-type="contact" className="wecahtBtn">
|
||||||
|
|||||||
Reference in New Issue
Block a user