index.tsx 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. import classNames from "classnames";
  2. import { Image, View, Text, ScrollView } from "@tarojs/components";
  3. import Taro, { FC } from "@tarojs/taro";
  4. import { AtDrawer } from "taro-ui";
  5. import { AtDrawerProps } from "taro-ui/types/drawer";
  6. import { observer } from "mobx-react";
  7. import { getSceneUrl } from "../../../../utils";
  8. import baseStore from "../../../../store/base";
  9. import CloseIcon from "../../../../images/icon_back_menu@2x.png";
  10. import SearchIcon from "../../../../images/icon_search_black@2x-min.png";
  11. import MapIcon from "../../../../images/icon_map_normal@2x-min.png";
  12. import ActMapIcon from "../../../../images/icon_map_active@2x-min.png";
  13. import CityIcon from "../../../../images/icon_build_normal@2x-min.png";
  14. import ActCityIcon from "../../../../images/icon_build_active@2x-min.png";
  15. import UserIcon from "../../../../images/icon_user_normal@2x-min.png";
  16. import ActUserIcon from "../../../../images/icon_user_active@2x-min.png";
  17. import "./index.scss";
  18. import { useMemo } from "react";
  19. export interface MenuProps extends AtDrawerProps {
  20. openSearch(): void;
  21. }
  22. export const Menu: FC<MenuProps> = observer((props) => {
  23. const LIST = useMemo(
  24. () => [
  25. {
  26. label: "要素地图",
  27. icon: MapIcon,
  28. activeIcon: ActMapIcon,
  29. children: [
  30. {
  31. label: "全部遗存",
  32. link: "",
  33. },
  34. ],
  35. },
  36. {
  37. label: "锡善之城",
  38. icon: CityIcon,
  39. activeIcon: ActCityIcon,
  40. children: [
  41. {
  42. label: "慈善博物馆",
  43. link:
  44. "/subModule/pages/iframe/index?url=" +
  45. encodeURIComponent(
  46. "https://houseoss.4dkankan.com/project/wuxicishanbwg/index.html?m=TEST"
  47. ),
  48. },
  49. {
  50. label: "慈善云学校",
  51. link:
  52. "/subModule/pages/iframe/index?url=" +
  53. encodeURIComponent(getSceneUrl(0)),
  54. },
  55. {
  56. label: "慈善堂",
  57. link:
  58. "/subModule/pages/iframe/index?url=" +
  59. encodeURIComponent(getSceneUrl(1)),
  60. },
  61. {
  62. label: "慈善广场",
  63. link:
  64. "/subModule/pages/iframe/index?url=" +
  65. encodeURIComponent(getSceneUrl(2)),
  66. },
  67. {
  68. label: "爱心林场",
  69. link:
  70. "/subModule/pages/iframe/index?url=" +
  71. encodeURIComponent(getSceneUrl(3)),
  72. },
  73. ],
  74. },
  75. {
  76. label: "用户中心",
  77. icon: UserIcon,
  78. activeIcon: ActUserIcon,
  79. children: [
  80. {
  81. label: "个人设定",
  82. link:
  83. "/subModule/pages/iframe/index?url=" +
  84. encodeURIComponent(getSceneUrl(4)),
  85. },
  86. {
  87. label: "用户反馈",
  88. link: "/subModule/pages/feedback/index",
  89. needAuth: true,
  90. },
  91. {
  92. label: "爱心币商城",
  93. link: "/subModule/pages/shopmall/index",
  94. needAuth: true,
  95. },
  96. ],
  97. },
  98. ],
  99. []
  100. );
  101. return (
  102. <AtDrawer {...props} className="menu" width={Taro.pxTransform(550)}>
  103. <Image
  104. src={CloseIcon}
  105. className="menu__close"
  106. onClick={() => props.onClose?.()}
  107. />
  108. <Image
  109. src={SearchIcon}
  110. className="menu__search"
  111. onClick={() => props.openSearch()}
  112. />
  113. <ScrollView scrollY style={{ height: "100%" }}>
  114. {LIST.map((item, idx) => {
  115. const isActive = idx === 0;
  116. return (
  117. <View
  118. key={item.label}
  119. className={classNames("menu-item", { active: isActive })}
  120. >
  121. <View
  122. className={classNames("menu-item__title", {
  123. "is-active": isActive,
  124. })}
  125. >
  126. <Image
  127. className="menu-item__title__icon"
  128. src={isActive ? item.activeIcon : item.icon}
  129. />
  130. <Text>{item.label}</Text>
  131. {isActive && (
  132. <View className="menu-item__title reflect">
  133. <Image
  134. className="menu-item__title__icon"
  135. src={isActive ? item.activeIcon : item.icon}
  136. />
  137. <Text>{item.label}</Text>
  138. </View>
  139. )}
  140. </View>
  141. {item.children.map((subItem) => (
  142. <View
  143. className="menu-item__sub"
  144. onClick={() => {
  145. Taro.navigateTo({
  146. url:
  147. subItem.needAuth && !baseStore.isLogin
  148. ? "/pages/login/index"
  149. : subItem.link,
  150. });
  151. }}
  152. >
  153. {subItem.label}
  154. </View>
  155. ))}
  156. </View>
  157. );
  158. })}
  159. </ScrollView>
  160. </AtDrawer>
  161. );
  162. });