feat: 首页-微信官方的渲染bug

This commit is contained in:
huxiaoshuang
2022-11-25 16:27:48 +08:00
parent 10112ed5d4
commit 2651275abd
4 changed files with 69 additions and 57 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -46,9 +46,8 @@ const Home = () => {
// 系统配置
const [systemConfig, setsystemConfig] = useState<any>({});
const [openid,setopenid]=useState()
const [isIn,setisIn]=useState(false)
const [openid, setopenid] = useState();
const [isIn, setisIn] = useState(false);
const onChange = (e) => {};
@@ -66,29 +65,33 @@ const Home = () => {
withShareTicket: true,
success() {},
});
getsystemConfig(); //获取系统配置
getdetails(); //获取活动详情
}, []);
useEffect(()=>{
useEffect(() => {
getsystemConfig(); //获取系统配置
setTimeout(()=>{
getdetails(); //获取活动详情
},500)
}, []);
useEffect(() => {
Taro.cloud.callFunction({
name: "getOpenid",
complete: async (res: any) => {
console.log("callFunction test result: ", res);
let newopenid = res?.result?.event?.userInfo?.openId;
setopenid(newopenid)
setopenid(newopenid);
},
});
},[isIn])
}, [isIn]);
const getdetails = async () => {
let objParams = {
tableName: "details",
// id: "80516fb66370bcf300b8f43c5f4dd52b",
okFun: (res: any) => {
okFun: async (res: any) => {
console.log("details--", res);
setdetails(res?.data ?? []);
await setdetails(res?.data ?? []);
},
};
await getTable(objParams);
@@ -98,9 +101,9 @@ const Home = () => {
let objParams = {
tableName: "systemConfig",
// id: "80516fb66370bcf300b8f43c5f4dd52b",
okFun: (res: any) => {
okFun: async (res: any) => {
console.log("systemConfig--", res);
setsystemConfig(res?.data ?? []);
await setsystemConfig(res?.data ?? []);
},
};
await getTable(objParams);
@@ -115,13 +118,12 @@ const Home = () => {
success: (res: any) => {
// get resource ID
console.log("res", res?.fileID);
checkIn({imageUrl:res?.fileID})
checkIn({ imageUrl: res?.fileID });
// 跳转到目的页面,打开新页面
// Taro.navigateTo({
// url: `/pages/home/components/CheckIn/index?fileID=${res?.fileID}`,
// });
},
fail: (err: any) => {
// handle error
@@ -145,7 +147,7 @@ const Home = () => {
};
// 签到
const checkIn = async (data:any) => {
const checkIn = async (data: any) => {
let postData = {
tableName: "userInfo",
keyValue: { openId: openid },
@@ -160,7 +162,7 @@ const Home = () => {
...(res?.data?.[0]?.checkInArr ?? []),
{
imageUrl: data?.imageUrl,
checkTime :new Date().valueOf(),//打卡时间
checkTime: new Date().valueOf(), //打卡时间
// remark: fieldValues?.remark,
// location: address,
},
@@ -174,7 +176,6 @@ const Home = () => {
duration: 2000,
onClose: () => {
// 跳转到打卡页面
// 返回首页 [上一页]
// Taro.navigateBack({
// delta: 1,
@@ -317,11 +318,19 @@ const Home = () => {
paginationVisible
onChange={onChange}
>
{(systemConfig?.[0]?.imagesArr ?? []).map((item: any, index: any) => (
<SwiperItem key={`swiper#demo1${index}`}>
<Image src={item?.url} fit="cover" width="100%" height="200px" />
</SwiperItem>
))}
{systemConfig?.length > 0 &&
(systemConfig?.[0]?.imagesArr ?? []).map(
(item: any, index: any) => (
<SwiperItem key={`swiper#demo1${index}`}>
<Image
src={item?.url}
fit="cover"
width="100%"
height="200px"
/>
</SwiperItem>
)
)}
</Swiper>
</View>
@@ -334,7 +343,7 @@ const Home = () => {
onClick={async () => {
// getLocation();
let isin: any = await phoneLogin();
setisIn(true)
setisIn(true);
console.log("isin", isin);
if (isin) {
chooseImage();
@@ -425,21 +434,25 @@ const Home = () => {
</Tabs> */}
{/* 截取数组2个活动 */}
{details.splice(0, 2).map((item: any, index: any) => {
return (
<View
onClick={() => {
console.log("Card");
Taro.navigateTo({
url: `/pages/activityList/components/details/index?id=${item?._id}`,
});
}}
>
{/* 活动卡片 */}
<ActiveCard dataSource={item} />
</View>
);
})}
{details?.length > 0 && (
<View>
{(details?.splice(0, 2) ?? []).map((item: any, index: any) => {
return (
<View
onClick={() => {
console.log("Card");
Taro.navigateTo({
url: `/pages/activityList/components/details/index?id=${item?._id}`,
});
}}
>
{/* 活动卡片 */}
<ActiveCard dataSource={item} />
</View>
);
})}
</View>
)}
{/* 直播live专区 */}
{/* <View>视频号直播</View> */}

View File

@@ -207,7 +207,7 @@ const my = (props: any) => {
{type !== "people" ||
(true && (
<Cell
icon="manager"
icon="star"
title="打卡记录"
isLink
onClick={() => {
@@ -226,7 +226,7 @@ const my = (props: any) => {
/>
))}
<Cell
{/* <Cell
icon="star"
title="我参与的"
isLink
@@ -243,24 +243,21 @@ const my = (props: any) => {
// });
}
}}
/>
/> */}
<Cell
icon="manager"
title="申请成为领队"
isLink
onClick={() => {
if (isin) {
// 跳转到目的页面,打开新页面
// Taro.navigateTo({
// url: "/pages/my/components/CheckinDetail/index",
// });
} else {
// Toast.fail({
// message: "请先登录",
// selector: "#vanToast-demo2",
// });
}
Toast.fail({
message: "首次参加活动后,可申请成为领队",
selector: "#vanToast-demo2",
});
// 跳转到目的页面,打开新页面
// Taro.navigateTo({
// url: "/pages/formSubmit/index",
// });
}}
/>
@@ -293,7 +290,7 @@ const my = (props: any) => {
/>
)}
<Cell
{/* <Cell
icon="friends"
title="关于我们"
isLink
@@ -303,7 +300,9 @@ const my = (props: any) => {
url: "/pages/my/components/AbountUs/index",
});
}}
/>
/> */}
{/* <Cell
icon="setting"
title="版本日志"