index.jsx 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import { useEffect, useState } from "react"
  2. import { Map, View, Image, Text } from "@tarojs/components"
  3. import CustomNav from "@/components/CustomNav"
  4. import ButtontWX from "@/components/ButtontWX"
  5. import withLayout from '@/layouts'
  6. import Taro from "@tarojs/taro"
  7. import locationImage from "@/assets/icons/comm/locationImage.png"
  8. import addresss from '@/assets/mineImgaes/addresss.png'//地址
  9. import { getMachineryInfo } from "@/services/homes"
  10. import { useModel } from "@/store"
  11. import { setMorKm } from "@/utils/codeSegment"
  12. import './style.less'
  13. export default withLayout((props) => {
  14. const $instance = Taro.getCurrentInstance()
  15. const { id, location } = $instance.router.params
  16. const { sserLocation } = useModel('userData')
  17. const LocationMap = sserLocation.split(",")
  18. const [carsInfo, setCarsInfo] = useState({})
  19. const [imagesList, setImagesList] = useState([])
  20. const [contentList, setContentList] = useState([])
  21. useEffect(() => {
  22. if (id) {
  23. getMachineryInfo(id, { location: sserLocation, attached: true }).then((e) => {
  24. setImagesList(e.imagesList)
  25. setContentList(e.contentList)
  26. setCarsInfo(e)
  27. })
  28. }
  29. }, [$instance.router.params, id, sserLocation])
  30. const startReserve = () => {
  31. Taro.navigateTo({ url: `/pages/OrderConfirmation/index?id=${id}&location=${location}` })
  32. }
  33. const markers = [{ // 绘制浮标,传入JSON支持多个
  34. iconPath: locationImage,
  35. id: 1,
  36. // longitude: LocationMap[0] ,// 经度
  37. // latitude: LocationMap[1] ,//纬度
  38. longitude: 112.095318,
  39. latitude: 32.695301,
  40. top: 10,
  41. width: 40, // 浮标宽度
  42. height: 37,// 浮标高度
  43. }]
  44. console.log("🚀 ~ file: index.jsx ~ line 46 ~ markers", markers)
  45. return (
  46. <View className='page-index'>
  47. <View className='index-navbar'>
  48. <CustomNav title='查看地图' />
  49. </View>
  50. <scroll-view scrollY style='height: 100%;' >
  51. <View className='MapBox-centent'>
  52. <Map
  53. id='map'
  54. longitude={112.092169}
  55. latitude={32.694883}
  56. scale='12'
  57. markers={markers}
  58. bindmarkertap='markertap'
  59. style='width:100%;height:35vh;'
  60. >
  61. </Map>
  62. <View className='MapBox-centent-BodyArticle'>
  63. <Image style={{ width: '100%', borderRadius: '20px 20px 0px 0px' }} src={carsInfo.thumb} />
  64. <View className='CarsContent-TextBox'>
  65. <View className='CheckDetails-bottom-box-flaxBox-liftText'>
  66. <View className='CheckDetails-bottom-box-flaxBox-liftText-Titles'>{carsInfo.name}</View>
  67. <View className='CheckDetails-bottom-box-flaxBox-liftText-price'>{(carsInfo.price / 100).toFixed(2)}/<Text>亩</Text></View>
  68. </View>
  69. <View className='content-header-box-map-Info'>
  70. <View className='content-header-box-map-Info-liftCentent'>
  71. <Image src={addresss} />
  72. <View>距离当前位置{setMorKm(carsInfo.distance)}&gt;&gt;</View>
  73. </View>
  74. </View>
  75. <View className='content-header-box-map-Info-carsName'>{carsInfo.orgName}</View>
  76. <View className='startReserve-centent'>
  77. {/* <View className='articleTitle-box-Details'>
  78. <Image src={decorate} />
  79. <View>作业详情</View>
  80. <Image src={decorate} />
  81. </View> */}
  82. <View className='startReserve-Bottom'>
  83. <ButtontWX butText='预约' onClick={startReserve} butWidth={300} butHeight={49} butFontSize={16} butBorderRadius={49} />
  84. </View>
  85. </View>
  86. </View>
  87. </View>
  88. </View>
  89. </scroll-view>
  90. </View>
  91. )
  92. })