index.jsx 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import { useEffect, useMemo, useState } from 'react'
  2. import { Map, CoverView } from '@tarojs/components'
  3. import '@/assets/css/iconfont.css'
  4. import './index.scss'
  5. const poiTypes = [
  6. { label: '交通', value: 'Transport', class: 'iconfont icon-jiaotong' },
  7. { label: '商业', value: 'Mall', class: 'iconfont icon-shangye' },
  8. { label: '学校', value: 'Edu', class: 'iconfont icon-xuexiao' },
  9. { label: '医院', value: 'Hospital', class: 'iconfont icon-yiyuan' },
  10. { label: '银行', value: 'Bank', class: 'iconfont icon-yinhang' },
  11. { label: '餐饮', value: 'Restaurant', class: 'iconfont icon-canyin' },
  12. ]
  13. export default function Periphery (props) {
  14. const { Info } = props
  15. const [pois, setPois] = useState([])
  16. const [markers, setMarkers] = useState([])
  17. const loc = useMemo(() => (Info?.coordinate ? Info.coordinate.split(',') : []), [Info?.coordinate])
  18. const CutTab = () => {
  19. return () => {
  20. }
  21. }
  22. useEffect(() => {
  23. if (!Info?.coordinate) {
  24. setMarkers([])
  25. return;
  26. }
  27. const mks = []
  28. // 项目位置
  29. mks.push({
  30. id: -1,
  31. longitude: loc[0],
  32. latitude: loc[1],
  33. iconPath: '',
  34. width: 24,
  35. height: 36,
  36. customCallout: {
  37. anchorY: 0,
  38. anchorX: 0,
  39. display: 'ALWAYS',
  40. }
  41. })
  42. setMarkers(mks)
  43. }, [Info, loc])
  44. return (
  45. <view className='components Periphery'>
  46. <view className='Title flex-h'>
  47. <view className='flex-item'>
  48. <text>位置及周边配套</text>
  49. </view>
  50. </view>
  51. <view className='Map'>
  52. <view>
  53. <Map
  54. id='poi-around'
  55. show-location
  56. scale={12}
  57. markers={markers}
  58. longitude={loc[0]}
  59. latitude={loc[1]}
  60. // enable-enableScroll
  61. // enable-zoom
  62. >
  63. <CoverView slot='callout' className='marker-callout'>
  64. <CoverView markerId={-1} className='marker-project'>{Info.buildingName}</CoverView>
  65. </CoverView>
  66. </Map>
  67. </view>
  68. </view>
  69. <view className='List flex-h'>
  70. {
  71. poiTypes.map((item) => (
  72. <view className='flex-item' key={item.value} onClick={CutTab(item.value)}>
  73. <text className={item.class}></text>
  74. <text>{item.label}(123)</text>
  75. </view>
  76. ))
  77. }
  78. </view>
  79. </view>
  80. )
  81. }