index.tsx 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. import "./index.scss";
  2. import UserApi from "@/apis/userApi";
  3. import Button from "@/component/button";
  4. import Flex from "@/component/flex";
  5. import Label from "@/component/label";
  6. import Layout from "@/component/layout";
  7. import Padding, { EdgeInsets } from "@/component/padding";
  8. import SizeBox from "@/component/sizeBox";
  9. import APPConfig from "@/config";
  10. import AppContext from "@/context/appContext";
  11. import UserHelper from "@/helper/userHelper";
  12. import ImageUtil from "@/utils/imgUtils";
  13. import RequestUtil from "@/utils/request";
  14. import RouteUtil from "@/utils/routeUtil";
  15. import { Image, ScrollView, View, Text, Input } from "@tarojs/components";
  16. import { parseQueryParams, isOuterLink } from "@/utils/toolsUtil";
  17. import Taro, { pxTransform } from "@tarojs/taro";
  18. import { useRequest } from "ahooks";
  19. import React, { useContext, useMemo, useState , useEffect ,useRef } from "react";
  20. import LoginBox from "../user/components/LoginBox";
  21. const Home = () => {
  22. const childRef:any = useRef()
  23. const handleOpen = () => {
  24. childRef.current.handleOpen()
  25. }
  26. const appContext = useContext(AppContext);
  27. const { screenWidth, statusBarHeight } = appContext.systemInfo!;
  28. const [bottomRemark, setBottomRemark] = useState('')
  29. const isUserLogin = UserHelper.isLogin()
  30. const indexInfoResult = useRequest(() => {
  31. return UserApi.getIndexInfoUsingPost({
  32. params: { appId: APPConfig.APPID },
  33. }).toData();
  34. });
  35. const channelResult = useRequest(() => {
  36. return UserApi.homeFetchChannel({
  37. data: { channelCode: 'hrqbxcx', refer: '' },
  38. }).toData().then(res => {
  39. setBottomRemark(res.bottom_remark)
  40. })
  41. });
  42. const postJumpUrlResult = () => {
  43. const params = parseQueryParams(indexInfoResult.data.link)
  44. return UserApi.getJumpUrlPost({
  45. loading: true,
  46. data: { appId: APPConfig.APPID, channelCode: params.channelCode, productId: params.productId }
  47. }).toData().then(res => {
  48. console.log("获取跳转链接结果", res)
  49. RouteUtil.toWebViewPage({ url: res?.adJumpLink })
  50. })
  51. }
  52. const loginFlowHandler = async () => {
  53. await UserHelper.UpdateOpenId()
  54. if (isOuterLink(indexInfoResult.data.link)) {
  55. await postJumpUrlResult()
  56. } else {
  57. await RouteUtil.toWebViewPage({ url: indexInfoResult.data.link })
  58. }
  59. }
  60. const imgBackStyle = useMemo(() => {
  61. return {
  62. ...ImageUtil.calculationHeight(332 / 170, (screenWidth - 64 + 16) / 2),
  63. position: "relative",
  64. } as React.CSSProperties;
  65. }, []);
  66. const item = (index: number, title: string, desc: string) => {
  67. return (
  68. <View style={imgBackStyle}>
  69. <Image
  70. className='background-image'
  71. src={require(`../../assets/icon_home_characteristic_b_${index}.png`)}
  72. />
  73. <Flex
  74. rowGap='sm'
  75. className='background-content background-content-wrap'
  76. >
  77. <Flex columnGap='sm' direction='row' alignItem='center'>
  78. <Image
  79. className='background-content-i'
  80. src={require(`../../assets/icon_home_characteristic_i_${index}.png`)}
  81. />
  82. <Label bold>{title}</Label>
  83. </Flex>
  84. <Label style={{ fontSize: pxTransform(22) }} type='secondary'>
  85. {desc}
  86. </Label>
  87. </Flex>
  88. </View>
  89. );
  90. };
  91. const BottomRemark = () => bottomRemark.split(';').map(text => <View style={{ margin: '4px 0' }}>{text}</View>)
  92. const ApplyButton = ({ isLogin }) => {
  93. return (
  94. <>
  95. {
  96. isLogin ? (<Button className='index-back-btn' onClick={() => {
  97. UserHelper.afterLogin({
  98. pop: false,
  99. callback: async () => {
  100. indexInfoResult.data && loginFlowHandler()
  101. // indexInfoResult.data && postJumpUrlResult()
  102. // RouteUtil.toWebViewPage({
  103. // url: indexInfoResult.data.link,
  104. // });
  105. },
  106. });
  107. }}
  108. >立即申请额度</Button>) : (<Button onClick={handleOpen} fill
  109. className='index-back-btn'
  110. >立即申请</Button>)
  111. }
  112. </>
  113. )
  114. }
  115. return (
  116. <Layout safe className='index' bottomBarIndex={0}>
  117. <ScrollView className='index-container'>
  118. <SizeBox height={statusBarHeight} />
  119. <SizeBox height={60} />
  120. {/* <Image
  121. className='index-logo'
  122. src={require("../../assets/new-edition/index-logo.png")}
  123. /> */}
  124. <Padding padding={EdgeInsets.symmetric({ horizontal: 32 })}>
  125. <View
  126. style={{
  127. ...ImageUtil.calculationHeight(
  128. 686 / 484,
  129. appContext.systemInfo!.screenWidth - 32
  130. ),
  131. position: "relative",
  132. }}
  133. className='index-panel'
  134. >
  135. <Flex
  136. alignItem='center'
  137. justifyContent='center'
  138. // rowGap={24}
  139. className='index-back-content'
  140. >
  141. <Label className='index-back-se'>最高可申请(元)</Label>
  142. <Label className='index-back-amount'>200,000.00</Label>
  143. <View className='index-back-tip'>具体额度以资金方审批为准</View>
  144. <Flex
  145. alignItem='center'
  146. justifyContent='center'
  147. direction='row'
  148. className='index-back-info'
  149. columnGap={12}
  150. >
  151. <Text>年化利率7.2-24%(单利)</Text>
  152. <View className='split-char'></View>
  153. <Text>期限3-36个月</Text>
  154. </Flex>
  155. <View className='index-back-btn-container'>
  156. <View className='index-back-btn-tip'>
  157. 现在申请,快速评估需求
  158. </View>
  159. <ApplyButton isLogin={isUserLogin}></ApplyButton>
  160. {/* <Button
  161. onClick={() => {
  162. UserHelper.afterLogin({
  163. pop: false,
  164. callback: async () => {
  165. indexInfoResult.data &&
  166. RouteUtil.toWebViewPage({
  167. url: indexInfoResult.data.link,
  168. });
  169. },
  170. });
  171. }}
  172. className='index-back-btn'
  173. >
  174. 立即申请额度
  175. </Button> */}
  176. </View>
  177. </Flex>
  178. </View>
  179. <View className='index-step-container'>
  180. <View className='background'></View>
  181. <Flex
  182. alignItem='center'
  183. justifyContent='center'
  184. direction='row'
  185. columnGap={8}
  186. >
  187. <Text>01.提交申请</Text>
  188. <Image
  189. style={{ width: "24px", height: "24px" }}
  190. src={require("../../assets/new-edition/icon-next.svg")}
  191. />
  192. <Text>02.需求评估</Text>
  193. <Image
  194. style={{ width: "24px", height: "24px" }}
  195. src={require("../../assets/new-edition/icon-next.svg")}
  196. />
  197. <Text>03.签约办理</Text>
  198. </Flex>
  199. </View>
  200. </Padding>
  201. <SizeBox height={24} />
  202. {/* <Padding padding={EdgeInsets.symmetric({ vertical: 68 })}>
  203. <Flex alignItem="center" justifyContent="center">
  204. <Image
  205. src={require("@/assets/icon_home_characteristic.png")}
  206. className="index-iocn-title"
  207. />
  208. </Flex>
  209. </Padding> */}
  210. {/* <Flex rowGap="sm" style={{ padding: "0 16PX" }}>
  211. <Flex direction="row">
  212. {item(0, "产品丰富", "信用、抵押、质押均可")}
  213. <SizeBox width={16} />
  214. {item(1, "快速便捷", "最快10分钟出结果")}
  215. </Flex>
  216. <Flex direction="row">
  217. {item(2, "场景多元", "可用于消费、经营等")}
  218. <SizeBox width={16} />
  219. {item(3, "信息保密", "严格保护申请人信息")}
  220. </Flex>
  221. </Flex> */}
  222. <Padding padding={EdgeInsets.symmetric({ horizontal: 32 })}>
  223. <Image
  224. src={require("../../assets/new-edition/platform.png")}
  225. className='index-platform-image'
  226. />
  227. </Padding>
  228. <Flex
  229. justifyContent='center'
  230. alignItem='center'
  231. rowGap={24}
  232. className='index-bottom-tip'
  233. >
  234. <View>
  235. <BottomRemark />
  236. {/* { bottomRemark } */}
  237. {/* 郑重声明:平台只提供贷款咨询和推荐服务,放款由银行或金融机构进行,贷款额度、放款时间以资金分审批结果为准,所有贷款申请在未成功贷款前绝不收取任何费用,为了保证您的资金安全,请不要相信任何要求您支付费用的信息、邮件、电话等不实信息。 */}
  238. </View>
  239. <View>如遇问题请向{ channelResult.data?.customerServiceInfo || '400-003-9350'}举报投诉,平台将及时为您解决!</View>
  240. </Flex>
  241. </ScrollView>
  242. <LoginBox ref={childRef}></LoginBox>
  243. </Layout>
  244. );
  245. };
  246. export default Home;