index.jsx 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. import React, { useState, useEffect } from "react";
  2. import withLayout from "@/layout";
  3. import "./index.scss";
  4. import { useSelector } from "react-redux";
  5. import { ScrollView, Image } from "@tarojs/components";
  6. import "@/assets/css/iconfont.css";
  7. import Taro from "@tarojs/taro";
  8. import { fetch } from "@/utils/request";
  9. import { queryPolicyTypeList, queryPolicyList } from "@/services/policy";
  10. const EncyItem = (props) => {
  11. const city = useSelector(state => state.city)
  12. const { item, index } = props;
  13. const [list, setList] = useState([]);
  14. useEffect(() => {
  15. if (item.policyTypeId) {
  16. getPolicyListByType(item.policyTypeId);
  17. }
  18. }, [item,city]);
  19. const getPolicyListByType = policyTypeId => {
  20. queryPolicyList({ pageSize: 100,policyTypeId,cityId: city?.curCity?.id }).then((res) => {
  21. setList(res.records);
  22. });
  23. };
  24. return (
  25. <view key={`ListItem-${index}`}>
  26. <view className="Title">
  27. <text>{index + 1 > 9 ? index + 1 : `0${index + 1}`}</text>
  28. <text>/{item.policyTypeName}</text>
  29. {/* <Image mode="heightFix" src={item.icon}></Image> */}
  30. </view>
  31. <view className="List">
  32. {list.map((subItem, subIndex) => (
  33. <view
  34. key={`subItem-${subIndex}`}
  35. onClick={() => {
  36. Taro.navigateTo({
  37. url: `/pages/index/encyDetail/index?id=${subItem.policyId}`,
  38. });
  39. }}
  40. >
  41. <text className="Name">{subItem.title}</text>
  42. {subItem.isHot === 1 && (
  43. <text className="Tips" style={{ background: "#FF0000" }}>
  44. {/* {subItem.tips} */}
  45. HOT
  46. </text>
  47. )}
  48. {/* {subItem.icon !== "" && (
  49. <Image mode="heightFix" src={subItem.icon}></Image>
  50. )} */}
  51. </view>
  52. ))}
  53. </view>
  54. </view>
  55. );
  56. };
  57. export default withLayout((props) => {
  58. // const [PageProps] = useState(props)
  59. const [PageList, setPageList] = useState([
  60. {
  61. name: "准备买房",
  62. icon: require("@/assets/ency-icon3.png"),
  63. list: [
  64. {
  65. name: "买房资质查询",
  66. id: 1,
  67. tips: "HOT",
  68. tipsColor: "#FF0000",
  69. icon: "",
  70. },
  71. {
  72. name: "22个房产名词",
  73. id: 2,
  74. tips: "NEW",
  75. tipsColor: "#30CFCF",
  76. icon: "",
  77. },
  78. ],
  79. },
  80. {
  81. name: "看房选房",
  82. icon: require("@/assets/ency-icon4.png"),
  83. list: [
  84. { name: "热门楼盘地图", id: 3, tips: "", icon: "" },
  85. {
  86. name: "选户型攻略",
  87. id: 4,
  88. tips: "实用",
  89. tipsColor: "#62D547",
  90. icon: "",
  91. },
  92. { name: "期房新房怎么选", id: 5, tips: "", icon: "" },
  93. ],
  94. },
  95. {
  96. name: "认筹签约",
  97. icon: require("@/assets/ency-icon5.png"),
  98. list: [
  99. {
  100. name: "买房签约流程",
  101. id: 6,
  102. tips: "哇!",
  103. tipsColor: "#FF396C",
  104. icon: require("@/assets/ency-icon2.png"),
  105. },
  106. { name: "契税征收标准", id: 7, tips: "", icon: "" },
  107. { name: "公司名义买房", id: 8, tips: "", icon: "" },
  108. ],
  109. },
  110. {
  111. name: "贷款买房",
  112. icon: require("@/assets/ency-icon6.png"),
  113. list: [
  114. { name: "新房贷政策", id: 9, tips: "", icon: "" },
  115. {
  116. name: "贷款查征信",
  117. id: 10,
  118. tips: "",
  119. icon: require("../../../assets/ency-icon1.png"),
  120. },
  121. ],
  122. },
  123. ]);
  124. const getPageList = () => {
  125. queryPolicyTypeList({ pageSize: 100 }).then((res) => {
  126. setPageList(res.records);
  127. });
  128. };
  129. // GET /api/{plat}/taPolicyType
  130. useEffect(() => {
  131. getPageList();
  132. }, []);
  133. return (
  134. <view className="Page encyclopediasOfBuyHouse">
  135. <ScrollView
  136. scroll-y={true}
  137. refresher-enabled={false}
  138. refresher-background="#fff"
  139. >
  140. <view className="PageContent">
  141. {PageList.map((item, index) => (
  142. <EncyItem item={item} key={index} index={index}></EncyItem>
  143. ))}
  144. </view>
  145. </ScrollView>
  146. </view>
  147. );
  148. });