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