doum
2026-04-28 87779aa2eb38f07e266ecb536e8ecd30c3b994b5
small-program/unpackage/dist/dev/mp-weixin/shop/pages/order-details/order-details.js
@@ -242,6 +242,7 @@
var _weappQrcode = _interopRequireDefault(__webpack_require__(/*! weapp-qrcode */ 193));
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var amapFile = __webpack_require__(/*! @/utils/amap-wx.130.js */ 38);
var _default = {
  computed: _objectSpread({}, (0, _vuex.mapState)(['navHeight', 'statusbarHeight'])),
  data: function data() {
@@ -249,7 +250,12 @@
      id: null,
      qrcodeImage: null,
      showCancel: false,
      info: {}
      info: {},
      mapLat: 0,
      mapLng: 0,
      mapScale: 12,
      markers: [],
      polyline: []
    };
  },
  onShow: function onShow() {
@@ -397,6 +403,9 @@
                    info: _this3.info,
                    delete: 0
                  });
                  if (_this3.info.type === 1 && _this3.info.status === 4) {
                    _this3.getRoutePlanning();
                  }
                }
              case 5:
              case "end":
@@ -405,6 +414,146 @@
          }
        }, _callee3);
      }))();
    },
    getRoutePlanning: function getRoutePlanning() {
      var that = this;
      var driverLat = this.info.driverLat;
      var driverLng = this.info.driverLng;
      var depositShopLat = this.info.depositShopLat;
      var depositShopLng = this.info.depositShopLng;
      console.log('getRoutePlanning called', driverLat, driverLng, depositShopLat, depositShopLng);
      if (!driverLat || !driverLng || !depositShopLat || !depositShopLng) {
        console.log('坐标缺失');
        return;
      }
      this.mapLat = driverLat;
      this.mapLng = driverLng;
      var myAmapFun = new amapFile.AMapWX({
        key: this.$gaodeMapKey
      });
      myAmapFun.getDrivingRoute({
        origin: driverLng + ',' + driverLat,
        destination: depositShopLng + ',' + depositShopLat,
        success: function success(data) {
          console.log('获取路径规划成功 data:', data);
          console.log('data keys:', Object.keys(data));
          console.log('data.paths:', data.paths);
          console.log('driverLng:', driverLng, 'driverLat:', driverLat, 'depositShopLng:', depositShopLng, 'depositShopLat:', depositShopLat);
          var points = [];
          if (data.paths && data.paths.length > 0) {
            var path = data.paths[0];
            console.log('path:', path);
            console.log('path keys:', Object.keys(path));
            var steps = path.steps || path.routs || path.roads || [];
            if (steps.length === 0 && path.distance) {
              steps = [path];
            }
            console.log('steps:', steps);
            if (steps && steps.length > 0) {
              for (var i = 0; i < steps.length; i++) {
                var step = steps[i];
                console.log('step:', step);
                console.log('step keys:', step ? Object.keys(step) : 'null');
                var polylineStr = step.polyline || step.Polyline || step.path || step.line || step.road || '';
                console.log('polylineStr:', polylineStr);
                if (!step || !polylineStr) continue;
                var stepPoints = polylineStr.split(';');
                if (!stepPoints || stepPoints.length === 0) continue;
                for (var j = 0; j < stepPoints.length; j++) {
                  if (!stepPoints[j]) continue;
                  var point = stepPoints[j].split(',');
                  if (!point || point.length < 2) continue;
                  points.push({
                    latitude: parseFloat(point[1]),
                    longitude: parseFloat(point[0])
                  });
                }
              }
            }
          }
          console.log('points:', points);
          that.polyline = [{
            points: points,
            color: '#00c47c',
            width: 10,
            arrowLine: true
          }];
          console.log('polyline set:', that.polyline);
          that.markers = [{
            id: 1,
            latitude: parseFloat(driverLat),
            longitude: parseFloat(driverLng),
            iconPath: '/static/icon/start.png',
            width: 30,
            height: 40,
            anchor: {
              x: 0.5,
              y: 1
            }
          }, {
            id: 2,
            latitude: parseFloat(depositShopLat),
            longitude: parseFloat(depositShopLng),
            iconPath: '/static/icon/end.png',
            width: 30,
            height: 40,
            anchor: {
              x: 0.5,
              y: 1
            }
          }, {
            id: 3,
            latitude: parseFloat(driverLat),
            longitude: parseFloat(driverLng),
            iconPath: '/static/icon/dizhi.png',
            width: 24,
            height: 30,
            anchor: {
              x: 0.5,
              y: 0.5
            },
            callout: {
              content: '预计到店时间\n' + (that.info.expectedDepositTime || ''),
              color: '#222222',
              fontSize: 14,
              borderRadius: 4,
              padding: 8,
              display: 'ALWAYS',
              bgColor: 'rgba(255, 255, 255, 0.95)'
            }
          }];
          if (points.length > 0) {
            that.mapLat = points[Math.floor(points.length / 2)].latitude;
            that.mapLng = points[Math.floor(points.length / 2)].longitude;
          }
        },
        fail: function fail(err) {
          console.error('获取路径规划失败', err);
          that.markers = [{
            id: 1,
            latitude: parseFloat(driverLat),
            longitude: parseFloat(driverLng),
            iconPath: '/static/icon/start.png',
            width: 30,
            height: 40,
            anchor: {
              x: 0.5,
              y: 1
            }
          }, {
            id: 2,
            latitude: parseFloat(depositShopLat),
            longitude: parseFloat(depositShopLng),
            iconPath: '/static/icon/end.png',
            width: 30,
            height: 40,
            anchor: {
              x: 0.5,
              y: 1
            }
          }];
        }
      });
    }
  }
};