index.tsx 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. import { View } from "@tarojs/components";
  2. import { Gift, Home, User } from "@nutui/icons-react-taro";
  3. import { navigateTo, redirectTo, getStorageSync } from "@tarojs/taro";
  4. import PostList from "../../components/post-list";
  5. import "./index.scss";
  6. import {
  7. Image,
  8. NoticeBar,
  9. Tabbar,
  10. TabPane,
  11. Tabs,
  12. } from "@nutui/nutui-react-taro";
  13. import { useEffect, useRef, useState } from "react";
  14. import { getCircleInfoApi } from "../../api/circle";
  15. import GameIntro from "../../components/game-intro";
  16. function Index() {
  17. const [circleData, setCircleData] = useState<any>(null);
  18. const [tab1value, setTab1value] = useState<string | number>("1");
  19. const containerTopRef = useRef<HTMLDivElement>(null);
  20. const [vipUserInfo, setVipUserInfo] = useState<any>(null);
  21. useEffect(() => {
  22. getCircleInfoApi({ id: 1 }).then((res: any) => {
  23. setCircleData(res.data);
  24. });
  25. setVipUserInfo(getStorageSync("vipInfo"));
  26. }, []);
  27. return (
  28. <View ref={containerTopRef} className="index">
  29. {/* 头部导航栏 - 移出page-content容器 */}
  30. <View
  31. className="index-header bg-[#6069d9] fixed top-0 left-0 right-0 z-20 h-[70px] w-full px-[10px]"
  32. style={{
  33. backgroundImage: `url(${circleData?.icon_url})`,
  34. backgroundSize: "cover",
  35. backgroundPosition: "center",
  36. backgroundRepeat: "no-repeat",
  37. }}
  38. >
  39. <View className="flex items-center justify-between">
  40. <View className="flex items-center relative z-40 py-[10px]">
  41. <View className="w-[45px] h-[45px] bg-[#fff] rounded-[50%] overflow-hidden">
  42. <Image
  43. src={circleData?.icon_url}
  44. width="100%"
  45. height="100%"
  46. mode="aspectFill"
  47. />
  48. </View>
  49. <View>
  50. <View className="text-[16px] font-[800] text-[#fff] ml-[10px]">
  51. {circleData?.name}
  52. </View>
  53. <View className="text-[12px] text-[#ccc] ml-[10px]">
  54. 3400人在线
  55. </View>
  56. </View>
  57. </View>
  58. <View className="flex items-center">
  59. {/* <View
  60. onClick={() => {
  61. navigateTo({ url: "/pages/self/index" });
  62. }}
  63. >
  64. <User size={22} />
  65. </View> */}
  66. </View>
  67. </View>
  68. </View>
  69. {/* 页面内容 - 使用ScrollView控制整个页面滚动 */}
  70. <View className="page-content">
  71. {vipUserInfo && (
  72. <View className="flex items-center justify-around w-[100%]">
  73. <View
  74. className="text-[#fff] w-[28%] h-[30px] flex items-center justify-center text-center text-[12px] rounded-[5px] font-[800] px-[10px] bg-[#5258acf0] "
  75. onClick={() => {
  76. navigateTo({ url: "/pages/act/index" });
  77. }}
  78. >
  79. 积分中心
  80. </View>
  81. <View
  82. className="text-[#fff] w-[28%] h-[30px] flex items-center justify-center text-center text-[12px] rounded-[5px] font-[800] px-[10px] bg-[#5258acf0]"
  83. onClick={() => {
  84. navigateTo({ url: "/pages/gift/index" });
  85. }}
  86. >
  87. <Gift size={16} />
  88. 礼包中心
  89. </View>
  90. {/* <View
  91. className="text-[#fff] w-[28%] h-[30px] flex items-center justify-center text-center text-[12px] rounded-[5px] font-[800] px-[10px] bg-[#5258acf0]"
  92. onClick={() => {
  93. navigateTo({ url: "/pages/publish/index" });
  94. }}
  95. >
  96. <Plus size={20} />
  97. 发布帖子
  98. </View> */}
  99. </View>
  100. )}
  101. {vipUserInfo?.notice && <NoticeBar content={vipUserInfo.notice} />}
  102. <View
  103. style={{
  104. height: vipUserInfo ? "calc(100vh - 180px)" : "calc(100vh - 100px)",
  105. }}
  106. >
  107. <Tabs
  108. align="left"
  109. autoHeight
  110. value={tab1value}
  111. onChange={(value) => {
  112. setTab1value(value);
  113. }}
  114. >
  115. {vipUserInfo?.download_list && (
  116. <TabPane title="游戏介绍" value="0">
  117. <GameIntro
  118. style={{
  119. height: vipUserInfo
  120. ? "calc(100vh - 260px)"
  121. : "calc(100vh - 180px)",
  122. }}
  123. vipUserInfo={vipUserInfo}
  124. />
  125. </TabPane>
  126. )}
  127. <TabPane title="官方咨讯" value="1">
  128. <PostList
  129. style={{
  130. height: vipUserInfo
  131. ? "calc(100vh - 260px)"
  132. : "calc(100vh - 180px)",
  133. }}
  134. />
  135. </TabPane>
  136. </Tabs>
  137. </View>
  138. <View className="bg-[#fff] fixed bottom-[0px] left-[0px] right-[0px] w-full">
  139. <Tabbar
  140. defaultValue={0}
  141. onSwitch={(value) => {
  142. if (value === 1) {
  143. redirectTo({ url: "/pages/self/index" });
  144. } else {
  145. redirectTo({ url: "/pages/index/index" });
  146. }
  147. }}
  148. >
  149. <Tabbar.Item title="首页" icon={<Home width={20} height={20} />} />
  150. <Tabbar.Item title="我的" icon={<User width={20} height={20} />} />
  151. </Tabbar>
  152. </View>
  153. </View>
  154. </View>
  155. );
  156. }
  157. export default Index;