|
@@ -1,194 +1,62 @@
|
|
-import ChatAI from "@/components/chat-ai/index";
|
|
|
|
-import ComponentList from "@/components/component-list/index";
|
|
|
|
-// import CustomShare from "@/components/custom-share/index";
|
|
|
|
-// import FloatingTips from "@/components/floating-tips/index";
|
|
|
|
import NavBarNormal from "@/components/nav-bar-normal";
|
|
import NavBarNormal from "@/components/nav-bar-normal";
|
|
import PageCustom from "@/components/page-custom/index";
|
|
import PageCustom from "@/components/page-custom/index";
|
|
-import useObserve from "@/hooks/useObserve";
|
|
|
|
-import logo from "@/images/logo.png";
|
|
|
|
-import { useCharacterStore, useCharacterStyle } from "@/store/characterStore";
|
|
|
|
-import { sortComponentsByIndex } from "@/store/componentStore";
|
|
|
|
-import { ICharacter, TEntityComponent } from "@/types";
|
|
|
|
-import { useAppStore } from "@/store/appStore";
|
|
|
|
-import { getToken } from "@/utils/index";
|
|
|
|
|
|
+
|
|
import { Image, Text, View } from "@tarojs/components";
|
|
import { Image, Text, View } from "@tarojs/components";
|
|
-import Taro, { useDidShow, useRouter } from "@tarojs/taro";
|
|
|
|
-import { useState } from "react";
|
|
|
|
-import style from "./index.module.less";
|
|
|
|
-import { APP_NAME_TEXT } from '@/config'
|
|
|
|
-import { reportProfilePage } from '@/utils/report'
|
|
|
|
|
|
+import Logo from '@/components/logo'
|
|
|
|
+import TopBar from './components/top-bar'
|
|
|
|
|
|
export default function Index() {
|
|
export default function Index() {
|
|
- const router = useRouter();
|
|
|
|
- console.log(router.params, router)
|
|
|
|
- const { isShared, fromContact, scene } = router.params;
|
|
|
|
- const profileId = scene ?? router.params.profileId;
|
|
|
|
- const { getProfileById } = useCharacterStore();
|
|
|
|
- const { fetchAppConfig } = useAppStore();
|
|
|
|
- const characters = useCharacterStore((state) => state.characters);
|
|
|
|
- const { visible } = useObserve(this, true);
|
|
|
|
- const [character, setCharacter] = useState<ICharacter | null>(null);
|
|
|
|
- const [components, setComponents] = useState<TEntityComponent[] | null>(null);
|
|
|
|
- const { customStyled, customBgImg } = useCharacterStyle();
|
|
|
|
- const token = getToken();
|
|
|
|
- const launchOptions = Taro.getLaunchOptionsSync();
|
|
|
|
- // 如果有 referralCode 参数,则说明是通过分享的方式进入小程序,则需要获取 referralCode 参数
|
|
|
|
- const referralCode = launchOptions.query?.referralCode;
|
|
|
|
- const isMine = !!characters.find((item) => item.profileId === profileId);
|
|
|
|
- const pages = Taro.getCurrentPages();
|
|
|
|
-
|
|
|
|
- console.log(referralCode, profileId, isShared, fromContact);
|
|
|
|
-
|
|
|
|
- const showError = ()=> {
|
|
|
|
- // 从联系人页跳转过来的
|
|
|
|
- if (fromContact) {
|
|
|
|
- Taro.showModal({
|
|
|
|
- content: `😭 该${APP_NAME_TEXT}已经失效,长按可以将其从联系人中删除`,
|
|
|
|
- showCancel: false,
|
|
|
|
- });
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- Taro.showModal({
|
|
|
|
- content: `😭 该${APP_NAME_TEXT}已失效`,
|
|
|
|
- showCancel: false,
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- const fetchData = async () => {
|
|
|
|
- if (profileId) {
|
|
|
|
- Taro.showLoading();
|
|
|
|
- const res = await getProfileById(profileId);
|
|
|
|
- Taro.hideLoading();
|
|
|
|
- // 登录过期
|
|
|
|
- if(!res || res.code === 20001){
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if (!res.data) {
|
|
|
|
- showError()
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- setCharacter(res.data.character);
|
|
|
|
-
|
|
|
|
- const _components = res.data.components
|
|
|
|
- .filter((item) => item.enabled)
|
|
|
|
- .map((item) => {
|
|
|
|
- // 兼容老数据 type images 类型 变为 media
|
|
|
|
- if (item.type === "images" && item.data?.images?.length) {
|
|
|
|
- item.data.media = item.data.images.map((img: any) => {
|
|
|
|
- return {
|
|
|
|
- url: img.src,
|
|
|
|
- fileType: "image",
|
|
|
|
- };
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- return item;
|
|
|
|
- })
|
|
|
|
- .sort(sortComponentsByIndex);
|
|
|
|
-
|
|
|
|
- setComponents(_components);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- useDidShow(() => {
|
|
|
|
- fetchAppConfig();
|
|
|
|
- fetchData();
|
|
|
|
- });
|
|
|
|
|
|
|
|
- reportProfilePage(character?.profileId, character?.name)
|
|
|
|
|
|
|
|
- const back2Index = () => {
|
|
|
|
- Taro.switchTab({
|
|
|
|
- url: "/pages/index/index",
|
|
|
|
- });
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- const renderLeft = () => {
|
|
|
|
- return (
|
|
|
|
- <>
|
|
|
|
- <View className={style.backButton} onClick={back2Index}>
|
|
|
|
- <Text className={style.backButtonText}>{APP_NAME_TEXT}</Text>
|
|
|
|
- </View>
|
|
|
|
- </>
|
|
|
|
- );
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- const renderNavBar = () => {
|
|
|
|
- if (!isShared && pages.length > 1) {
|
|
|
|
- return (
|
|
|
|
- <NavBarNormal
|
|
|
|
- center={!visible}
|
|
|
|
- scrollFadeIn
|
|
|
|
- >
|
|
|
|
- <View className={style.title}>{!visible ? character?.name : ""}</View>
|
|
|
|
- </NavBarNormal>
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return (
|
|
|
|
- <NavBarNormal
|
|
|
|
- leftColumn={() => renderLeft()}
|
|
|
|
- center={!visible}
|
|
|
|
- scrollFadeIn
|
|
|
|
- >
|
|
|
|
- <View className={style.title}>{!visible ? character?.name : ""}</View>
|
|
|
|
- </NavBarNormal>
|
|
|
|
- );
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- const renderHomeButton = () => {
|
|
|
|
- return (
|
|
|
|
- <View className={style.homeButtonContainer} onClick={back2Index}>
|
|
|
|
- <View className={style.homeButton}>
|
|
|
|
- <View className={style.decorateLine}></View>
|
|
|
|
- <View className="flex items-center gap-8">
|
|
|
|
- <Image src={logo} mode="widthFix" className={style.logo}></Image>
|
|
|
|
- <Text className={style.homeButtonText}>{APP_NAME_TEXT},我的智能主页</Text>
|
|
|
|
- </View>
|
|
|
|
- <View className={style.decorateLine}></View>
|
|
|
|
- </View>
|
|
|
|
- {!isMine && isShared && (
|
|
|
|
- <View className="rounded-button-big">创建我的{APP_NAME_TEXT}</View>
|
|
|
|
- )}
|
|
|
|
- </View>
|
|
|
|
- );
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
|
|
// const renderFloatingTips = () => {
|
|
// const renderFloatingTips = () => {
|
|
// return isShared ? <FloatingTips></FloatingTips> : <></>;
|
|
// return isShared ? <FloatingTips></FloatingTips> : <></>;
|
|
// };
|
|
// };
|
|
|
|
|
|
- // 自定义背景样式
|
|
|
|
- const bgImageStyle = customBgImg
|
|
|
|
- ? {
|
|
|
|
- // background: `linear-gradient(rgba(242, 244, 245, 0) 0%, rgba(242, 244, 245, .8) 80% , rgba(242, 244, 245,1) 100%), url(${customBgImg})`,
|
|
|
|
- background: `url(${customBgImg})`,
|
|
|
|
- }
|
|
|
|
- : undefined;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
- <PageCustom style={bgImageStyle}>
|
|
|
|
- <View style={customStyled} className="w-full">
|
|
|
|
- {renderNavBar()}
|
|
|
|
- <View
|
|
|
|
- className="flex flex-col items-center gap-48 w-full"
|
|
|
|
- style={{ paddingBottom: "32px" }}
|
|
|
|
- >
|
|
|
|
- {character && token && (
|
|
|
|
- <ChatAI playGreeting getSession character={character}></ChatAI>
|
|
|
|
- )}
|
|
|
|
- <View className="px-16 flex flex-col gap-10 w-full">
|
|
|
|
- {components && (
|
|
|
|
- <ComponentList components={components}></ComponentList>
|
|
|
|
- )}
|
|
|
|
-
|
|
|
|
- </View>
|
|
|
|
- {/* {character && <CustomShare character={character}></CustomShare>} */}
|
|
|
|
|
|
+ <PageCustom>
|
|
|
|
+ <View className="w-full">
|
|
|
|
+ <NavBarNormal scrollFadeIn showBgColor leftColumn={Logo}></NavBarNormal>
|
|
|
|
+ <TopBar></TopBar>
|
|
|
|
+ <View className="p-16">
|
|
|
|
+ <View className="rounded-12 bg-white p-24">
|
|
|
|
+ 杭州茗视佳眼科,引入先进的精品专项医院运营模式,引进了阿玛仕1050rs、新版蔡司、生物力学分析仪、欧堡眼底照相等国际先进设备,汇聚浙一浙二的顶级近视手术专家手术。开展Smart全激光、半飞秒、全飞秒、ICL晶体植入以及多焦点人工晶体置换手术。
|
|
|
|
+ </View>
|
|
|
|
+ <View className="rounded-12 bg-white p-24">
|
|
|
|
+ 杭州茗视佳眼科,引入先进的精品专项医院运营模式,引进了阿玛仕1050rs、新版蔡司、生物力学分析仪、欧堡眼底照相等国际先进设备,汇聚浙一浙二的顶级近视手术专家手术。开展Smart全激光、半飞秒、全飞秒、ICL晶体植入以及多焦点人工晶体置换手术。
|
|
|
|
+ </View>
|
|
|
|
+ <View className="rounded-12 bg-white p-24">
|
|
|
|
+ 杭州茗视佳眼科,引入先进的精品专项医院运营模式,引进了阿玛仕1050rs、新版蔡司、生物力学分析仪、欧堡眼底照相等国际先进设备,汇聚浙一浙二的顶级近视手术专家手术。开展Smart全激光、半飞秒、全飞秒、ICL晶体植入以及多焦点人工晶体置换手术。
|
|
|
|
+ </View>
|
|
|
|
+ <View className="rounded-12 bg-white p-24">
|
|
|
|
+ 杭州茗视佳眼科,引入先进的精品专项医院运营模式,引进了阿玛仕1050rs、新版蔡司、生物力学分析仪、欧堡眼底照相等国际先进设备,汇聚浙一浙二的顶级近视手术专家手术。开展Smart全激光、半飞秒、全飞秒、ICL晶体植入以及多焦点人工晶体置换手术。
|
|
|
|
+ </View>
|
|
|
|
+ <View className="rounded-12 bg-white p-24">
|
|
|
|
+ 杭州茗视佳眼科,引入先进的精品专项医院运营模式,引进了阿玛仕1050rs、新版蔡司、生物力学分析仪、欧堡眼底照相等国际先进设备,汇聚浙一浙二的顶级近视手术专家手术。开展Smart全激光、半飞秒、全飞秒、ICL晶体植入以及多焦点人工晶体置换手术。
|
|
|
|
+ </View>
|
|
|
|
+ <View className="rounded-12 bg-white p-24">
|
|
|
|
+ 杭州茗视佳眼科,引入先进的精品专项医院运营模式,引进了阿玛仕1050rs、新版蔡司、生物力学分析仪、欧堡眼底照相等国际先进设备,汇聚浙一浙二的顶级近视手术专家手术。开展Smart全激光、半飞秒、全飞秒、ICL晶体植入以及多焦点人工晶体置换手术。
|
|
|
|
+ </View>
|
|
|
|
+ <View className="rounded-12 bg-white p-24">
|
|
|
|
+ 杭州茗视佳眼科,引入先进的精品专项医院运营模式,引进了阿玛仕1050rs、新版蔡司、生物力学分析仪、欧堡眼底照相等国际先进设备,汇聚浙一浙二的顶级近视手术专家手术。开展Smart全激光、半飞秒、全飞秒、ICL晶体植入以及多焦点人工晶体置换手术。
|
|
|
|
+ </View>
|
|
|
|
+ <View className="rounded-12 bg-white p-24">
|
|
|
|
+ 杭州茗视佳眼科,引入先进的精品专项医院运营模式,引进了阿玛仕1050rs、新版蔡司、生物力学分析仪、欧堡眼底照相等国际先进设备,汇聚浙一浙二的顶级近视手术专家手术。开展Smart全激光、半飞秒、全飞秒、ICL晶体植入以及多焦点人工晶体置换手术。
|
|
|
|
+ </View>
|
|
|
|
+ <View className="rounded-12 bg-white p-24">
|
|
|
|
+ 杭州茗视佳眼科,引入先进的精品专项医院运营模式,引进了阿玛仕1050rs、新版蔡司、生物力学分析仪、欧堡眼底照相等国际先进设备,汇聚浙一浙二的顶级近视手术专家手术。开展Smart全激光、半飞秒、全飞秒、ICL晶体植入以及多焦点人工晶体置换手术。
|
|
|
|
+ </View>
|
|
|
|
+ <View className="rounded-12 bg-white p-24">
|
|
|
|
+ 杭州茗视佳眼科,引入先进的精品专项医院运营模式,引进了阿玛仕1050rs、新版蔡司、生物力学分析仪、欧堡眼底照相等国际先进设备,汇聚浙一浙二的顶级近视手术专家手术。开展Smart全激光、半飞秒、全飞秒、ICL晶体植入以及多焦点人工晶体置换手术。
|
|
|
|
+ </View>
|
|
|
|
+ <View className="rounded-12 bg-white p-24">
|
|
|
|
+ 杭州茗视佳眼科,引入先进的精品专项医院运营模式,引进了阿玛仕1050rs、新版蔡司、生物力学分析仪、欧堡眼底照相等国际先进设备,汇聚浙一浙二的顶级近视手术专家手术。开展Smart全激光、半飞秒、全飞秒、ICL晶体植入以及多焦点人工晶体置换手术。
|
|
|
|
+ </View>
|
|
</View>
|
|
</View>
|
|
- {renderHomeButton()}
|
|
|
|
- {/* {renderFloatingTips()} */}
|
|
|
|
</View>
|
|
</View>
|
|
</PageCustom>
|
|
</PageCustom>
|
|
);
|
|
);
|