ContactUs.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. 'use client'
  2. import React, {useEffect} from 'react';
  3. import SubTitle from "@/components/subTitle";
  4. import {BDMapGL} from "@/utils/BDMap";
  5. import Image from "next/image";
  6. function ContactUs({basicInfo, locationInfoList}: { basicInfo: BasicInfo, locationInfoList: LocationInfo[] }) {
  7. const BASE_URL: string = process.env.NEXT_PUBLIC_BASE_URL as string;
  8. const BDMapInit = () => {
  9. BDMapGL('94KOPB1NRjoXmLvlJN6HMi7eVC50z09K').then((BMapGL: any) => {
  10. const map = new BMapGL.Map('container')
  11. locationInfoList.forEach(point => {
  12. const bmapPoint = new BMapGL.Point(point.longitude, point.latitude);
  13. const marker = new BMapGL.Marker(bmapPoint);
  14. // 创建信息窗口(内容可自定义 HTML)
  15. const infoWindow = new BMapGL.InfoWindow(`
  16. <div>
  17. <h4>姓名:${point.name}</h4>
  18. <p style="margin: 5px 0 0; color: #666;">区域:${point.marker}</p>
  19. <p style="margin: 5px 0 10px; color: #666;">联系方式:${point.phone}</p>
  20. </div>
  21. `);
  22. // 绑定点击事件:点击标记点显示信息窗口
  23. marker.addEventListener("click", () => {
  24. map.openInfoWindow(infoWindow, bmapPoint); // 在点位坐标处打开窗口
  25. });
  26. map.centerAndZoom(bmapPoint, 7)
  27. map.enableScrollWheelZoom(true) //设置鼠标放大缩小
  28. map.addControl(new BMapGL.ScaleControl()) //卡尺
  29. map.addOverlay(marker)
  30. });
  31. })
  32. }
  33. const qrCodeUrl = BASE_URL + basicInfo.qrCodeUrl
  34. useEffect(() => {
  35. BDMapInit()
  36. }, []);
  37. return (
  38. <>
  39. {/* 联系我们 */}
  40. <section id="section-4" className="scroll-mt-10 py-12 px-4">
  41. <div className="w-4/5 mx-auto my-10 sm:my-6">
  42. <SubTitle title="联系我们"/>
  43. </div>
  44. <div className="w-full sm:w-[80%] mx-auto">
  45. <Image
  46. src="/assets/about/25.jpg"
  47. alt="contact"
  48. width={1000}
  49. height={1000}
  50. className="w-full h-auto block sm:hidden"
  51. unoptimized
  52. />
  53. <Image
  54. src="/assets/about/24.jpg"
  55. alt="contact"
  56. width={1000}
  57. height={1000}
  58. className="w-full h-auto hidden sm:block"
  59. unoptimized
  60. />
  61. </div>
  62. {/* <div className="grid sm:grid-cols-1 md:grid-cols-2 gap-6">
  63. <div className="h-88" id="container"></div>
  64. <div className="space-y-4">
  65. <div className="bg-gray-300 w-60 h-60">
  66. <Image src={qrCodeUrl} alt={'qrcode'} width={500} height={500}/>
  67. </div>
  68. <p>电话:{basicInfo.telephone}</p>
  69. <p>邮箱:{basicInfo.email}</p>
  70. <p>地址:{basicInfo.address}</p>
  71. </div>
  72. </div> */}
  73. </section>
  74. </>
  75. );
  76. }
  77. export default ContactUs;