详细问题描述
nvue引入高德小程序sdk,,然后报错 Can't find variable: wx __ERROR ,,vue的文件可以用用
<template>
<div style="display: flex;flex-direction: column;">
<map style="flex: 1;" :latitude="latitude" :longitude="longitude" show-location :markers="markers"
@callouttap="callouttap" @markertap="markertap" id="map1" ref="map1" :include-points="includePoints">
<cover-view class="left-top">
<cover-view class="cover-item">
<cover-image class="img" src="../../../static/img/status-green.png"></cover-image>
<text>较空</text>
</cover-view>
<cover-view class="cover-item margin-top">
<cover-image class="img" src="../../../static/img/status-yellow.png"></cover-image>
<text>较满</text>
</cover-view>
<cover-view class="cover-item margin-top">
<cover-image class="img" src="../../../static/img/status-red.png"></cover-image>
<text>紧张</text>
</cover-view>
</cover-view>
</map>
<view ref="bottom_box" class="bottom_box">
<view>
<view>
<text style="text-align: center;">请选择回收机进行路线规划</text>
</view>
<view style="justify-content: space-around;flex-direction: row;margin-top: 40px;">
<text class="btn" v-bind:class="[(includePointsType == 'full')?'bg-blue':'']" @click="changeMap('full')">满箱回收机{{ fullIncludePoints.length }}台</text>
<text class="btn" v-bind:class="[(includePointsType == 'all')?'bg-blue':'']" @click="changeMap('all')">全部回收机{{ allIncludePoints.length }}台</text>
</view>
</view>
</view>
</div>
</template>
<script>
import $http from '../../../js_sdk/api/api.js';
import amap from '../../../js_sdk/amap-wx.js';
export default {
data() {
return {
map:"",
latitude: 39.909,
longitude: 116.39742,
markers: [],
amapPlugin: null,
key: '0f65a82aaea0288b9b7adb79a848ca0f',
includePoints:[],
allIncludePoints:[],
fullIncludePoints:[],
includePointsType:"full",
};
},
beforeCreate() {
},
created() {
},
mounted() {
// this.amapPlugin = new amap.AMapWX({
// key: this.key
// });
// this.amapPlugin.getRegeo({
// success: (data) => {
// console.log(data) ;
// }
// });
this.map = uni.createMapContext("map1", this);
$http.getUserDeviceList().then((res)=>{
if(res.data){
let {status,data,message} = res.data;
if(status == '200'){
let obj = null;
this.markers = data.map((item)=>{
this.allIncludePoints.push({
latitude: item.longitudeLatitude[1],
longitude: item.longitudeLatitude[0],
});
obj = {
id:item.id + '_' + Date.now(),
latitude: item.longitudeLatitude[1],
longitude: item.longitudeLatitude[0],
width:73,
height:78,
iconPath: '../../../static/img/status-green.png',
title:"",
callout:{
content:item.areaDetailName,
padding:5,
display:"BYCLICK",
borderRadius:3,
fontSize:12,
}
}
let fullArr = item.deviceStatuses.filter((elem,index)=>{
return elem.value >= 0.9;
});
if(fullArr.length > 0){
this.fullIncludePoints.push({
latitude: item.longitudeLatitude[1],
longitude: item.longitudeLatitude[0],
});
obj.iconPath = '../../../static/img/status-red.png';
}else{
let tensionArr = item.deviceStatuses.filter((elem,index)=>{
return 0.5 >= elem.value < 0.9;
});
if(tensionArr.length > 0){
obj.iconPath = '../../../static/img/status-yellow.png';
}
}
return obj;
});
this.includePoints = this.fullIncludePoints;
}
}
});
uni.getLocation({
type: 'gcj02',
success: (res)=> {
this.longitude = res.longitude;
this.latitude = res.latitude;
}
});
},
methods:{
callouttap(event){
//点击气泡时触发
console.log('callouttap',event);
},
markertap(event){
//点击标记点
console.log('markertap',event);
},
changeMap(type){
//满箱和全部回收机的切换
this.includePointsType = type;
if(type == 'all'){
this.includePoints = this.allIncludePoints;
this.map.getScale({
success: ret => {
console.log(ret);
},
fail: error => {
console.log(res);
}
})
}else{
this.includePoints = this.fullIncludePoints;
}
}
},
}
</script>
<style lang="scss">
.bottom_box {
// width: 100%;
height: 260px;
background-color: #FFFFFF;
// position: absolute;
border-radius: 5px;
justify-content:center;
}
.left-top{
background-color: #FFFFFF;
// width: 160rpx;
// height: 190rpx;
position: absolute;
left: 10px;
top: 10px;
padding: 20rpx;
border-radius: 3px;
}
.cover-item{
justify-content: space-between;
flex-direction: row;
align-items: center;
}
.margin-top{
margin-top: 20rpx;
}
.img{
width: 53rpx;
height: 58rpx;
margin-right: 15px;
}
.text-center{
text-align: center;
}
.btn{
padding: 15px 40px;
text-align: center;
border-color: #1c1c1c;
border-width: 1px;
border-style: solid;
border-radius: 5px;
}
.bg-blue{
background-color: #0081ff;
border-color: #0081ff;
color: #FFFFFF;
}
</style>
(DCloud产品不会有明显的bug,所以你遇到的问题大都是在特定环境下才能重现的问题,请仔细描述你的环境和重现方式,否则DCloud很难排查解决你的问题)
[内容]
重现步骤
[步骤]
[结果]
[期望]
[如果语言难以表述清晰,拍一个视频或截图,有图有真相]
IDE运行环境说明
[HBuilder 或 HBuilderX。如果你用其他工具开发uni-app,也需要在此说明]
[IDE版本号]
[windows版本号]
[mac版本号]
uni-app运行环境说明
[运行端是h5或app或某个小程序?]
[运行端版本号]
[项目是cli创建的还是HBuilderX创建的?如果是cli创建的,请更新到最新版cli再试]
[编译模式是老模板模式还是新的自定义组件模式?]
App运行环境说明
[Android版本号]
[iOS版本号]
[手机型号]
[模拟器型号]
附件
[IDE问题请提供HBuilderX运行日志。菜单帮助-查看运行日志,点右键打开文件所在目录,将log文件压缩成zip包上传]
[App问题请提供可重现问题的代码片段,你补充的细一点,问题就解决的快一点]
[App安装包或H5地址]
[可重现代码片段]
联系方式
[QQ]
8***@qq.com (作者)
请问这个能实现多个点的路线规划么?我看高德的sdk教程里头没得这个
2019-12-23 20:13
大苏
回复 8***@qq.com: 这个你要看高德的文件了
2019-12-24 15:23