|
@@ -17,7 +17,6 @@ import Taro, {
|
|
|
} from "@tarojs/taro";
|
|
|
import { Menu } from "./components/Menu";
|
|
|
import BtmBgImg from "../../images/img_city-min.png";
|
|
|
-import BgImg from "../../images/img_map@2x-min.jpg";
|
|
|
import CloudImg from "../../images/img_cloud-min.png";
|
|
|
import LeftIcon from "../../images/icon_blue_left@2x-min.png";
|
|
|
import RightIcon from "../../images/icon_blue_right@2x-min.png";
|
|
@@ -26,10 +25,12 @@ import { Swiper as SightSwiper, SwiperMethods } from "./components/Swiper";
|
|
|
import { SearchLayout } from "./components/SearchLayout";
|
|
|
import { SightDetailLayout } from "./components/SightDetailLayout";
|
|
|
import { SIGHT_LIST, SORT_MAP_ID } from "./constants";
|
|
|
-import { checkLoginApi, getSignListApi } from "../../api";
|
|
|
+import { getSignListApi } from "../../api";
|
|
|
import { VisitCard } from "./components/VisitCard";
|
|
|
-import { getSceneUrl, NICKNAME_key, TOKEN_KEY } from "../../utils";
|
|
|
+import { getSceneUrl, login } from "../../utils";
|
|
|
import baseStore from "../../store/base";
|
|
|
+import SearchIcon from "../../images/icon_search_white@2x-min.png";
|
|
|
+import { PageSwiper } from "../../components/PageSwiper";
|
|
|
import "./index.scss";
|
|
|
|
|
|
const PointIcon = memo(() => {
|
|
@@ -76,14 +77,19 @@ const HomePage: FC = () => {
|
|
|
[curSwiperItem]
|
|
|
);
|
|
|
|
|
|
- const openSearch = () => {
|
|
|
- setShowMenu(false);
|
|
|
+ const openSearch = (closeMenu?: boolean) => {
|
|
|
+ closeMenu && setShowMenu(false);
|
|
|
setShowSearch(true);
|
|
|
+ if (!closeMenu) {
|
|
|
+ swiperRef.current?.setIsRunning(false);
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
- const handleDetail = async () => {
|
|
|
+ const handleDetail = async (id?: number) => {
|
|
|
swiperRef.current?.setIsRunning(false);
|
|
|
- const target = SIGHT_LIST.find((i) => i.id === SORT_MAP_ID[curSwiperItem]);
|
|
|
+ const target = SIGHT_LIST.find(
|
|
|
+ (i) => i.id === (id || SORT_MAP_ID[curSwiperItem])
|
|
|
+ );
|
|
|
const data = await getSignListApi({
|
|
|
searchKey: target?.title,
|
|
|
type: "scene",
|
|
@@ -113,29 +119,6 @@ const HomePage: FC = () => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- const checkLogin = async () => {
|
|
|
- try {
|
|
|
- Taro.showLoading({
|
|
|
- title: "登录中...",
|
|
|
- });
|
|
|
- const data = await checkLoginApi();
|
|
|
-
|
|
|
- if (data) {
|
|
|
- baseStore.isLogin = true;
|
|
|
- Taro.navigateTo({
|
|
|
- url:
|
|
|
- "/subModule/pages/iframe/index?url=" +
|
|
|
- encodeURIComponent(getSceneUrl()),
|
|
|
- });
|
|
|
- } else {
|
|
|
- Taro.removeStorageSync(TOKEN_KEY);
|
|
|
- Taro.removeStorageSync(NICKNAME_key);
|
|
|
- }
|
|
|
- } finally {
|
|
|
- Taro.hideLoading();
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
useDidShow(() => {
|
|
|
loaded && swiperRef.current?.setIsRunning(true);
|
|
|
});
|
|
@@ -153,7 +136,17 @@ const HomePage: FC = () => {
|
|
|
}}
|
|
|
/>
|
|
|
|
|
|
- <Menu show={showMenu} onClose={closeMenu} openSearch={openSearch} />
|
|
|
+ <Menu
|
|
|
+ show={showMenu}
|
|
|
+ onClose={closeMenu}
|
|
|
+ openSearch={openSearch.bind(undefined, true)}
|
|
|
+ />
|
|
|
+
|
|
|
+ <Image
|
|
|
+ src={SearchIcon}
|
|
|
+ className="home__search"
|
|
|
+ onClick={() => openSearch()}
|
|
|
+ />
|
|
|
|
|
|
<Swiper
|
|
|
vertical
|
|
@@ -188,6 +181,7 @@ const HomePage: FC = () => {
|
|
|
ref={swiperRef}
|
|
|
curSwiperItem={curSwiperItem}
|
|
|
setCurSwiperItem={setCurSwiperItem}
|
|
|
+ handleDetail={handleDetail}
|
|
|
/>
|
|
|
|
|
|
<View className="home-toggle">
|
|
@@ -207,7 +201,7 @@ const HomePage: FC = () => {
|
|
|
|
|
|
<View
|
|
|
className="home-toggle__detail"
|
|
|
- onClick={handleDetail}
|
|
|
+ onClick={() => handleDetail()}
|
|
|
/>
|
|
|
</View>
|
|
|
|
|
@@ -228,23 +222,14 @@ const HomePage: FC = () => {
|
|
|
|
|
|
<Image
|
|
|
className="home__bg"
|
|
|
- src={BgImg}
|
|
|
+ src="https://houseoss.4dkankan.com/project/wx-csbwg-public/images/img_map%402x-min.jpg"
|
|
|
mode="widthFix"
|
|
|
style={{
|
|
|
top: `${-offsetHeight}px`,
|
|
|
}}
|
|
|
/>
|
|
|
<Image className="home__btm-bg" src={BtmBgImg} mode="widthFix" />
|
|
|
- <Image
|
|
|
- className="home__cloud cloud1"
|
|
|
- src={CloudImg}
|
|
|
- mode="heightFix"
|
|
|
- />
|
|
|
- <Image
|
|
|
- className="home__cloud cloud2"
|
|
|
- src={CloudImg}
|
|
|
- mode="heightFix"
|
|
|
- />
|
|
|
+ <Image className="home__cloud" src={CloudImg} mode="heightFix" />
|
|
|
</View>
|
|
|
</SwiperItem>
|
|
|
|
|
@@ -253,16 +238,35 @@ const HomePage: FC = () => {
|
|
|
className="home2__btn"
|
|
|
src={ButtonImg}
|
|
|
mode="widthFix"
|
|
|
- onClick={() => {
|
|
|
- const token = Taro.getStorageSync(TOKEN_KEY);
|
|
|
+ onClick={async () => {
|
|
|
+ const userInfo = baseStore.userInfo;
|
|
|
|
|
|
- if (token) {
|
|
|
- checkLogin();
|
|
|
- } else {
|
|
|
+ if (!userInfo) {
|
|
|
+ await login();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (userInfo.invite === 0) {
|
|
|
setVisitVisible(true);
|
|
|
+ return;
|
|
|
}
|
|
|
+
|
|
|
+ Taro.navigateTo({
|
|
|
+ url:
|
|
|
+ "/subModule/pages/iframe/index?url=" +
|
|
|
+ encodeURIComponent(getSceneUrl()),
|
|
|
+ });
|
|
|
}}
|
|
|
/>
|
|
|
+
|
|
|
+ <Video
|
|
|
+ className="home2__bg"
|
|
|
+ src="https://houseoss.4dkankan.com/project/wx-csbwg-public/videos/city.mp4"
|
|
|
+ autoplay
|
|
|
+ muted
|
|
|
+ loop
|
|
|
+ controls={false}
|
|
|
+ objectFit="cover"
|
|
|
+ />
|
|
|
</SwiperItem>
|
|
|
</Swiper>
|
|
|
|
|
@@ -284,7 +288,12 @@ const HomePage: FC = () => {
|
|
|
|
|
|
<SearchLayout
|
|
|
isOpened={showSearch}
|
|
|
- onClose={() => setShowSearch(false)}
|
|
|
+ onClose={() => {
|
|
|
+ setShowSearch(false);
|
|
|
+ if (curSwiper === 0) {
|
|
|
+ swiperRef.current?.setIsRunning(true);
|
|
|
+ }
|
|
|
+ }}
|
|
|
openDetail={(item) => {
|
|
|
swiperRef.current?.setIsRunning(false);
|
|
|
setItem(item);
|
|
@@ -304,6 +313,8 @@ const HomePage: FC = () => {
|
|
|
isOpened={visitVisible}
|
|
|
onClose={() => setVisitVisible(false)}
|
|
|
/>
|
|
|
+
|
|
|
+ {/* <PageSwiper /> */}
|
|
|
</>
|
|
|
);
|
|
|
};
|