qingyiay
2023-05-16 72935b2a35765bcc3622561bb06f2eccd64caf83
pages/public-page/mapRoute/mapRoute.vue
@@ -15,6 +15,7 @@
            <text>{{ duration || '' }}</text>
         </view>
      </view>
      <view class="open-button" @click="awaken"><button type="default">跳转</button></view>
   </view>
</template>
@@ -38,13 +39,13 @@
            {
               latitude: null,
               longitude: null,
               iconPath: '../../../static/image/banner/location.png',
               iconPath: 'https://mx.jzeg.cn:9095/appimg/image/banner/location.png',
               width: 23,
               height: 33,
               id: 0,
               callout: {
                  content: '起点', //文本
                  color: '#ffffff', //文字颜色
                  color: '#000000', //文字颜色
                  fontSize: 14, //文本大小
                  borderRadius: 15, //边框圆角
                  borderWidth: '10',
@@ -55,7 +56,7 @@
            {
               latitude: null,
               longitude: null,
               iconPath: '../../../static/image/banner/location.png',
               iconPath: 'https://mx.jzeg.cn:9095/appimg/image/banner/location.png',
               width: 23,
               height: 33,
               id: 1,
@@ -81,7 +82,9 @@
            }
         ],
         distance: null,
         duration: null
         duration: null,
         fromLocation: {},
         toLocation: {}
      };
   },
   methods: {
@@ -93,39 +96,45 @@
         let qqmapsdk = new QQMapWX({
            key: 'HTNBZ-LZGRQ-YDB5S-B4KAS-KLHJH-GHBUE' // 必填
         });
         const params = this.toFiledId ? { toFiledId: this.toFiledId } : { customerId: this.customerId, filedId: this.filedId };
         this.$reqGet('getAppLocation', params).then(res => {
            console.log(res, '腾讯经纬度');
         const params = this.toFiledId ? { filedId: this.filedId, toFiledId: this.toFiledId } : { customerId: this.customerId, filedId: this.filedId };
         this.$reqGet('getAppLocation', params).then(result => {
            console.log(result, '腾讯经纬度');
            let _this = this;
            console.log(_this.orderType, '类型');
            let fromLocation;
            let toLocation;
            if (_this.orderType == '外购' || _this.orderType == '外销') {
               _this.$set(_this.markers[0], 'longitude', res.data.customerLongitude);
               _this.$set(_this.markers[0], 'latitude', res.data.customerLatitude);
               fromLocation = {
                  longitude: res.data.customerLongitude,
                  latitude: res.data.customerLatitude
                  longitude: result.data.customerLongitude,
                  latitude: result.data.customerLatitude
               };
               _this.$set(_this.markers[1], 'longitude', res.data.filedLongitude);
               _this.$set(_this.markers[1], 'latitude', res.data.filedLatitude);
               toLocation = {
                  longitude: res.data.filedLongitude,
                  latitude: res.data.filedLatitude
                  longitude: result.data.filedLongitude,
                  latitude: result.data.filedLatitude
               };
            } else if (_this.orderType == '内购' || _this.orderType == '内销') {
               _this.$set(_this.markers[0], 'longitude', res.data.filedLongitude);
               _this.$set(_this.markers[0], 'latitude', res.data.filedLatitude);
               fromLocation = {
                  longitude: res.data.filedLongitude,
                  latitude: res.data.filedLatitude
                  longitude: result.data.filedLongitude,
                  latitude: result.data.filedLatitude
               };
               _this.$set(_this.markers[1], 'longitude', res.data.customerLongitude);
               _this.$set(_this.markers[1], 'latitude', res.data.customerLatitude);
               toLocation = {
                  longitude: res.data.customerLongitude,
                  latitude: res.data.customerLatitude
                  longitude: result.data.customerLongitude,
                  latitude: result.data.customerLatitude
               };
            } else {
               fromLocation = {
                  longitude: result.data.filedLongitude,
                  latitude: result.data.filedLatitude
               };
               toLocation = {
                  longitude: result.data.toFiledLongitude,
                  latitude: result.data.toFiledLatitude
               };
               _this.fromLocation = fromLocation;
               _this.toLocation = toLocation;
            }
            _this.fromLocation = fromLocation;
            _this.toLocation = toLocation;
            //调用距离计算接口
            qqmapsdk.direction({
               mode: 'driving',
@@ -158,6 +167,22 @@
                        arrowLine: true
                     }
                  ];
                  if (_this.orderType == '外购' || _this.orderType == '外销') {
                     _this.$set(_this.markers[0], 'longitude', result.data.customerLongitude);
                     _this.$set(_this.markers[0], 'latitude', result.data.customerLatitude);
                     _this.$set(_this.markers[1], 'longitude', result.data.filedLongitude);
                     _this.$set(_this.markers[1], 'latitude', result.data.filedLatitude);
                  } else if (_this.orderType == '内购' || _this.orderType == '内销') {
                     _this.$set(_this.markers[0], 'longitude', result.data.filedLongitude);
                     _this.$set(_this.markers[0], 'latitude', result.data.filedLatitude);
                     _this.$set(_this.markers[1], 'longitude', result.data.customerLongitude);
                     _this.$set(_this.markers[1], 'latitude', result.data.customerLatitude);
                  } else {
                     _this.$set(_this.markers[0], 'longitude', result.data.filedLongitude);
                     _this.$set(_this.markers[0], 'latitude', result.data.filedLatitude);
                     _this.$set(_this.markers[1], 'longitude', result.data.toFiledLongitude);
                     _this.$set(_this.markers[1], 'latitude', result.data.toFiledLatitude);
                  }
               },
               fail: function(error) {
                  console.error(error);
@@ -185,6 +210,15 @@
            .toString()
            .padStart(2, '0');
         return hours + ':' + minutes;
      },
      // 唤醒
      awaken() {
         uni.openLocation({
            latitude: this.markers[1].latitude,
            longitude: this.markers[1].longitude,
            name: '目的地位置',
            address: '目的地位置'
         });
      }
   },
   onLoad(params) {
@@ -196,10 +230,8 @@
      }
   },
   onShow() {
      if (this.orderType !== '转入' || this.orderType !== '转出') {
         this.getLocation();
      } else {
      }
      this.getLocation();
      // this.awaken();
   }
};
</script>
@@ -220,4 +252,8 @@
      }
   }
}
.open-button {
   width: 200rpx;
   margin: 10rpx 0;
}
</style>