中品加油
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

850 lines
26 KiB

<template>
<view>
<cu-custom class="main-totextbar bg-main-oil" :isBack="true" bgColor="bg-main-oil">
<block slot="backText">返回</block>
<block slot="content">路径规划地图</block>
</cu-custom>
<view class="filter-container">
<sl-filter reflexTitle ref="slFilter" @result="filterRes" :menuList="menuList"></sl-filter>
</view>
<view class="map_box" ref='map_box'>
<map id="navi_map" ref="navi_map" :longitude="origin.longitude" :latitude="origin.latitude" scale="12" @labeltap="markerTap" @markertap="markerTap" :markers="covers" :polyline="polyline" >
</map>
</view>
<view class="site_info" v-if="showSiteDetail">
<view class="inner_container" >
<view class=" siteName">{{oliSiteInfo.siteName}}</view>
<view class=" detail flex ">
<view class=" address_info">{{oliSiteInfo.address}}</view>
<view class=" distances">
<view class="margin-top-sm margin-right-lg text-red-deep">
<text class='cuIcon-location'></text>
<text > {{oliSiteInfo.distance}}KM</text>
</view>
</view>
</view>
<view class=" actions">
<view @tap="navigation">导航</view>
<view @tap="gotoDetail">详情</view>
</view>
</view>
<view class="close" @tap="showSiteDetail=false">×</view>
</view>
</view>
</template>
<script>
import amapFile from '../../../utils/amap-wx.130.js'
import StationItem from '@/components/site-item/site-item.vue'
import oilSiteApi from '../../../api/oil-site.js'
import slFilter from '@/components/sl-filter/sl-filter.vue'
export default {
data() {
return {
oliSiteInfo:{},//存储所选 油站信息
controls: [{ //在地图上显示控件,控件不随着地图移动
id: 1, //控件id
position: { //控件在地图的位置
left: 0,
top: 15,
width: 50,
height: 50
},
}],
menuList: [{
title: '距离',
isMutiple: false,
key: 'distance',
detailList: [
{
title: "默认",
value: 20
},
{
title: "20Km",
value: 20
},
{
title: "30Km",
value: 30
},
{
title: "50Km",
value: 50
}
]
},
{
title: '油品',
key: 'oilProductCode',
isMutiple: false,
detailList: uni.getStorageSync('filterData') ? uni.getStorageSync('filterData')[1].detailList : [{
title: "默认",
value: "0#"
}]
},
{
title: '是否高速',
key: 'highSpeedMark',
isSort: true,
isMutiple: false,
detailList: [
{
title: "全部",
value: ""
},
{
title: "是",
value: '1'
},
{
title: "否",
value: '0'
},
]
},
{
title: '渠道',
key: 'channelCode',
isSort: true,
isMutiple: false,
detailList: uni.getStorageSync('filterData') ? uni.getStorageSync('filterData')[3]?.detailList : [{
title: "全部",
value: ""
}]
}
],
searchInfo:{
juLi:20, //分别返回20公里,30公里以及50公里范围内油站数据 默认为20 Number
oilProductCode:"0#", //油品,查询条件0#、-10#、-20#、-35# 为空默认查询0# String
siteChannel: "" , //XOIL:星油WJY:万金油LV:老吕(找油网)TY:团油YDJY:一点加油(壳牌)为空默认查询全部 String
geoList:[]
},
changesJuli:0,
covers: [],
origin: {
lon: '',
lat: '',
// tips: [],
address: ''
},
destination: {
lon: '',
lat: '',
// tips: [],
address: ''
},
latitude: '',
longitude: '',
filterCondition: '',
polyline: [
{
borderColor: "#00B373",
color: "#00B373",
points: [
]
}
],
myAmapFun:new amapFile.AMapWX({key: '88f3d3a38da95c4dea388978a76d0b81'}),
scale: 12, //地图层级
distance: '',
cost: '',
northeast: '',
southwest: '',
points: [],
siteInfo: '',
showSiteDetail: false,
newOilVariety: [],
newchannel:[],
ChangeoilProductCode:'',
changeOnload :{}
}
},
components:{
StationItem,
slFilter
},
onLoad(option) {
this.changeOnload = option
if (!uni.getStorageSync('filterData')) {
oilSiteApi.getConditionMenu().then(res=>{
if(res.code == 20000){
let oilVariety = res.data.productCodes,
channel = res.data.channelCodes
this.newOilVariety = res.data.productCodes
this.newchannel = res.data.channelCodes
this.getFilterData(oilVariety,channel)
}
})
}
var that = this;
this.origin = JSON.parse(option.origin )
this.destination = JSON.parse(option.destination)
this.myAmapFun .getDrivingRoute({
origin: this.origin.longitude+","+this.origin.latitude,
destination: this.destination.longitude+","+this.destination.latitude,
success: function(data){
var points ={
juLi:20, //分别返回20公里,30公里以及50公里范围内油站数据 默认为20 Number
oilProductCode:"", //油品,查询条件0#、-10#、-20#、-35# 为空默认查询全部 String
siteChannel: "" , //XOIL:星油WJY:万金油LV:老吕(找油网)TY:团油YDJY:一点加油(壳牌)为空默认查询全部 String
geoList:[]
};
var lines= []
if(data.paths && data.paths[0] && data.paths[0].steps){
var steps = data.paths[0].steps;
for(var i = 0; i < steps.length; i++){
var poLen = steps[i].polyline.split(';');
for(var j = 0;j < poLen.length; j++){
points.geoList.push({
lon: parseFloat(poLen[j].split(',')[0]),
lat: parseFloat(poLen[j].split(',')[1])
})
lines.push({
longitude: parseFloat(poLen[j].split(',')[0]),
latitude: parseFloat(poLen[j].split(',')[1])
})
}
}
}
that.points = points
that.polyline= [{
points: lines,
color: "#00B373",
width: 6,
borderColor: "#00B373",
}]
if(option.isChange == 1){
that.changeGetInfo()
return
}
console.log("测试一下")
console.log(that.polyline )
if(data.paths[0] && data.paths[0].distance){
that.distance = data.paths[0].distance + '米'
}
if(data.taxi_cost){
that.cost = '打车约' + parseInt(data.taxi_cost) + '元'
}
that.tempPoints = points;
that.tempPoints.geoList= that.tempPoints.geoList.filter((item,index)=>{
return index % 20 == 0
});
// this.tempPoints.push( this.northeast )
// this.tempPoints.push( this.southwest )
console.log( '+++++++++++++++++++++++',that.tempPoints)
let newPiont = []
oilSiteApi.getSiteByGeoHash(that.tempPoints).then(ele=>{
that.coverDatas = ele.data;
// console.log("当前结果数据")
// console.log(that.coverDatas)
that.tempPoints =points
// 包装成maker
let nmbs = 0
ele.data.forEach(item=>{
// console.log('123' ,item.id)
let iconPath;
if(item.siteChannel === 'LV'){
iconPath ='../../static/img/LV.png';
}else if(item.siteChannel == 'TY'){
iconPath ='../../static/img/change_TY.png';
}else if(item.siteChannel == 'WJY'){
iconPath ='../../static/img/change_wjy.png';
}else if(item.siteChannel == 'XOIL'){
iconPath ='../../static/img/change_xy.png';
}else if(item.siteChannel == 'YDJY'){
iconPath ='../../static/img/YDJY.png';
} else{
iconPath ='../../static/img/change_qt.png';
}
// item.distance= item.distance.toFixed(1);
let result = {
id: Number(item.id.substr(0,8)),
siteId: item.id,
latitude: item.latitude,
longitude: item.longitude,
iconPath: iconPath,
width: 52,
height: 66,
label: { //为标记点旁边增加标签
content:'', //文本
color: '#FFFFFF', //文本颜色
anchorX: -5, //label的坐标,原点是 marker 对应的经纬度
anchorY: -25 //label的坐标,原点是 marker 对应的经纬度
}
}
newPiont.push(result)
})
that.covers = newPiont
// console.log('this.covers',that.covers)
if(that.filterCondition != null && that.filterCondition != ''){
console.log(that.filterCondition)
// this.filterCondition.distance = 3
that.filterRes(that.filterCondition)
}
})
},
fail: function(info){
}
})
},
methods:{
changeGetInfo(){
let that = this
this.searchInfo = uni.getStorageSync('searchInfo')
let inifo =this.searchInfo ,
listGeo = that.points.geoList
console.log(listGeo)
var points ={
juLi:inifo.juLi,//分别返回20公里,30公里以及50公里范围内油站数据 默认为20 Number
oilProductCode:inifo.oilProductCode,//油品,查询条件0#、-10#、-20#、-35# 为空默认查询全部 String
siteChannel: inifo.siteChannel ,//XOIL:星油WJY:万金油LV:老吕(找油网)TY:团油YDJY:一点加油(壳牌)为空默认查询全部 String
geoList:that.points.geoList
};
console.log(points)
let newPiont = []
oilSiteApi.getSiteByGeoHash(points).then(ele=>{
console.log('这里是change')
that.coverDatas = ele.data;
console.log("当前结果数据")
console.log(that.coverDatas)
that.tempPoints =points
// 包装成maker
let ishighSpeedMark =''+uni.getStorageSync('ishighSpeedMark')
let coverList = []
console.log('ishighSpeedMark',ishighSpeedMark,typeof(ishighSpeedMark))
if(ishighSpeedMark!=''){
ishighSpeedMark = parseInt(ishighSpeedMark)
if(ishighSpeedMark == 1 || ishighSpeedMark == 0 ){
console.log('进入')
if(ishighSpeedMark == 1){
that.coverDatas = that.coverDatas.map(item=>{
if(item.highSpeedMark == 1){
coverList.push(item)
console.log('123456',coverList)
}
})
}
if(ishighSpeedMark == 0){
that.coverDatas = that.coverDatas.map(item=>{
if(item.highSpeedMark == 0){
coverList.push(item)
console.log('3456',coverList)
}
})
}
}
}
if(coverList.length>0){
that.coverDatas = coverList
}
console.log('+-+-+-+-+-',that.coverDatas)
console.log('+-+-+-+-+-',coverList)
let pointsList =that.coverDatas.map(item=>{
let iconPath;
if(item.siteChannel === 'LV'){
iconPath ='../../static/img/LV.png';
}else if(item.siteChannel == 'TY'){
iconPath ='../../static/img/change_TY.png';
}else if(item.siteChannel == 'WJY'){
iconPath ='../../static/img/change_wjy.png';
}else if(item.siteChannel == 'XOIL'){
iconPath ='../../static/img/change_xy.png';
}else if(item.siteChannel == 'YDJY'){
iconPath ='../../static/img/YDJY.png';
} else{
iconPath ='../../static/img/change_qt.png';
}
// item.distance= item.distance.toFixed(1);
let result = {
id: Number(item.id.substr(0,8)),
siteId: item.siteCode,
latitude: item.latitude,
longitude: item.longitude,
iconPath: iconPath,
width: 52,
height: 66,
label: { //为标记点旁边增加标签
content:'', //文本
color: '#FFFFFF', //文本颜色
anchorX: -5, //label的坐标,原点是 marker 对应的经纬度
anchorY: -25 //label的坐标,原点是 marker 对应的经纬度
}
}
return result
})
that.covers = pointsList
console.log('this.covers',that.covers)
if(that.filterCondition != null && that.filterCondition != ''){
console.log("过滤数据")
console.log(that.filterCondition)
// this.filterCondition.distance = 3
that.filterRes(that.filterCondition)
}
})
},
// change距离重新渲染路径
changeJuLi(es){
let that = this
let inifo = that.searchInfo,
listGeo = that.points.geoList
if(es){
var points ={
juLi:es, //分别返回20公里,30公里以及50公里范围内油站数据 默认为20 Number
oilProductCode:inifo.oilProductCode, //油品,查询条件0#、-10#、-20#、-35# 为空默认查询全部 String
siteChannel: inifo.siteChannel , //XOIL:星油WJY:万金油LV:老吕(找油网)TY:团油YDJY:一点加油(壳牌)为空默认查询全部 String
geoList:listGeo
};
}else{
var points ={
juLi:inifo.juLi, //分别返回20公里,30公里以及50公里范围内油站数据 默认为20 Number
oilProductCode:inifo.oilProductCode, //油品,查询条件0#、-10#、-20#、-35# 为空默认查询全部 String
siteChannel: inifo.siteChannel , //XOIL:星油WJY:万金油LV:老吕(找油网)TY:团油YDJY:一点加油(壳牌)为空默认查询全部 String
geoList:listGeo
};
}
uni.setStorageSync('searchInfo',points)
uni.redirectTo({
url:`/BagStation/pages/routePlainMap/routePlainMap?origin=${this.changeOnload.origin}&destination=${this.changeOnload.destination}&isChange=1`
})
},
navigation(){
uni.openLocation({
latitude: this.oliSiteInfo.latitude,
longitude: this.oliSiteInfo.longitude,
success: function () {
console.log('success');
}
});
},
gotoDetail(){
let obj = {
siteId : this.siteInfo.id,
siteCode:this.siteInfo.siteCode,
siteChannel:this.siteInfo.siteChannel,
longitude:this.siteInfo.longitude,
latitude:this.siteInfo.latitude,
}
let itemS = JSON.stringify(obj)
uni.navigateTo({
url: `../stationDetail/stationDetail?item=${itemS}&&types=map`
})
},
goDetail: function(){
wx.navigateTo({
url: '../navigation_car_detail/navigation'
})
},
goToCar: function (e) {
wx.redirectTo({
url: '../navigation_car/navigation'
})
},
goToBus: function (e) {
wx.redirectTo({
url: '../navigation_bus/navigation'
})
},
goToRide: function (e) {
wx.redirectTo({
url: '../navigation_ride/navigation'
})
},
goToWalk: function (e) {
wx.redirectTo({
url: '../navigation_walk/navigation'
})
},
getFilterData(v,c) { //v:油站油品 c:油站渠道
oilSiteApi.getCheckInfo().then(res => {
if (res.code == 20000) {
let channelCodes = []
c.map(item => {
channelCodes.push({
title: item.name,
value: item.id
})
})
let productCodes = []
v.map(item => {
productCodes.push({
title: item.name,
value: item.id
})
})
let siteBrands = []
res.data.siteBrands.map(item => {
siteBrands.push({
title: item.name,
value: item.id
})
})
console.log('++++++++++++++++++++++++++++++++++++++++++++++++',channelCodes, productCodes, siteBrands)
this.menuList[3].detailList = this.menuList[3].detailList.concat(channelCodes)
this.menuList[1].detailList = this.menuList[1].detailList.concat(productCodes)
// this.menuList[2].detailList = this.menuList[2].detailList.concat(siteBrands)
console.log('这里是旧获取菜单信息的地方',this.menuList)
console.log('这里是新获取menus内容 渠道',c,'这里是新获取menus内容 渠道',v)
uni.setStorageSync('filterData', this.menuList)
// this.$refs.slFilter.resetMenuList(this.menuList)
}
})
},
markerTap(res){
console.log('这类似点击marker点',res)
console.log('这类似点击marker点匹配',this.coverDatas)
let site = this.coverDatas.filter(item=>Number(item.id.substr(0,8)) == res.detail.markerId );
console.log('*++++++++++++++++++++++++++++++*',site)
this.siteInfo = site[0]
if(this.siteInfo){
let userLocation = uni.getStorageSync('userLocation')
let list = userLocation.split(','),
longitude = list[0],
latitude = list[1]
let obj = {
siteId:this.siteInfo.id,
latitude:latitude ,
longitude: longitude ,
}
console.log('点击获取obj',obj)
oilSiteApi.getSiteDetails(obj).then(res=>{
if(res.code == 20000){
console.log(res)
this.oliSiteInfo = res.data
this.oliSiteInfo.distance = res.data.juli /1000
this.showSiteDetail=true
} else{
uni.showToast({
title:res.msg,
icon:'none'
})
}
})
}
console.log('这里是siteInfo idS',this.siteInfo)
},
//接口筛选
filterRes(res){
console.log(res)
console.log("筛选前")
console.log('list',res.highSpeedMark)
if(res.distance){
if(res.distance != this.searchInfo.juLi){
// this.fistJli = 1
this.searchInfo.juLi = res.distance
console.log('change前',res.distance)
this.changeJuLi(res.distance )
return
}
}
if(res.oilProductCode){
if(res.oilProductCode != this.searchInfo.oilProductCode){
// this.fistJli = 1
this.searchInfo.oilProductCode = res.oilProductCode
console.log('change前',res.oilProductCode)
this.changeJuLi()
return
}
}
if(res.channelCode){
if(res.channelCode != this.searchInfo.siteChannel){
// this.fistJli = 1
this.searchInfo.siteChannel = res.channelCode
console.log('change前',res.channelCode)
this.changeJuLi()
return
}
}
if(res.highSpeedMark){
console.log('++++++++++++++++++++++++++++++是否高速')
let changIs = uni.getStorageSync('ishighSpeedMark')
if(!changIs){
changIs = res.highSpeedMark
console.log(changIs)
uni.setStorageSync('ishighSpeedMark',parseInt(changIs))
this.changeJuLi()
return
}
if(res.highSpeedMark != changIs){
// this.fistJli = 1
console.log('这里是油站是否高速')
let changIs = uni.getStorageSync('ishighSpeedMark')
changIs = res.highSpeedMark
console.log(changIs)
uni.setStorageSync('ishighSpeedMark',parseInt(changIs))
// if(item.highSpeedMark = res.highSpeedMark ){
this.changeJuLi()
return
}
}
// if(res.highSpeedMark != null && res.highSpeedMark != '' ){
// console.log('这里是油站是否高速')
// let changIs = uni.getStorageSync('ishighSpeedMark')
// changIs = res.highSpeedMark
// console.log(changIs)
// uni.setStorageSync('ishighSpeedMark',changIs)
// // if(item.highSpeedMark = res.highSpeedMark ){
// this.changeJuLi()
// return
// // }
// }
// console.log(this.coverDatas)
this.filterCondition = res
let tmpCoverDatas = this.coverDatas.filter(item=>{
// if(res.highSpeedMark != null && res.highSpeedMark != '' ){
// console.log('这里是油站是否高速')
// // if(item.highSpeedMark = res.highSpeedMark ){
// return item.highSpeedMark == res.highSpeedMark
// // }
// }
// if(res.channelCode != null && res.channelCode != '' && res.channelCode != item.siteChannel){
// console.log('这里是油站渠道')
// return item.channelCode === res.channelCode
// }
// if(res.oilProductCode != null && res.oilProductCode != '' ){
// console.log('这里是油站油品')
// return item.oilProductCode == res.oilProductCode
// // for(let ele of item){
// // console.log('测试内容',ele)
// // if(ele != res.oilProductCode) return false;
// // }
// }
return true;
})
console.log("筛选后")
console.log(this.coverDatas)
console.log('这里是筛选后 tmpCoverDatas+++++++++++++++++++++',tmpCoverDatas)
// this.$refs.navi_map.clear()
// console.log(this.covers)
this.covers = []
this.covers = tmpCoverDatas.map(item=>{
let iconPath;
if(item.siteChannel === 'LV'){
iconPath ='../../static/img/LV.png';
}else if(item.siteChannel == 'TY'){
iconPath ='../../static/img/change_TY.png';
}else if(item.siteChannel == 'WJY'){
iconPath ='../../static/img/change_wjy.png';
}else if(item.siteChannel == 'XOIL'){
iconPath ='../../static/img/change_xy.png';
}else if(item.siteChannel == 'YDJY'){
iconPath ='../../static/img/YDJY.png';
} else{
iconPath ='../../static/img/change_qt.png';
}
let result = {
id: Number(item.id.substr(0,8)),
siteId: item.id,
latitude: item.latitude,
longitude: item.longitude,
iconPath: iconPath,
width: 52,
height: 66,
label: { //为标记点旁边增加标签
content:'', //文本
color: '#FFFFFF', //文本颜色
anchorX: -5, //label的坐标,原点是 marker 对应的经纬度
anchorY: -25, //label的坐标,原点是 marker 对应的经纬度
}
}
return result
})
console.log("筛选过后的数据");
console.log(this.covers);
// highSpeedMark = []
// this.$refs.navi_map.removeMarkers()
// this.$refs.navi_map.addMarkers(this.covers)
},
moveMap(res){
console.log(res)
if(res.type == "end"){
this.northeast = res.detail.region.northeast
this.southwest = res.detail.region.southwest
console.log('这里是this.northeast ',this.northeast )
console.log('这里是this.southwest ',this.southwest )
this.tempPoints = JSON.parse(JSON.stringify(this.points));
this.tempPoints= this.tempPoints.filter((item,index)=>{
return index % 35 == 0
});
// this.tempPoints.push( this.northeast )
// this.tempPoints.push( this.southwest )
console.log( '+++++++++++++++++++++++',this.tempPoints)
oilSiteApi.getSiteByGeoHash(this.tempPoints).then(ele=>{
this.coverDatas = ele.data;
console.log("当前结果数据")
console.log(this.coverDatas)
this.tempPoints = JSON.parse(JSON.stringify(this.points))
// 包装成maker
this.covers = ele.data.map(item=>{
let iconPath;
if(item.siteChannel === 'LV'){
iconPath ='../../static/img/LV.png';
}else if(item.siteChannel == 'TY'){
iconPath ='../../static/img/change_TY.png';
}else if(item.siteChannel == 'WJY'){
iconPath ='../../static/img/WJY.png';
}else if(item.siteChannel == 'XOIL'){
iconPath ='../../static/img/XOIL.png';
}else if(item.siteChannel == 'YDJY'){
iconPath ='../../static/img/YDJY.png';
}
// item.distance= item.distance.toFixed(1);
console.log('这里是id',item.id,typeof(item.id))
let result = {
id: Number(item.id.substr(0,8)),
siteId: item.id,
latitude: item.latitude,
longitude: item.longitude,
iconPath: iconPath,
width: 80,
height: 26,
label: { //为标记点旁边增加标签
content: 'test', //文本
color: '#FFFFFF', //文本颜色
anchorX: -5, //label的坐标,原点是 marker 对应的经纬度
anchorY: -25 //label的坐标,原点是 marker 对应的经纬度
}
}
return result
})
console.log('this.covers',this.covers)
if(this.filterCondition != null && this.filterCondition != ''){
console.log("过滤数据")
console.log(this.filterCondition)
// this.filterCondition.distance = 3
this.filterRes(this.filterCondition)
}
})
}
}
}
}
</script>
<style scoped>
.flex-style{
display: -webkit-box;
display: -webkit-flex;
display: flex;
}
.flex-item{
height: 35px;
line-height: 35px;
text-align: center;
-webkit-box-flex: 1;
-webkit-flex: 1;
flex: 1
}
.flex-item.active{
color:#0091ff;
}
.map_box{
position:absolute;
top:0;
bottom: 0;
left: 0px;
right: 0px;
}
#navi_map{
width: 100%;
height: 100%;
}
.site_info{
position:absolute;
background-color: #FFFFFF;
height: 120px!important;
bottom: 0px;
left: 0px;
right: 0px;
transition: all ease-in-out 700ms;
}
.site_info{
padding: 10rpx 12rpx;
}
.text_box .text{
margin: 25px;
}
.detail_button{
position:absolute;
bottom: 30px;
right: 10px;
padding: 3px 5px;
color: #fff;
background: #0091ff;
width:50px;
text-align:center;
border-radius:5px;
}
.filter-container{
position:absolute;
top: 145rpx;
height: 72rpx;
left: 0px;
right: 0px;
z-index: 1111;
}
.actions{
display: flex;
justify-content: space-around;
margin-top: 20rpx;
}
.actions view{
width: 200rpx;
height: 50rpx;
background-color: #FF0000;
text-align: center;
color: #FFFFFF;
padding: 7rpx 29rpx;
border-radius: 12rpx;
}
.siteName{
font-weight: 600;
font-size: 35rpx;
line-height: 2;
margin: 0 17rpx;
}
.distances{
position:absolute;
right: 25rpx;
top: 55rpx;
color: #FE0505;
}
.address_info{
font-size: 25rpx;
line-height: 2;
white-space: nowrap;
text-overflow:ellipsis;
overflow:hidden;
width: 70%;
margin: 0 17rpx;
}
.inner_container{
margin-top: 10px;
position: relative;
}
.close{
position:absolute;
right: 29rpx;
top: 20rpx;
transform: scale(2);
}
</style>