1
This commit is contained in:
parent
960d43ba01
commit
a197797f9b
14
src/App.vue
14
src/App.vue
@ -111,13 +111,13 @@ export default {
|
|||||||
wx.ready(() => {
|
wx.ready(() => {
|
||||||
wx.updateAppMessageShareData(shareinfo);
|
wx.updateAppMessageShareData(shareinfo);
|
||||||
wx.updateTimelineShareData(shareinfo);
|
wx.updateTimelineShareData(shareinfo);
|
||||||
wx.getLocation({
|
// wx.getLocation({
|
||||||
type: 'gcj02',
|
// type: 'gcj02',
|
||||||
success: (e) => {
|
// success: (e) => {
|
||||||
localStorage.setItem('user_latitude', e.latitude)
|
// localStorage.setItem('user_latitude', e.latitude)
|
||||||
localStorage.setItem('user_longitude', e.longitude)
|
// localStorage.setItem('user_longitude', e.longitude)
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
});
|
});
|
||||||
wx.error((e) => {
|
wx.error((e) => {
|
||||||
});
|
});
|
||||||
|
|||||||
@ -85,51 +85,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
if (wx && this.$isWechat()) {
|
this.initLocation();
|
||||||
let url = 'https://m.taigurun.cn'
|
|
||||||
this.$post('/v1/client/HWxinfoClient/share', JSON.stringify(url)).then(res => {
|
|
||||||
const data = res.data || {};
|
|
||||||
const jsApiList = data.jsApiList || ['onMenuShareTimeline', 'onMenuShareAppMessage', 'updateAppMessageShareData', 'updateTimelineShareData', 'openLocation', 'getLocation'];
|
|
||||||
const openTagList = data.openTagList || ['wx-open-launch-weapp'];
|
|
||||||
jsApiList.push('wx-open-launch-weapp');
|
|
||||||
wx.config({
|
|
||||||
debug: false,
|
|
||||||
appId: data.appid,
|
|
||||||
timestamp: Number(data.timestamp) || 0,
|
|
||||||
nonceStr: data.noncestr,
|
|
||||||
signature: data.signature,
|
|
||||||
jsApiList: jsApiList,
|
|
||||||
openTagList: openTagList
|
|
||||||
});
|
|
||||||
wx.ready(() => {
|
|
||||||
wx.getLocation({
|
|
||||||
type: 'gcj02',
|
|
||||||
success: (e) => {
|
|
||||||
this.searchparams.latitude = e.latitude;
|
|
||||||
this.searchparams.longitude = e.longitude;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
wx.error((e) => {
|
|
||||||
// window.location.reload();
|
|
||||||
if (localStorage.getItem('latitude') && localStorage.getItem('longitude')) {
|
|
||||||
this.searchparams.latitude = localStorage.getItem('latitude');
|
|
||||||
this.searchparams.longitude = localStorage.getItem('longitude');
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
// this.$geo.getWebGeo().then(res => {
|
|
||||||
// this.searchparams.latitude = res.lat;
|
|
||||||
// this.searchparams.longitude = res.lon;
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.$geo.getWebGeo().then(res => {
|
|
||||||
this.searchparams.latitude = res.lat;
|
|
||||||
this.searchparams.longitude = res.lon;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.init();
|
this.init();
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.checkScroll();
|
this.checkScroll();
|
||||||
@ -188,6 +144,55 @@ export default {
|
|||||||
onSearchInput() {
|
onSearchInput() {
|
||||||
this.searchparams.shopname = this.searchQuery;
|
this.searchparams.shopname = this.searchQuery;
|
||||||
},
|
},
|
||||||
|
initLocation() {
|
||||||
|
if (wx && this.$isWechat()) {
|
||||||
|
this.$post('/v1/client/HWxinfoClient/share', JSON.stringify(location.href)).then(res => {
|
||||||
|
const data = res.data || {};
|
||||||
|
const jsApiList = data.jsApiList || ['getLocation'];
|
||||||
|
const openTagList = data.openTagList || ['wx-open-launch-weapp'];
|
||||||
|
jsApiList.push('wx-open-launch-weapp');
|
||||||
|
wx.config({
|
||||||
|
debug: false,
|
||||||
|
appId: data.appid,
|
||||||
|
timestamp: Number(data.timestamp) || 0,
|
||||||
|
nonceStr: data.noncestr,
|
||||||
|
signature: data.signature,
|
||||||
|
jsApiList: jsApiList,
|
||||||
|
openTagList: openTagList
|
||||||
|
});
|
||||||
|
wx.ready(() => {
|
||||||
|
wx.getLocation({
|
||||||
|
type: 'gcj02',
|
||||||
|
success: (e) => {
|
||||||
|
this.searchparams.latitude = e.latitude;
|
||||||
|
this.searchparams.longitude = e.longitude;
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.log('定位失败:', err)
|
||||||
|
// this.$showToast('定位被拒绝,请重新进入页面获取定位')
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
wx.error((e) => {
|
||||||
|
if (localStorage.getItem('latitude') && localStorage.getItem('longitude')) {
|
||||||
|
this.searchparams.latitude = localStorage.getItem('latitude');
|
||||||
|
this.searchparams.longitude = localStorage.getItem('longitude');
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
this.$geo.getWebGeo().then(res => {
|
||||||
|
this.searchparams.latitude = res.lat;
|
||||||
|
this.searchparams.longitude = res.lon;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.$geo.getWebGeo().then(res => {
|
||||||
|
this.searchparams.latitude = res.lat;
|
||||||
|
this.searchparams.longitude = res.lon;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@ -74,7 +74,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.init()
|
this.init();
|
||||||
|
this.initLocation();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
@ -93,6 +94,37 @@ export default {
|
|||||||
this.$showImagePreview({ images: [imageUrl], startPosition: 0 });
|
this.$showImagePreview({ images: [imageUrl], startPosition: 0 });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
initLocation() {
|
||||||
|
if (wx && this.$isWechat()) {
|
||||||
|
this.$post('/v1/client/HWxinfoClient/share', JSON.stringify(location.href)).then(res => {
|
||||||
|
const data = res.data || {};
|
||||||
|
const jsApiList = data.jsApiList || ['getLocation', 'openLocation'];
|
||||||
|
const openTagList = data.openTagList || ['wx-open-launch-weapp'];
|
||||||
|
jsApiList.push('wx-open-launch-weapp');
|
||||||
|
wx.config({
|
||||||
|
debug: false,
|
||||||
|
appId: data.appid,
|
||||||
|
timestamp: Number(data.timestamp) || 0,
|
||||||
|
nonceStr: data.noncestr,
|
||||||
|
signature: data.signature,
|
||||||
|
jsApiList: jsApiList,
|
||||||
|
openTagList: openTagList
|
||||||
|
});
|
||||||
|
// 预获取定位权限,用户点击地图时可以直接打开
|
||||||
|
// wx.ready(() => {
|
||||||
|
// wx.getLocation({
|
||||||
|
// type: 'gcj02',
|
||||||
|
// success: () => {
|
||||||
|
// console.log('定位权限获取成功');
|
||||||
|
// },
|
||||||
|
// fail: () => {
|
||||||
|
// console.log('定位权限获取失败');
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
openMap() {
|
openMap() {
|
||||||
if (this.shopInfo.shoplatitude && this.shopInfo.shoplongitude) {
|
if (this.shopInfo.shoplatitude && this.shopInfo.shoplongitude) {
|
||||||
const lat = this.shopInfo.shoplatitude;
|
const lat = this.shopInfo.shoplatitude;
|
||||||
@ -105,20 +137,6 @@ export default {
|
|||||||
(this.shopInfo.shopaddress || '')
|
(this.shopInfo.shopaddress || '')
|
||||||
);
|
);
|
||||||
if (wx && this.$isWechat()) {
|
if (wx && this.$isWechat()) {
|
||||||
this.$post('/v1/client/HWxinfoClient/share', JSON.stringify(location.href)).then(res => {
|
|
||||||
const data = res.data || {};
|
|
||||||
const jsApiList = data.jsApiList || ['openLocation'];
|
|
||||||
const openTagList = data.openTagList || ['wx-open-launch-weapp'];
|
|
||||||
jsApiList.push('wx-open-launch-weapp');
|
|
||||||
wx.config({
|
|
||||||
debug: false,
|
|
||||||
appId: data.appid,
|
|
||||||
timestamp: Number(data.timestamp) || 0,
|
|
||||||
nonceStr: data.noncestr,
|
|
||||||
signature: data.signature,
|
|
||||||
jsApiList: jsApiList,
|
|
||||||
openTagList: openTagList
|
|
||||||
});
|
|
||||||
wx.ready(() => {
|
wx.ready(() => {
|
||||||
wx.openLocation({
|
wx.openLocation({
|
||||||
latitude: Number(lat),
|
latitude: Number(lat),
|
||||||
@ -132,11 +150,10 @@ export default {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
} else {
|
} else {
|
||||||
window.open(`https://uri.amap.com/navigation?to=${lon},${lat},${fullAddress}&mode=car&src=shop`, '_blank');
|
window.open(`https://uri.amap.com/navigation?to=${lon},${lat},${fullAddress}&mode=car&src=shop`, '_blank');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user