|
@@ -1,6 +1,14 @@
|
|
|
import { useMemo, useRef, useState } from "react";
|
|
|
import { Image, View, Text } from "@tarojs/components";
|
|
|
-import { FC, pxTransform, useDidHide, useDidShow } from "@tarojs/taro";
|
|
|
+import classNames from "classnames";
|
|
|
+import { AtIcon } from "taro-ui";
|
|
|
+import Taro, {
|
|
|
+ FC,
|
|
|
+ nextTick,
|
|
|
+ pxTransform,
|
|
|
+ useDidHide,
|
|
|
+ useDidShow,
|
|
|
+} from "@tarojs/taro";
|
|
|
import { Menu } from "./components/Menu";
|
|
|
import BtmBgImg from "../../images/img_map2@2x-min.png";
|
|
|
import BgImg from "../../images/img_map@2x-min.png";
|
|
@@ -14,14 +22,20 @@ import { SIGHT_LIST } from "./constants";
|
|
|
import "./index.scss";
|
|
|
|
|
|
const HomePage: FC = () => {
|
|
|
+ const [loaded, setLoaded] = useState(false);
|
|
|
const [showMenu, setShowMenu] = useState(false);
|
|
|
const [showSearch, setShowSearch] = useState(false);
|
|
|
const [showSight, setShowSight] = useState(false);
|
|
|
const swiperRef = useRef<SwiperMethods>(null);
|
|
|
const [curSwiperItem, setCurSwiperItem] = useState(10);
|
|
|
- const item = useMemo(() => {
|
|
|
- return SIGHT_LIST.find((i) => i.id === curSwiperItem);
|
|
|
- }, [curSwiperItem]);
|
|
|
+ const [item, setItem] = useState(
|
|
|
+ SIGHT_LIST.find((i) => i.id === curSwiperItem)
|
|
|
+ );
|
|
|
+
|
|
|
+ const realItem = useMemo(
|
|
|
+ () => SIGHT_LIST.find((i) => i.id === curSwiperItem),
|
|
|
+ [curSwiperItem]
|
|
|
+ );
|
|
|
|
|
|
const openSearch = () => {
|
|
|
setShowMenu(false);
|
|
@@ -30,6 +44,7 @@ const HomePage: FC = () => {
|
|
|
|
|
|
const handleDetail = () => {
|
|
|
swiperRef.current?.setIsRunning(false);
|
|
|
+ setItem(SIGHT_LIST.find((i) => i.id === curSwiperItem));
|
|
|
setShowSight(true);
|
|
|
};
|
|
|
|
|
@@ -38,8 +53,20 @@ const HomePage: FC = () => {
|
|
|
swiperRef.current?.setIsRunning(true);
|
|
|
};
|
|
|
|
|
|
- useDidShow(() => {
|
|
|
+ const closeMenu = () => {
|
|
|
+ setShowMenu(false);
|
|
|
swiperRef.current?.setIsRunning(true);
|
|
|
+ };
|
|
|
+
|
|
|
+ const handleLoaded = () => {
|
|
|
+ nextTick(() => {
|
|
|
+ setLoaded(true);
|
|
|
+ swiperRef.current?.setIsRunning(true);
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ useDidShow(() => {
|
|
|
+ loaded && swiperRef.current?.setIsRunning(true);
|
|
|
});
|
|
|
useDidHide(() => {
|
|
|
swiperRef.current?.setIsRunning(false);
|
|
@@ -47,6 +74,15 @@ const HomePage: FC = () => {
|
|
|
|
|
|
return (
|
|
|
<View className="home-container">
|
|
|
+ <View className={classNames("ld-page", { hide: loaded })}>
|
|
|
+ <AtIcon
|
|
|
+ className="ld-page__icon"
|
|
|
+ value="loading"
|
|
|
+ color="#589498"
|
|
|
+ size={40}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+
|
|
|
<View className="home">
|
|
|
<View
|
|
|
className="home__menu-btn"
|
|
@@ -66,14 +102,7 @@ const HomePage: FC = () => {
|
|
|
/>
|
|
|
)}
|
|
|
|
|
|
- <Menu
|
|
|
- show={showMenu}
|
|
|
- onClose={() => {
|
|
|
- setShowMenu(false);
|
|
|
- swiperRef.current?.setIsRunning(true);
|
|
|
- }}
|
|
|
- openSearch={openSearch}
|
|
|
- />
|
|
|
+ <Menu show={showMenu} onClose={closeMenu} openSearch={openSearch} />
|
|
|
|
|
|
<View className="home-main">
|
|
|
<Swiper
|
|
@@ -92,9 +121,9 @@ const HomePage: FC = () => {
|
|
|
<View className="home-toggle-inner">
|
|
|
<View className="home-toggle-label">
|
|
|
<Text className="home-toggle-label__title limit-line">
|
|
|
- {item?.title}
|
|
|
+ {realItem?.title}
|
|
|
</Text>
|
|
|
- <Text>{item?.address}</Text>
|
|
|
+ <Text>{realItem?.address}</Text>
|
|
|
</View>
|
|
|
|
|
|
<View className="home-toggle__detail" onClick={handleDetail}>
|
|
@@ -114,17 +143,32 @@ const HomePage: FC = () => {
|
|
|
mode="widthFix"
|
|
|
className="home-main__btn__btn"
|
|
|
src={ButtonImg}
|
|
|
+ onClick={() => {
|
|
|
+ Taro.navigateTo({
|
|
|
+ url: "/subModule/pages/iframe/index?url=https://houseoss.4dkankan.com/project/wx-csbwg-public/web/index.html",
|
|
|
+ });
|
|
|
+ }}
|
|
|
/>
|
|
|
</View>
|
|
|
</View>
|
|
|
|
|
|
- <Image className="home__bg" src={BgImg} mode="widthFix" />
|
|
|
+ <Image
|
|
|
+ className="home__bg"
|
|
|
+ src={BgImg}
|
|
|
+ mode="widthFix"
|
|
|
+ onLoad={handleLoaded}
|
|
|
+ />
|
|
|
<Image className="home__btm-bg" src={BtmBgImg} mode="widthFix" />
|
|
|
</View>
|
|
|
|
|
|
<SearchLayout
|
|
|
isOpened={showSearch}
|
|
|
onClose={() => setShowSearch(false)}
|
|
|
+ openDetail={(item) => {
|
|
|
+ swiperRef.current?.setIsRunning(false);
|
|
|
+ setItem(item);
|
|
|
+ setShowSight(true);
|
|
|
+ }}
|
|
|
/>
|
|
|
|
|
|
{item && (
|