index.tsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. import Flex from "@/component/flex";
  2. import UserApi from "@/apis/userApi";
  3. import APPConfig from "@/config";
  4. import { useRequest } from "ahooks";
  5. import Layout from "@/component/layout";
  6. import Padding, { EdgeInsets } from "@/component/padding";
  7. import SizeBox from "@/component/sizeBox";
  8. import AppContext from "@/context/appContext";
  9. import ImageUtil from "@/utils/imgUtils";
  10. import { Image, View, Text ,Input, Button as TaroButton } from "@tarojs/components";
  11. import { PropsWithChildren, useContext ,useRef} from "react";
  12. import useStore from "@/hooks/useRedux";
  13. import RouteUtil from "@/utils/routeUtil";
  14. import UserHelper from "@/helper/userHelper";
  15. import Button from "@/component/button";
  16. import { parseQueryParams, isOuterLink } from "@/utils/toolsUtil";
  17. import "./index.scss";
  18. import LoginBox from "../components/LoginBox";
  19. interface IMineProps {}
  20. const Mine = (props: PropsWithChildren<IMineProps>) => {
  21. const appContext = useContext(AppContext);
  22. const { screenSize } = useContext(AppContext);
  23. const { statusBarHeight } = appContext.systemInfo!;
  24. const userInfo = useStore((p) => p.userInfo);
  25. const isUserLogin = UserHelper.isLogin()
  26. const indexInfoResult = useRequest(() => {
  27. return UserApi.getIndexInfoUsingPost({
  28. params: { appId: APPConfig.APPID },
  29. }).toData();
  30. });
  31. const childRef:any = useRef()
  32. const handleOpen = () => {
  33. childRef.current.handleOpen()
  34. }
  35. const postJumpUrlResult = () => {
  36. const params = parseQueryParams(indexInfoResult.data.link)
  37. return UserApi.getJumpUrlPost({
  38. loading: true,
  39. data: { appId: APPConfig.APPID, channelCode: params.channelCode, productId: params.productId }
  40. }).toData().then(res => {
  41. console.log("获取跳转链接结果", res)
  42. RouteUtil.toWebViewPage({ url: res?.adJumpLink })
  43. })
  44. }
  45. const loginFlowHandler = () => {
  46. UserHelper.UpdateOpenId()
  47. if (isOuterLink(indexInfoResult.data.link)) {
  48. postJumpUrlResult()
  49. } else {
  50. RouteUtil.toWebViewPage({ url: indexInfoResult.data.link })
  51. }
  52. }
  53. const ApplyButton = ({ isLogin }) => {
  54. return (
  55. <>
  56. {
  57. isLogin ? (<Button className='mine-apply-panel-button' onClick={() => {
  58. UserHelper.afterLogin({
  59. pop: false,
  60. callback: async () => {
  61. indexInfoResult.data && loginFlowHandler()
  62. },
  63. });
  64. }}
  65. >立即申请</Button>) : (<Button onClick={handleOpen}
  66. className='mine-apply-panel-button'
  67. >立即申请</Button>)
  68. }
  69. </>
  70. )
  71. }
  72. const LoginBoxs = ({ isLogin ,userName}) => {
  73. return(
  74. <>
  75. { isLogin?
  76. <View
  77. className="mine-info"
  78. >
  79. <Padding padding={EdgeInsets.symmetric({ horizontal: 20 })}>
  80. <Image
  81. src={require("../../../assets/icon_head.png")}
  82. className='avatar-image-head'
  83. />
  84. </Padding>
  85. <View className="mine-box">
  86. <Text className='mine-login'>{userName}</Text>
  87. <Text className='mine-text'>欢迎来到惠融钱包~</Text>
  88. </View>
  89. </View> :
  90. <View
  91. className="mine-info"
  92. onClick={handleOpen}
  93. >
  94. <Padding padding={EdgeInsets.symmetric({ horizontal: 20 })}>
  95. <Image
  96. src={require("../../../assets/icon_head.png")}
  97. className='avatar-image-head'
  98. />
  99. </Padding>
  100. <View className="mine-box">
  101. <Text className='mine-login'>登录/注册</Text>
  102. <Text className='mine-text'>欢迎来到惠融钱包~</Text>
  103. </View>
  104. </View>
  105. }
  106. </>
  107. )
  108. }
  109. const maskPhone = (phone:string) => {
  110. if (!phone || phone.length !== 11) return phone; // 确保电话号码有效且长度为11位
  111. return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1***$2');
  112. }
  113. const userName = maskPhone(userInfo.userMobile);
  114. return (
  115. <Layout className='mine' bottomBarIndex={1}>
  116. <SizeBox height={statusBarHeight}></SizeBox>
  117. <SizeBox height={36}></SizeBox>
  118. <LoginBoxs isLogin={isUserLogin} userName={userName}></LoginBoxs>
  119. <View
  120. className='mine-apply-panel'
  121. style={{
  122. ...ImageUtil.calculationHeight(
  123. 750 / 324,
  124. appContext.systemInfo!.screenWidth - 32
  125. ),
  126. position: "relative",
  127. }}
  128. >
  129. <Text className='mine-apply-panel-title'>最高可申请(元)</Text>
  130. <Flex justifyContent='space-between' alignItem='center' direction='row'>
  131. <Text className='mine-apply-panel-money'>200,000</Text>
  132. {/* <Button
  133. className='mine-apply-panel-button'
  134. onClick={() => {
  135. UserHelper.afterLogin({
  136. pop: false,
  137. callback: async () => {
  138. indexInfoResult.data &&
  139. RouteUtil.toWebViewPage({
  140. url: indexInfoResult.data.link,
  141. });
  142. },
  143. });
  144. }}
  145. >
  146. 立即申请
  147. </Button> */}
  148. <ApplyButton isLogin={isUserLogin}></ApplyButton>
  149. </Flex>
  150. <Flex
  151. justifyContent='flex-start'
  152. alignItem='center'
  153. direction='row'
  154. columnGap={12}
  155. className='mine-apply-panel-tip'
  156. >
  157. <Text>年化利率7.2-24%(单利)</Text>
  158. <View className='split-char'></View>
  159. <Text>期限3-36个月</Text>
  160. </Flex>
  161. </View>
  162. <View className='mine-apply-panel-warn'>
  163. <Image src={require('@/assets/new-edition/icon-info.png')} className='icon-info' />
  164. <Text>具体额度以资金方审批为准</Text>
  165. </View>
  166. {/* <View
  167. style={{
  168. ...ImageUtil.calculationHeight(750 / 328, screenSize.width),
  169. position: "relative",
  170. }}
  171. onClick={() => {
  172. UserHelper.afterLogin({
  173. pop: false,
  174. callback: async () => {},
  175. });
  176. }}
  177. >
  178. <Flex justifyContent="flex-end" className="background-content">
  179. <Padding padding={EdgeInsets.symmetric({ horizontal: 32 })}>
  180. <Flex columnGap={32} direction="row" alignItem="center">
  181. <Image
  182. src={require("@/assets/icon_mine_avatar.png")}
  183. className="mine-avatar"
  184. />
  185. <Label bold>
  186. {userInfo ? `HI,${userInfo.userMobile}` : "点击此处登录"}
  187. </Label>
  188. </Flex>
  189. </Padding>
  190. </Flex>
  191. </View> */}
  192. <SizeBox height={16} />
  193. <Padding padding={EdgeInsets.symmetric({ horizontal: 32 })}>
  194. <View className='mine-tools-panel-title'>我的工具</View>
  195. <View className='mine-tools-panel'>
  196. <TaroButton
  197. open-type='contact'
  198. session-from='sessionFrom'
  199. className='mine-tools-item'
  200. >
  201. <Image
  202. src={require("@/assets/new-edition/icon-service.svg")}
  203. className='mine-tools-item-icon'
  204. />
  205. <Text className='mine-tools-item-title'>在线客服</Text>
  206. <Image
  207. src={require("@/assets/new-edition/icon-arrow-right.svg")}
  208. className='icon-arrow'
  209. />
  210. </TaroButton>
  211. <View
  212. className='mine-tools-item'
  213. onClick={() => {
  214. RouteUtil.push("/pages/user/setting/index");
  215. }}
  216. >
  217. <Image
  218. src={require("@/assets/new-edition/icon-setting.svg")}
  219. className='mine-tools-item-icon'
  220. />
  221. <View className='mine-tools-item-title'>系统设置</View>
  222. <Image
  223. src={require("@/assets/new-edition/icon-arrow-right.svg")}
  224. className='icon-arrow'
  225. />
  226. </View>
  227. </View>
  228. </Padding>
  229. <SizeBox height={20} />
  230. <Padding padding={EdgeInsets.symmetric({ horizontal: 32 })}>
  231. <Image
  232. onClick={() => {
  233. // https://huirong.bicredit.xin/
  234. RouteUtil.toWebViewPage({
  235. url: "https://mp.weixin.qq.com/s/4umQqPbPGfCgXqCizeXqKA",
  236. });
  237. }}
  238. src={require("@/assets/new-edition/wechat-official.png")}
  239. className='mine-image-wechat-official'
  240. />
  241. </Padding>
  242. {/* <Flex direction="row" className="mine-menu">
  243. <Flex
  244. onClick={() => {
  245. // https://huirong.bicredit.xin/
  246. RouteUtil.toWebViewPage({
  247. url: "https://h5.bicredit.xin/view/webapp/business-cooperation.html",
  248. });
  249. }}
  250. columnGap="sm"
  251. direction="row"
  252. alignItem="center"
  253. justifyContent="center"
  254. flex={1}
  255. className="mine-menu-wrap"
  256. >
  257. <Label>商务合作</Label>
  258. <Image
  259. src={require("@/assets/icon_mine_business.png")}
  260. className="mine-menu-icon"
  261. />
  262. </Flex>
  263. <SizeBox width={16} />
  264. <Flex flex={1}>
  265. <Button
  266. className="mine-menu-wrap"
  267. open-type="contact"
  268. session-from="sessionFrom"
  269. >
  270. <Flex
  271. columnGap="sm"
  272. direction="row"
  273. alignItem="center"
  274. justifyContent="center"
  275. style={{ height: "100%" }}
  276. flex={1}
  277. >
  278. 在线客服
  279. <Image
  280. src={require("@/assets/icon_mine_service.png")}
  281. className="mine-menu-icon"
  282. />
  283. </Flex>
  284. </Button>
  285. </Flex>
  286. </Flex> */}
  287. <SizeBox height={16} />
  288. {/* <Cell
  289. size="large"
  290. onClick={() => {
  291. RouteUtil.push("/pages/user/aggrement/index");
  292. }}
  293. icon={
  294. <Image
  295. src={require("@/assets/icon_mine_aggrement.png")}
  296. className="mine-item-icon"
  297. />
  298. }
  299. title="用户协议"
  300. rightIcon={<Arrow />}
  301. ></Cell>
  302. <SizeBox height={8} /> */}
  303. {/* <Cell size="large" icon={<Image src={require('@/assets/icon_mine_upgrade.png')} className="mine-item-icon" />} title="检查更新" rightIcon={<Arrow />} ></Cell>
  304. <SizeBox height={8} /> */}
  305. {/* <Cell
  306. onClick={() => {
  307. RouteUtil.push("/pages/user/setting/index");
  308. }}
  309. size="large"
  310. icon={
  311. <Image
  312. src={require("@/assets/icon_mine_setting.png")}
  313. className="mine-item-icon"
  314. />
  315. }
  316. title="设置"
  317. rightIcon={<Arrow />}
  318. ></Cell> */}
  319. <LoginBox ref={childRef}></LoginBox>
  320. </Layout>
  321. );
  322. };
  323. export default Mine;