董国庆
2026-07-14 11fa99f45663fc39cda7918aa97e134c8e337de7
修改
6个文件已修改
1117 ■■■■■ 已修改文件
FreeRidePackage/pages/pushTrip/pushTrip.wxml 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/advoad-city-search/advoad-message/advoad-message.js 221 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/advoad-city-search/advoad-message/advoad-message.wxml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/advoad-city-search/advoad-message/electronic-fence/electronic-fence.js 839 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/advoad-city-search/advoad-success/advoad-success.js 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/advoad-city-search/advoad-success/advoad-success.wxml 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
FreeRidePackage/pages/pushTrip/pushTrip.wxml
@@ -23,7 +23,7 @@
        </view>
    </view>
    <view class="call-proxy" wx:if="{{type==1}}">
        是否需要代叫
        是否代他人叫车
        <radio-group class="XQ-radio" bindchange='checkedTap'>
            <view class="radio-Car-XQ" wx:for="{{radio}}" wx:key="index">
                <radio checked="{{item.check}}" value="{{item.id}}" data-name="{{item.name}}" color="#F07207" class="radio-1" />
@@ -31,9 +31,9 @@
            </view>
        </radio-group>
    </view>
    <view class="van-cell" wx:if="{{IsProxy==1}}" style="background: #fff;margin-top: 20rpx;">
    <view class="van-cell" wx:if="{{type==1 && IsProxy==1}}" style="background: #fff;margin-top: 20rpx;">
        <image src="../../../img/phone@2x.png" class="phone-icons" mode="aspectFill" />
        <input bindinput="phone" value="{{phone}}" maxlength="20" placeholder-class="input-class" placeholder="乘车人手机号" type="text" />
        <input bindinput="phone" value="{{phone}}" maxlength="20" placeholder-class="input-class" placeholder="请输入联系电话" type="text" />
    </view>
    <view class="pass-order" catchtap="goPush">{{type==1?'立即发布':'确认发布'}}</view>
</view>
@@ -80,4 +80,4 @@
            <view class="close_y" catchtap="yes">确认取消</view>
        </view>
    </view>
</view>
</view>
pages/advoad-city-search/advoad-message/advoad-message.js
@@ -1,6 +1,7 @@
// pages/advoad-city-search/advoad-message/advoad-message.js
const app = getApp()
var WxParse  = require("../../../utils/wxParse/wxParse")
const GdMap = require('../../../utils/amap-wx')
const {
  queryLocation,
@@ -8,8 +9,11 @@
  orderCrossCity,
  queryBalance,
  queryByType,
  isElectronicLedger
  isElectronicLedger,
  areaMonitoringexport
} = require('../../../utils/ajax')
const ADVOAD_START_LOCATION_STORAGE_KEY = 'advoadStartSelectedLocation'
const ADVOAD_END_LOCATION_STORAGE_KEY = 'advoadEndSelectedLocation'
Page({
  /**
@@ -47,7 +51,157 @@
    canOrder:true,//禁止下单
    wxParse:false,//乘车须知
    isAllIn:false,//是否包车 显示选择座位
    peopleArr:0
    canChooseSeat:true,//是否展示选座
    peopleArr:0,
    lineDestinationId:'',
    skipStartLocationCacheSync:false
  },
  getAvailablePeopleCount(data = this.data){
    const self = data.self || {}
    const numberText = String(self.number || '')
    const [usedSeatText, totalSeatText] = numberText.split('/')
    const usedSeat = Number(usedSeatText || 0)
    const totalSeat = Number(totalSeatText || 0)
    const availableSeat = totalSeat - usedSeat
    return availableSeat > 0 ? availableSeat : 0
  },
  getEffectivePeopleId(data = this.data){
    if(Number(data.radioVlaue) == 2){
      return this.getAvailablePeopleCount(data)
    }
    return data.peopleId
  },
  isSeatSelectionRequired(data = this.data){
    return data.radioVlaue != 2 && data.canChooseSeat
  },
  getStoredRouteLocation(where){
    const storageKey = where == 'startLocation'
      ? ADVOAD_START_LOCATION_STORAGE_KEY
      : ADVOAD_END_LOCATION_STORAGE_KEY
    return wx.getStorageSync(storageKey)
  },
  getCurrentLocationDetail(){
    return new Promise(async (resolve) => {
      try{
        const locationRes = await new Promise((locationResolve, locationReject) => {
          wx.getLocation({
            type: 'gcj02',
            success: locationResolve,
            fail: locationReject
          })
        })
        const latitude = locationRes.latitude
        const longitude = locationRes.longitude
        const myAmapFun = new GdMap.AMapWX({
          key: 'cea7923a93987b959ab1d2f8ab44d497'
        })
        const regeoRes = await new Promise((regeoResolve, regeoReject) => {
          myAmapFun.getRegeo({
            location: `${longitude},${latitude}`,
            success: regeoResolve,
            fail: regeoReject
          })
        })
        const item = regeoRes && regeoRes[0]
        const regeocodeData = item && item.regeocodeData
        const addressComponent = (regeocodeData && regeocodeData.addressComponent) || {}
        const pois = (regeocodeData && regeocodeData.pois) || []
        const landmarkName = (item && item.name) || (pois[0] && pois[0].name) || '当前位置'
        const formattedAddress = (regeocodeData && regeocodeData.formatted_address) || landmarkName
        const adcode = addressComponent.adcode || wx.getStorageSync('adcode') || ''
        const userLocation = `${longitude},${latitude}`
        wx.setStorageSync('latitude', latitude)
        wx.setStorageSync('longitude', longitude)
        wx.setStorageSync('adcode', adcode)
        wx.setStorageSync('formatted_address', formattedAddress)
        wx.setStorageSync('userLocation', userLocation)
        resolve({
          latitude,
          longitude,
          adcode,
          landmarkName,
          formattedAddress,
          location: userLocation
        })
      }catch(error){
        resolve(null)
      }
    })
  },
  async tryAutoFillCurrentStartLocation(){
    const self = this.data.self || {}
    if(!self.abovadStartId){
      return
    }
    if(
      this.data.startLocation != '请选择上车点' &&
      Object.keys(this.data.startInfo || {}).length !== 0
    ){
      return
    }
    const currentLocation = await this.getCurrentLocationDetail()
    if(!currentLocation || !currentLocation.adcode){
      return
    }
    try{
      const res = await areaMonitoringexport(
        currentLocation.adcode,
        currentLocation.location,
        self.abovadStartId
      )
      const data = res.data || {}
      if(data.code == 200 && data.data == 1){
        this.setData({
          startLocation: currentLocation.formattedAddress || currentLocation.landmarkName || '当前位置',
          startInfo: {
            startLat: currentLocation.latitude,
            startLon: currentLocation.longitude
          }
        },()=>{
          this.queryOrderMoney()
        })
      }
    }catch(error){
    }
  },
  syncStoredRouteLocation(options = {}){
    const {
      syncStart = true,
      syncEnd = true
    } = options
    let self = this.data.self || {}
    if(Object.keys(self).length === 0){
      return
    }
    let updates = {}
    let startLocationCache = this.getStoredRouteLocation('startLocation')
    let endLocationCache = this.getStoredRouteLocation('endLocation')
    if(
      syncStart &&
      startLocationCache &&
      String(startLocationCache.siteId) == String(self.abovadStartId) &&
      startLocationCache.locationName &&
      startLocationCache.locationInfo
    ){
      updates.startLocation = startLocationCache.locationName
      updates.startInfo = startLocationCache.locationInfo
    }
    if(
      syncEnd &&
      endLocationCache &&
      String(endLocationCache.siteId) == String(self.abovadEndId) &&
      endLocationCache.locationName &&
      endLocationCache.locationInfo
    ){
      updates.endLocation = endLocationCache.locationName
      updates.endInfo = endLocationCache.locationInfo
      updates.lineDestinationId = endLocationCache.lineDestinationId || ''
    }
    if(Object.keys(updates).length > 0){
      this.setData(updates,()=>{
        this.queryOrderMoney()
      })
    }
  },
  closePop(){
    this.setData({
@@ -60,11 +214,12 @@
     if(radioVlaue == 2){
        this.setData({
          isAllIn:true,
          zwNum:"请选择座位",
          zwNum:this.data.canChooseSeat ? "请选择座位" : "",
        })
     }else{
        this.setData({
          isAllIn:false
          isAllIn:false,
          zwNum:this.data.canChooseSeat ? "请选择座位" : ""
        })
     }
     this.setData({
@@ -94,7 +249,7 @@
    this.setData({
      peopleNum:peopleId+'人',
      peopleId,
      zwNum:'请选择座位',
      zwNum:this.data.canChooseSeat ? '请选择座位' : '',
    },()=>{
      this.queryOrderMoney()
    })
@@ -103,7 +258,7 @@
  zwNum(){
    let self  = this.data.self
    let data = this.data
    if(data.peopleNum=='请选择出行人数'){
    if(Number(data.radioVlaue) != 2 && data.peopleNum=='请选择出行人数'){
     app.showToastSuccess('请先选择出行人数',null,'none',1500)
     return false
    }
@@ -199,9 +354,11 @@
  async orderCrossCityAjax (){
    let dataSelf = this.data.self
    let data = this.data
    let peopleId = this.getEffectivePeopleId(data)
    console.log('数据',this.data);
    let userLocation = wx.getStorageSync('userLocation')
    let zwNumLength =    data.zwNum.split(',').length
    let needChooseSeat = this.isSeatSelectionRequired(data)
    let zwNumLength = needChooseSeat && data.zwNum ? data.zwNum.split(',').length : 0
    let mask = '' 
      data.maskList.map( x =>{
        if(x.checked){
@@ -209,12 +366,12 @@
          mask+=','+x.name
        } 
      })
      console.log(data.peopleId,zwNumLength)
      if((data.peopleId!==zwNumLength)&& data.radioVlaue!=2){
      console.log(peopleId,zwNumLength)
      if(needChooseSeat && (peopleId!==zwNumLength)){
        app.showToastSuccess('请正确选择座位',null,'none',1500)
        return false
      }
    let seatNumber = data.zwNum == '请选择座位' ? '' : data.zwNum
    let seatNumber = needChooseSeat && data.zwNum != '请选择座位' ? data.zwNum : ''
    let dataInfo = {
      carId : dataSelf.carId,//车辆id
      distance :data.distance ,//行驶里程数
@@ -224,8 +381,9 @@
      endLon :  data.endInfo.startLon,//终点经度
      lineId  : dataSelf.lineSelf.id||dataSelf.lineId,//线路ID
      lineShiftDriverId  : dataSelf.lineShiftDriverId,//排班ID
      lineDestinationId : data.lineDestinationId || '',
      orderSource  : 3,
      peopleNumber  : data.peopleId,//出行人数
      peopleNumber  : peopleId,//出行人数
      placementAddress : wx.getStorageSync('formatted_address'),//下单详细位置
      placementLat  : userLocation.split(',')[1],//下单经纬
      placementLon   : userLocation.split(',')[0],
@@ -268,8 +426,8 @@
      startLocation: data.startLocation,
      endLocation:data.endLocation,
      driveInfo:dataSelf.name + '-' +dataSelf.carLicensePlate,
      zwNum: people||data.zwNum,
      zwPeople : peopleNum||data.peopleId,
      zwNum: people || seatNumber,
      zwPeople : peopleNum||peopleId,
      orderId: res.data.data.id,
      orderType:3,
      couponId:this.data.couponId,
@@ -312,20 +470,24 @@
      abvoadEndLocation
    } = this.data.self
    wx.navigateTo({
      url: `./electronic-fence/electronic-fence?where=endLocation&abovadEndId=${abovadEndId}&abvoadEndLocation=${abvoadEndLocation}`,
      url: `./electronic-fence/electronic-fence?where=endLocation&abovadStartId=${abovadStartId}&abovadEndId=${abovadEndId}&abvoadEndLocation=${abvoadEndLocation}`,
    })
  },
  //获取预估金额
 async queryOrderMoney(){
    let data = this.data
    let peopleId = this.getEffectivePeopleId(data)
    let totalSeat = data.self.number.split('/')[1]
    if((data.zwNum!=='请选择座位'|| data.radioVlaue==2)&&data.startLocation!=='请选择上车点'&&
    let needChooseSeat = this.isSeatSelectionRequired(data)
    let seatReady = !needChooseSeat || data.zwNum !== '请选择座位'
    let seatNumber = needChooseSeat ? data.zwNum : ''
    if(seatReady&&data.startLocation!=='请选择上车点'&&
    data.endLocation!=='请选择下车点'&&
    Object.keys(data.startInfo).length!==0&&
    Object.keys(data.endInfo).length!==0&&
    data.peopleId!==''&&
    peopleId!==''&&
    data.radioVlaue!==''&&
    data.zwNum!==''
    (!needChooseSeat || data.zwNum!=='')
    ){
      this.setData({
        canOrder:false
@@ -336,11 +498,12 @@
        endLonLat ,
        startLonLat ,
        data.self.lineSelf.id||data.self.lineId ,
        data.peopleId ,
        data.zwNum ,
        peopleId ,
        seatNumber ,
        data.self.serverCarModelId ,
        totalSeat ,
        data.radioVlaue
        data.radioVlaue ,
        data.lineDestinationId || ''
      )
      res.data.code == 200
      ?
@@ -372,7 +535,12 @@
       let  self = JSON.parse(options.self)
       console.log(self)
       this.setData({
         self
         self,
         canChooseSeat:self.chooseSeat !== false,
         zwNum:self.chooseSeat === false ? '' : this.data.zwNum,
         skipStartLocationCacheSync:true
       },()=>{
         this.tryAutoFillCurrentStartLocation()
       })
     }
  },
@@ -389,6 +557,15 @@
   */
  onShow: function () {
       console.log(this.data.startInfo,this.data.endInfo)
       this.syncStoredRouteLocation({
        syncStart: !this.data.skipStartLocationCacheSync
       })
       wx.removeStorageSync(ADVOAD_END_LOCATION_STORAGE_KEY)
       if(this.data.skipStartLocationCacheSync){
        this.setData({
          skipStartLocationCacheSync:false
        })
       }
  },
@@ -426,4 +603,4 @@
  onShareAppMessage: function () {
  }
})
})
pages/advoad-city-search/advoad-message/advoad-message.wxml
@@ -15,7 +15,6 @@
            </view>
            <view class="right">
                <view>{{self.brand}} {{self.carColor}}</view>
                <view>可乘人数{{self.number}}</view>
            </view>
        </view>
    </view>
@@ -48,7 +47,7 @@
            </view>
        </view>
        <!--乘客人数-->
        <view class="go-time" catchtap="handelClickPeopleNum">
        <view class="go-time" catchtap="handelClickPeopleNum" wx:if="{{radioVlaue != 2}}">
            <image src="/img/icon_people@2x.png" mode="widthFix"></image>
            <view class="other1 other">
                <view>乘客人数</view>
@@ -74,7 +73,7 @@
            </view>
        </view>
        <!--选择座位-->
        <view class="go-time" catchtap="zwNum" hidden="{{isAllIn}}">
        <view class="go-time" catchtap="zwNum" hidden="{{isAllIn || !canChooseSeat}}">
            <image src="/img/icon_car@2x.png" mode="widthFix"></image>
            <view class="other1 other">
                <view>选择座位</view>
@@ -117,4 +116,4 @@
</view>
<people-num peopleNumBallen="{{peopleNumBallen}}" peopleAjaxInfo="{{peopleAjaxInfo}}" bind:parentEventTip='onParentEvent' style="padding-bottom:{{btuBottom}}rpx"></people-num>
<people7 people7="{{people7}}" peopleAjax="{{peopleAjax}}" bind:parentEventTip7='onParentEvent7' style="padding-bottom:{{btuBottom}}rpx"></people7>
<people5 people5="{{people5}}" peopleAjax="{{peopleAjax}}" bind:parentEventTip5='onParentEvent5' style="padding-bottom:{{btuBottom}}rpx"></people5>
<people5 people5="{{people5}}" peopleAjax="{{peopleAjax}}" bind:parentEventTip5='onParentEvent5' style="padding-bottom:{{btuBottom}}rpx"></people5>
pages/advoad-city-search/advoad-message/electronic-fence/electronic-fence.js
@@ -2,12 +2,15 @@
const app = getApp()
const {
  queryLocation,
  areaMonitoringexport
  areaMonitoringexport,
  queryFirstLineDestinations
} = require('../../../../utils/ajax')
const amapFile = require('../../../../utils/amap-wx')
// 保留百度地图相关代码作为备用
const QQMapWX = require('../../../../utils/qqmap-wx-jssdk')
let qqmapsdk;
const ADVOAD_START_LOCATION_STORAGE_KEY = 'advoadStartSelectedLocation'
const ADVOAD_END_LOCATION_STORAGE_KEY = 'advoadEndSelectedLocation'
Page({
  /**
   * 页面的初始数据
@@ -22,31 +25,30 @@
    isCitys: false,
    addressList: [],
    userId: "",
    startSiteId: "",
    endSiteId: "",
    startLocation: "加载中",
    district: "",
    type:0,
    source: "",
    stationWhere: "",
    locatingCurrent: false,
    hasTriedAutoLocate: false,
    fenceList: []
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: async function (options) {
    let pages = getCurrentPages();
    console.log('qweqweqwe',options);
    let response = await this.handleDistrict(options.abovadEndId || options.abovadStartId);
    this.setData({
      district: response.data.data[0].district,
      type:options.type,
      startLocation:response.data.data[0].city
    },()=>{
        console.log('+++++',this.data);
    })
    if (options) {
      let where = options.where
      this.setData({
        where
        where,
        type:options.type,
        source: options.source || "",
        stationWhere: options.stationWhere || ""
      })
      if (where == 'startLocation') {
        wx.setNavigationBarTitle({
@@ -56,12 +58,26 @@
          options,
          abovadStartId: options.abovadStartId,
          startLocation1: options.abvoadStartLocation,
          userId: options.abovadStartId
          userId: options.abovadStartId,
          startSiteId: options.abovadStartId || "",
          endSiteId: options.abovadEndId || ""
        })
        let response = await this.handleDistrict()
        console.log('/**/*/**/*',response);
        const fenceList = this.getFenceListFromResponse(response)
        console.log('+-89587877',fenceList);
        if(fenceList.length > 0){
          this.setData({
            district: fenceList[0].district,
            startLocation: fenceList[0].city
          },()=>{
            console.log('+++++',this.data);
          })
        }
        let location = wx.getStorageSync('longitude') + ',' + wx.getStorageSync('latitude')
        //获取起点电子围栏
        this.getNearLocation(options.abvoadStartLocation,'',true)
        this.getNearLocation(options.abvoadStartLocation,location,true)
        if(this.data.district){
            this.getNearLocation(this.data.district, location, true)
        }
@@ -73,13 +89,53 @@
          options,
          startLocation1: options.abvoadEndLocation,
          abovadStartId: options.abovadEndId,
          userId: options.abovadEndId
          userId: options.abovadEndId,
          startSiteId: options.abovadStartId || "",
          endSiteId: options.abovadEndId || ""
        })
        let response = await this.handleDistrict()
        console.log('/**/*/**/*',response);
        const fenceList = this.getFenceListFromResponse(response)
        console.log('+-89587877',fenceList);
        if(fenceList.length > 0){
          this.setData({
            district: fenceList[0].district,
            startLocation: fenceList[0].city
          },()=>{
            console.log('+++++',this.data);
          })
        }
        let location = wx.getStorageSync('longitude') + ',' + wx.getStorageSync('latitude')
        const userLongitude = wx.getStorageSync('longitude')
        const userLatitude = wx.getStorageSync('latitude')
        let location = userLongitude + ',' + userLatitude
        const normalizedFenceList = fenceList.map((item) => this.normalizeFenceItem(item))
        const currentInFence = userLongitude && userLatitude
          ? normalizedFenceList.some((item) => {
            const parsedFence = this.parseFenceCoordinate(item)
            if(!parsedFence){
              return false
            }
            if(parsedFence.mode == 'circle'){
              const distance = this.getDistanceMeters(
                Number(userLatitude),
                Number(userLongitude),
                parsedFence.centerLatitude,
                parsedFence.centerLongitude
              )
              return distance <= Number(parsedFence.radius || 0)
            }
            return parsedFence.points && parsedFence.points.length >= 3
              ? this.isPointInPolygon(Number(userLatitude), Number(userLongitude), parsedFence.points)
              : false
          })
          : false
        if(!currentInFence){
          location = this.getMainFenceLocation(normalizedFenceList) || location
        }
        //获取起点电子围栏
        this.getNearLocation(options.abvoadEndLocation,'',true)
        this.getNearLocation(options.abvoadEndLocation,location,true)
        if(this.data.district){
            this.getNearLocation(this.data.district, location, true)
        }
@@ -87,6 +143,494 @@
    }
    //设置当前位置经纬度
  },
  createMarker(latitude, longitude){
    return [{
      id: 1,
      latitude,
      longitude,
      iconPath: "/img/icon_location.png",
      width: 26,
      height: 35
    }]
  },
  getAmapInstance(){
    return new amapFile.AMapWX({
      key: 'cea7923a93987b959ab1d2f8ab44d497'
    })
  },
  reverseGeocode(latitude, longitude) {
    const myAmapFun = this.getAmapInstance()
    return new Promise((resolve, reject) => {
      myAmapFun.getRegeo({
        location: `${longitude},${latitude}`,
        success: (res) => {
          const regeocodeData = res[0].regeocodeData
          resolve({
            addressComponent: regeocodeData.addressComponent,
            formattedAddress: regeocodeData.formatted_address
          })
        },
        fail: reject
      })
    })
  },
  toRadians(deg){
    return deg * Math.PI / 180
  },
  getDistanceMeters(lat1, lon1, lat2, lon2){
    const earthRadius = 6378137
    const dLat = this.toRadians(lat2 - lat1)
    const dLon = this.toRadians(lon2 - lon1)
    const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
      Math.cos(this.toRadians(lat1)) * Math.cos(this.toRadians(lat2)) *
      Math.sin(dLon / 2) * Math.sin(dLon / 2)
    const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
    return earthRadius * c
  },
  isPointInPolygon(latitude, longitude, points){
    let inside = false
    for (let i = 0, j = points.length - 1; i < points.length; j = i++) {
      const xi = Number(points[i].longitude)
      const yi = Number(points[i].latitude)
      const xj = Number(points[j].longitude)
      const yj = Number(points[j].latitude)
      const intersect = ((yi > latitude) !== (yj > latitude)) &&
        (longitude < (xj - xi) * (latitude - yi) / ((yj - yi) || 0.0000001) + xi)
      if (intersect) {
        inside = !inside
      }
    }
    return inside
  },
  isCurrentLocationInFence(latitude, longitude){
    const circles = this.data.circles || []
    const polygons = this.data.polygons || []
    const inCircle = circles.some((circle) => {
      const distance = this.getDistanceMeters(
        latitude,
        longitude,
        Number(circle.latitude),
        Number(circle.longitude)
      )
      return distance <= Number(circle.radius || 0)
    })
    if(inCircle){
      return true
    }
    return polygons.some((polygon) => {
      return polygon.points && polygon.points.length >= 3
        ? this.isPointInPolygon(latitude, longitude, polygon.points)
        : false
    })
  },
  getLocationStorageKey(where){
    return where == 'startLocation'
      ? ADVOAD_START_LOCATION_STORAGE_KEY
      : ADVOAD_END_LOCATION_STORAGE_KEY
  },
  saveSelectedLocation(where, siteId, siteName, locationName, locationInfo, extraData = {}){
    wx.setStorageSync(this.getLocationStorageKey(where), {
      siteId,
      siteName,
      locationName,
      locationInfo,
      ...extraData
    })
  },
  getDefaultText(currentText, defaultText){
    if(currentText && currentText.indexOf('选择') !== -1 && currentText.indexOf('请') === -1){
      return defaultText.replace('请', '')
    }
    return defaultText
  },
  getNearLocationKeyword(defaultKeyword){
    const options = this.data.options || {}
    if(this.data.where == 'endLocation'){
      return options.abvoadEndLocation || this.data.startLocation1 || defaultKeyword
    }
    if(this.data.where == 'startLocation'){
      return options.abvoadStartLocation || this.data.startLocation1 || defaultKeyword
    }
    return defaultKeyword
  },
  getFenceListFromResponse(response){
    const data = response && response.data && response.data.data
    if(Array.isArray(data)){
      return data
    }
    if(data && typeof data === 'object'){
      if(Array.isArray(data.records)){
        return data.records
      }
      if(Array.isArray(data.list)){
        return data.list
      }
      return [data]
    }
    if(data && Array.isArray(data.records)){
      return data.records
    }
    if(data && Array.isArray(data.list)){
      return data.list
    }
    return []
  },
  normalizeFenceItem(item){
    const fenceInfo = item.fenceInfo || {}
    const coordinate = item.coordinate || fenceInfo.coordinate || ''
    const coordinateList = coordinate.split(';').filter(i => i)
    const firstPoint = coordinateList[0] ? coordinateList[0].split(',') : []
    const isCircleByCoordinate = coordinateList.length == 2 &&
      firstPoint.length == 2 &&
      !Number.isNaN(Number(firstPoint[0])) &&
      !Number.isNaN(Number(firstPoint[1])) &&
      !Number.isNaN(Number(coordinateList[1]))
    const derivedFenceType = isCircleByCoordinate
      ? 1
      : (coordinateList.length >= 3 ? 2 : Number(item.fenceType || fenceInfo.fenceType || item.type || 0))
    const derivedDefaultPointLon = Number(item.defaultPointLon || fenceInfo.defaultPointLon || (firstPoint[0] || 0))
    const derivedDefaultPointLat = Number(item.defaultPointLat || fenceInfo.defaultPointLat || (firstPoint[1] || 0))
    return {
      ...item,
      coordinate,
      fenceType: derivedFenceType,
      defaultPointLat: derivedDefaultPointLat,
      defaultPointLon: derivedDefaultPointLon,
      district: item.district || fenceInfo.district || '',
      city: item.city || fenceInfo.city || '',
      name: item.name || fenceInfo.name || ''
    }
  },
  parseFenceCoordinate(fenceItem){
    const coordinate = fenceItem.coordinate || ''
    const coordinateList = coordinate.split(';').filter(i => i)
    const firstPoint = coordinateList[0] ? coordinateList[0].split(',') : []
    const isCircleByCoordinate = coordinateList.length == 2 &&
      firstPoint.length == 2 &&
      !Number.isNaN(Number(firstPoint[0])) &&
      !Number.isNaN(Number(firstPoint[1])) &&
      !Number.isNaN(Number(coordinateList[1]))
    if((fenceItem.fenceType == 1 || isCircleByCoordinate) && coordinateList.length >= 2){
      return {
        mode: 'circle',
        centerLongitude: Number(firstPoint[0]),
        centerLatitude: Number(firstPoint[1]),
        radius: Number(Number(coordinateList[1]).toFixed(5))
      }
    }
    if(coordinateList.length >= 3){
      return {
        mode: 'polygon',
        points: coordinateList.map((item) => {
          return {
            longitude: Number(item.split(',')[0]),
            latitude: Number(item.split(',')[1])
          }
        })
      }
    }
    return null
  },
  getMatchedFenceItemByLocation(latitude, longitude){
    const fenceList = this.data.fenceList || []
    for(let i = 0; i < fenceList.length; i++){
      const fenceItem = fenceList[i]
      const parsedFence = this.parseFenceCoordinate(fenceItem)
      if(!parsedFence){
        continue
      }
      if(parsedFence.mode == 'circle'){
        const distance = this.getDistanceMeters(
          latitude,
          longitude,
          parsedFence.centerLatitude,
          parsedFence.centerLongitude
        )
        if(distance <= Number(parsedFence.radius || 0)){
          return fenceItem
        }
      }else if(parsedFence.mode == 'polygon'){
        if(this.isPointInPolygon(latitude, longitude, parsedFence.points)){
          return fenceItem
        }
      }
    }
    return null
  },
  getMainFenceLocation(fenceList = []){
    const mainFence = fenceList.find((item) => Number(item.isMain) == 1) || fenceList[0]
    if(!mainFence){
      return ''
    }
    const parsedMainFence = this.parseFenceCoordinate(mainFence)
    const longitude = mainFence.defaultPointLon || (parsedMainFence && parsedMainFence.centerLongitude) || (parsedMainFence && parsedMainFence.points && parsedMainFence.points[0] && parsedMainFence.points[0].longitude)
    const latitude = mainFence.defaultPointLat || (parsedMainFence && parsedMainFence.centerLatitude) || (parsedMainFence && parsedMainFence.points && parsedMainFence.points[0] && parsedMainFence.points[0].latitude)
    if(!longitude || !latitude){
      return ''
    }
    return `${longitude},${latitude}`
  },
  async fetchFenceData(){
    if(this.data.where == 'endLocation'){
      const startId = this.data.startSiteId
      const endId = this.data.endSiteId || this.data.userId
      if(!startId || !endId){
        return {
          data: {
            code: 200,
            data: []
          }
        }
      }
      // 原来根据终点站点ID获取围栏的方法先保留注释,改为按起终站点查询新的围栏
      // return queryLocation(endId)
      return queryFirstLineDestinations(startId, endId)
    }
    return queryLocation(this.data.userId)
  },
  handleStationSelectResult(self, startInfo, extraUpdates = {}){
    let pages = getCurrentPages();
    let targetPage = pages[pages.length - 3];
    if(!targetPage){
      app.showToastSuccess('页面信息获取失败',null,'none',1500)
      return
    }
    const isStartStation = this.data.stationWhere == 'statrLocation'
    const siteId = this.data.userId
    const siteName = this.data.startLocation1 || self.name
    this.saveSelectedLocation(this.data.where, siteId, siteName, self.name, startInfo, extraUpdates)
    if(targetPage.route == 'pages/home/home'){
      const homeUpdates = isStartStation
        ? {
          abovadStartId: siteId,
          abvoadStartLocation: self.name,
          abovadEndId: null,
          abvoadEndLocation: '请选择终点'
        }
        : {
          abovadEndId: siteId,
          abvoadEndLocation: self.name
        }
      targetPage.setData(homeUpdates,()=>{
        wx.navigateBack({
          delta:2
        })
      })
      return
    }
    const updates = isStartStation
      ? {
        abovadStartId: siteId,
        abvoadStartLocation: siteName,
        abvoadEndLocation: this.getDefaultText(targetPage.data.abvoadEndLocation, '请选择终点'),
        abovadEndId: null,
        startLocation: self.name,
        startInfo,
        endLocation: this.getDefaultText(targetPage.data.endLocation, '请选择下车点'),
        endInfo: {},
        lineDestinationId: ''
      }
      : {
        abovadEndId: siteId,
        abvoadEndLocation: siteName,
        endLocation: self.name,
        endInfo: startInfo,
        lineDestinationId: extraUpdates.lineDestinationId || ''
      }
    targetPage.setData(updates,()=>{
      wx.navigateBack({
        delta:2
      })
    })
  },
  async confirmSelectedLocation(self, silentInvalid){
    let {
      abovadStartId,
      where
    } = this.data
    let pages = getCurrentPages();
    let prevPage = pages[pages.length - 2];
    const locationArr = (self.location || '').split(',')
    const currentLongitude = Number(locationArr[0])
    const currentLatitude = Number(locationArr[1])
    const hasFence = (this.data.circles && this.data.circles.length > 0) || (this.data.polygons && this.data.polygons.length > 0)
    if(
      hasFence &&
      Number.isFinite(currentLatitude) &&
      Number.isFinite(currentLongitude) &&
      !this.isCurrentLocationInFence(currentLatitude, currentLongitude)
    ){
      if(!silentInvalid){
        app.showToastSuccess('该位置不在围栏范围内,请重新选择',null,'none',1500)
      }
      return false
    }
    if(where == 'endLocation'){
      const firstLineValid = await this.queryEndLocationLineDestinations(silentInvalid)
      if(!firstLineValid){
        return false
      }
    }
    let res = await areaMonitoringexport(self.adcode, self.location,abovadStartId)
    let data = res.data
    let startInfo = {
        startLat  : self.location.split(',')[1],
        startLon  : self.location.split(',')[0]
    }
    const matchedFenceItem = where == 'endLocation'
      ? this.getMatchedFenceItemByLocation(currentLatitude, currentLongitude)
      : null
    const lineDestinationId = matchedFenceItem ? (matchedFenceItem.id || matchedFenceItem.lineDestinationId || '') : ''
    const extraUpdates = where == 'endLocation'
      ? { lineDestinationId }
      : {}
    if(data.code==200){
        if(data.data==1){
            if(this.data.source == 'stationSelect'){
                this.handleStationSelectResult(self, startInfo, extraUpdates)
                return true
            }
            this.saveSelectedLocation(
              where,
              abovadStartId,
              this.data.startLocation1 || self.name,
              self.name,
              startInfo,
              extraUpdates
            )
            if(where == "startLocation"){
                prevPage.setData({
                    startLocation:self.name,
                    startInfo:startInfo,
                    lineDestinationId: ''
                },()=>{
                    if(this.data.type!=1){
                        prevPage.queryOrderMoney()
                    }
                    wx.navigateBack({
                      delta:1
                    })
                })
            }else{
                prevPage.setData({
                    endLocation:self.name,
                    endInfo:startInfo,
                    lineDestinationId
                  },()=>{
                    if(this.data.type!=1){
                        prevPage.queryOrderMoney()
                    }
                    wx.navigateBack({
                      delta:1
                    })
                  })
            }
            return true
        }
        if(!silentInvalid){
          app.showToastSuccess('该位置不在有效范围内,请重新选择',null,'none',1500)
        }
        return false
    }
    app.showToastSuccess(data.msg,null,'none',1500)
    return false
  },
  async queryEndLocationLineDestinations(silentInvalid){
    const startId = this.data.startSiteId
    const endId = this.data.endSiteId || this.data.userId
    if(!startId || !endId){
      return true
    }
    try{
      const res = await queryFirstLineDestinations(startId, endId)
      const data = res.data || {}
      if(data.code == 200){
        return true
      }
      if(!silentInvalid){
        app.showToastSuccess(data.msg || '终点线路信息获取失败',null,'none',1500)
      }
      return false
    }catch(error){
      if(!silentInvalid){
        app.showToastSuccess('终点线路信息获取失败',null,'none',1500)
      }
      return false
    }
  },
  async getCurrentLocationInfo(updateMap){
    if(this.data.locatingCurrent){
      return null
    }
    this.setData({
      locatingCurrent: true
    })
    try{
      const locationRes = await new Promise((resolve, reject) => {
        wx.getLocation({
          type: 'gcj02',
          success: resolve,
          fail: reject
        })
      })
      const latitude = locationRes.latitude
      const longitude = locationRes.longitude
      const regeoRes = await this.reverseGeocode(latitude, longitude)
      const adcode = regeoRes.addressComponent.adcode || wx.getStorageSync('adcode')
      const formattedAddress = regeoRes.formattedAddress || '当前位置'
      const location = `${longitude},${latitude}`
      if(updateMap){
        const nearLocationKeyword =
          formattedAddress ||
          regeoRes.addressComponent.district ||
          regeoRes.addressComponent.city ||
          this.getNearLocationKeyword(formattedAddress)
        this.setData({
          longitude,
          latitude,
          startLocation: regeoRes.addressComponent.city || regeoRes.addressComponent.district || this.data.startLocation,
          markers: this.createMarker(latitude, longitude)
        })
        this.getNearLocation(nearLocationKeyword, location, false)
      }
      return {
        name: formattedAddress,
        location,
        adcode,
        latitude,
        longitude
      }
    }catch(error){
      return null
    }finally{
      this.setData({
        locatingCurrent: false
      })
    }
  },
  async tryAutoLocateCurrentPosition(){
    if(this.data.where != 'startLocation'){
      return
    }
    if(this.data.hasTriedAutoLocate){
      return
    }
    this.setData({
      hasTriedAutoLocate: true
    })
    const currentLocation = await this.getCurrentLocationInfo(true)
    if(!currentLocation){
      app.showToastSuccess('定位失败,请手动选择上车位置',null,'none',1500)
      return
    }
  },
  handleLocationButtonTap(){
    this.getCurrentLocationInfo(true).then((currentLocation) => {
      if(!currentLocation){
        app.showToastSuccess('定位失败,请手动选择上车位置',null,'none',1500)
      }
    })
  },
  //cancelAddress
  cancelAddress() {
@@ -96,7 +640,7 @@
  },
  //获取 poi
  getNearLocation(inputValue, location, bloone) {
     console.log('///////////',location);
    //  let myAmapFun = new amapFile.AMapWX({ key: '22f054fcf175ade2af008875bdd68242' });     
    var myAmapFun = new amapFile.AMapWX({
      key: 'cea7923a93987b959ab1d2f8ab44d497'
@@ -112,7 +656,7 @@
          addressList: arr,
        }, () => {
          if (bloone || '') {
            this.init(this.data.userId)
            this.init()
          }
        })
      }
@@ -131,14 +675,7 @@
            isCitys:false,
            latitude:res.latitude,
            longitude:res.longitude,
            markers: [{
                id: 1,
                latitude: res.latitude,
                longitude: res.longitude,
                iconPath: "/img/icon_location.png",
                width: 26,
                height: 35
              }],
            markers: this.createMarker(res.latitude, res.longitude),
          })
          this.getLocal (res.latitude,res.longitude)
        }
@@ -147,50 +684,22 @@
  },
  //获取Value
  getLocal(latitude, longitude) {
    // 使用高德地图
    var myAmapFun = new amapFile.AMapWX({
      key: 'cea7923a93987b959ab1d2f8ab44d497'
    });
    // 百度地图备用代码(注释掉)
    // qqmapsdk = new QQMapWX({
    //   key: 'UHWBZ-6NM3U-DHCVH-2NMFG-XWCIH-WUBYM', //这里自己的key秘钥进行填充
    // });
    // qqmapsdk.reverseGeocoder({
    //   location: {
    //     latitude: latitude,
    //     longitude: longitude
    //   },
    //   success:(res) => {
    //     if(res.message =="query ok" ){
    //       this.setData({
    //         startLocation:res.result.address_component.city
    //       })
    //        this.getNearLocation(res.result.formatted_addresses.recommend,location,false)
    //     }else{
    //       app.showToastSuccess('数据获取失败',null,'none',1500)
    //     }
    //   }
    // })
    myAmapFun.getRegeo({
      location: `${longitude},${latitude}`, // 高德地图格式:经度,纬度
      success: (res) => {
        // 高德地图返回的数据结构
        var regeocodeData = res[0].regeocodeData;
        const addressComponent = regeocodeData.addressComponent;
        const formattedAddress = regeocodeData.formatted_address;
    this.reverseGeocode(latitude, longitude).then((res) => {
        const addressComponent = res.addressComponent;
        const formattedAddress = res.formattedAddress;
        this.setData({
          startLocation: addressComponent.city || addressComponent.district
        })
        let location = longitude + ',' + latitude
        // 获取周边位置信息,使用formattedAddress作为推荐地址
        this.getNearLocation(formattedAddress, location, false)
      },
      fail: (error) => {
        const nearLocationKeyword =
          formattedAddress ||
          addressComponent.district ||
          addressComponent.city ||
          this.getNearLocationKeyword(formattedAddress)
        this.getNearLocation(nearLocationKeyword, location, false)
      }).catch(() => {
        app.showToastSuccess('数据获取失败222222222222', null, 'none', 1500)
      }
    })
      })
  },
  //点击从哪里上车
@@ -202,162 +711,92 @@
  //点击poi 跳转到 确定页面
  async handelClickLocationItem(e) {
    let self = e.currentTarget.dataset.self
    let {
      abovadStartId,
      where,
      circles,
      polygons
    } = this.data
    let newSelf = {
      ...self,
      abovadStartId,
      where
    }
    let pages = getCurrentPages();
    let prevPage = pages[pages.length - 2];
    let res = await areaMonitoringexport(self.adcode, self.location,abovadStartId)
    let data = res.data
    let startInfo = {
        startLat  : self.location.split(',')[1],
        startLon  : self.location.split(',')[0]
    }
    if(data.code==200){
        if(data.data==1){
            if(where == "startLocation"){
                prevPage.setData({
                    startLocation:self.name,
                    startInfo:startInfo
                },()=>{
                    if(this.data.type!=1){
                        prevPage.queryOrderMoney()
                    }
                    wx.navigateBack({
                      delta:1
                    })
                })
            }else{
                prevPage.setData({
                    endLocation:self.name,
                    endInfo:startInfo
                  },()=>{
                    if(this.data.type!=1){
                        prevPage.queryOrderMoney()
                    }
                    wx.navigateBack({
                      delta:1
                    })
                  })
            }
        }
    }
    // wx.navigateTo({
    //   url: `/pages/advoad-city-search/advoad-message/electronic-true/electronic-true?self=${JSON.stringify(newSelf)}&circles=${JSON.stringify(circles)}&polygons=${JSON.stringify(polygons)}`
    // })
    await this.confirmSelectedLocation(self)
  },
  handleDistrict(id) {
    return queryLocation(id);
  handleDistrict() {
    return this.fetchFenceData();
  },
  //异步操作
  async init(id) {
  async init() {
    try {
      let res1 = await queryLocation(id)
      let res1 = await this.fetchFenceData()
      let data = res1.data
      let picOnie = []
      let _circles = []
      let _polygons = []
      let _polygonsObj = {}
      const fenceList = this.getFenceListFromResponse(res1).map((item) => this.normalizeFenceItem(item))
      this.setData({
        district: res1.data.data[0].district
      })
      if (data.code == 200) {
        let arrPic = data.data.map(x => {
          if (x.type == 2 && x.coordinate !== '') {
            picOnie.push(x)
            return x
          } else if (x.type == 1 && x.coordinate == '') {
            return x
          }
      if(fenceList.length > 0){
        this.setData({
          fenceList,
          district: fenceList[0].district || this.data.district,
          startLocation: fenceList[0].city || this.data.startLocation
        })
        if (data.data.length > 0 && data.data[0].type == 2) {
          let coordinateLocation = data.data[0].coordinate.split(';')
          let longitude = coordinateLocation[0].split(',')[0]
          let latitude = coordinateLocation[0].split(',')[1]
          this.setData({
            markers: [{
              id: 1,
              latitude: latitude,
              longitude: longitude,
              iconPath: "/img/icon_location.png",
              width: 26,
              height: 35
            }],
            longitude,
            latitude
          }, () => {
            this.getLocal(latitude, longitude)
          })
      }else{
        this.setData({
          fenceList: []
        })
      }
      if (data.code == 200) {
        const mainFence = fenceList.find((item) => Number(item.isMain) == 1) || fenceList[0]
        if (mainFence) {
          const parsedMainFence = this.parseFenceCoordinate(mainFence)
          const longitude = mainFence.defaultPointLon || (parsedMainFence && parsedMainFence.centerLongitude) || (parsedMainFence && parsedMainFence.points && parsedMainFence.points[0] && parsedMainFence.points[0].longitude)
          const latitude = mainFence.defaultPointLat || (parsedMainFence && parsedMainFence.centerLatitude) || (parsedMainFence && parsedMainFence.points && parsedMainFence.points[0] && parsedMainFence.points[0].latitude)
          if(longitude && latitude){
            this.setData({
              markers: this.createMarker(latitude, longitude),
              longitude,
              latitude
            }, () => {
              this.getLocal(latitude, longitude)
            })
          }
        } else {
          if(this.data.addressList[0].location.length){
          if(this.data.addressList[0] && this.data.addressList[0].location.length){
            this.setData({
                longitude: this.data.addressList[0].location.split(',')[0],
                latitude: this.data.addressList[0].location.split(',')[1],
                startLocation: this.data.startLocation1
              })
          }else{
          }else if(this.data.addressList[1] && this.data.addressList[1].location.length){
            this.setData({
                longitude: this.data.addressList[1].location.split(',')[0],
                latitude: this.data.addressList[1].location.split(',')[1],
                startLocation: this.data.startLocation1
              })
          }
        }
        arrPic.map(x => {
          let arrLength = x.coordinate.split(';').length;
          if (x.coordinate !== undefined) {
            if (arrLength == 2) {
              let coordinateStr = x.coordinate.split(';')
              let circles_a = {
                latitude: coordinateStr[0].split(',')[1],
                longitude: coordinateStr[0].split(',')[0],
                color: '#7cb5ec88',
                fillColor: '#7cb5ec88',
                radius: Number(Number(coordinateStr[1]).toFixed(5)),
                strokeWidth: 1
              }
              _circles.push(circles_a)
            } else {
              let arrPlus = []
              let coordinatePolygons = x.coordinate.split(';').filter(i => i);
              for (let i = 0; i < coordinatePolygons.length; i++) {
                let arrLotcaionObj = {
                  longitude: Number(coordinatePolygons[i].split(',')[0]),
                  latitude: Number(coordinatePolygons[i].split(',')[1])
                }
                arrPlus.push(arrLotcaionObj)
                _polygonsObj.points = arrPlus
                _polygonsObj.fillColor = "#7cb5ec88"
                _polygonsObj.strokeColor = "#7cb5ec88"
                _polygonsObj.strokeWidth = 1
                _polygonsObj.zIndex = 1
              }
              _polygonsObj.points && _polygons.push(_polygonsObj)
            }
            this.setData({
              circles: _circles,
              polygons: _polygons
        fenceList.forEach((x) => {
          const parsedFence = this.parseFenceCoordinate(x)
          if (!parsedFence) {
            return
          }
          if (parsedFence.mode == 'circle') {
            _circles.push({
              latitude: parsedFence.centerLatitude,
              longitude: parsedFence.centerLongitude,
              color: '#7cb5ec88',
              fillColor: '#7cb5ec88',
              radius: parsedFence.radius,
              strokeWidth: 1
            })
          } else {
          } else if (parsedFence.mode == 'polygon') {
            _polygons.push({
              points: parsedFence.points,
              fillColor: "#7cb5ec88",
              strokeColor: "#7cb5ec88",
              strokeWidth: 1,
              zIndex: 1
            })
          }
        })
        this.setData({
          circles: _circles,
          polygons: _polygons
        },()=>{
          if(this.data.where == 'startLocation'){
            this.tryAutoLocateCurrentPosition()
          }
        })
      } else {
@@ -414,4 +853,4 @@
  onShareAppMessage: function () {
  }
})
})
pages/advoad-city-search/advoad-success/advoad-success.js
@@ -1,5 +1,4 @@
// pages/advoad-city-search/advoad-success/advoad-success.js
const unit = require('../../../utils/util')
const app = getApp();
Page({
@@ -7,23 +6,13 @@
     * 页面的初始数据
     */
    data: {
        payInfo: {},
        showPop: false
        payInfo: {}
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        unit.post(app.globalData.Url + "/base/line/confirm", {
                carId: wx.getStorageSync('carId'),
            })
            .then((res) => {
                // wx.removeStorageSync('carId')
                this.setData({
                    showPop: res.data.data == 1 ? true : false
                })
            })
        console.log(options)
        let pages = getCurrentPages();
        console.log(pages)
@@ -84,20 +73,9 @@
            iconStyle: iconStyle,
        });
    },
    closePop() {
        this.setData({
            showPop: false
        })
    },
    readerHome() {
        wx.reLaunch({
            url: '/pages/home/home',
        })
    },
    //跳转到预约摆渡车
    handelClickFerryCoach() {
        wx.redirectTo({
            url: `/pages/ferry-coach/ferry-coach?startLocation=${this.data.payInfo}`,
        })
    },
    //跳转到server
@@ -163,4 +141,4 @@
    onShareAppMessage: function () {
    }
})
})
pages/advoad-city-search/advoad-success/advoad-success.wxml
@@ -18,19 +18,3 @@
        <view catchtap="handelClickWaitting">查看订单</view>
    </view>
</view>
<!--摆渡车业务弹窗-->
<view class="pop-success" wx:if="{{showPop}}">
    <view class="img-center">
        <image src="https://traffic.qytzt.cn/v1/AUTH_d8bef0a04db511f0b79d01a3e2b7587e/qyt20250702/imgs/management/6913e69b-7d31-40d4-8341-5fbc3707719f.png"></image>
        <view class="title-view">
            <view class="pop-title">我们为您提供了摆渡车业务,</view>
            <view class="pop-title">可接送您至上车点。</view>
        </view>
     <view class="pop-active">
        <view catchtap="closePop">不用,谢谢</view>
        <view catchtap="handelClickFerryCoach">预约摆渡车</view>
     </view>
    </view>
</view>