commit
2b5a06174f
|
@ -32,7 +32,7 @@
|
||||||
</view>
|
</view>
|
||||||
<!-- #endif -->
|
<!-- #endif -->
|
||||||
</view>
|
</view>
|
||||||
<view class="store-distance ss-flex ss-row-center" @tap="showMaoLocation(item)">
|
<view class="store-distance ss-flex ss-row-center" @tap.stop="showMaoLocation(item)">
|
||||||
<text class="addressTxt" v-if="item.distance">距离{{ item.distance.toFixed(2) }}千米</text>
|
<text class="addressTxt" v-if="item.distance">距离{{ item.distance.toFixed(2) }}千米</text>
|
||||||
<text class="addressTxt" v-else>查看地图</text>
|
<text class="addressTxt" v-else>查看地图</text>
|
||||||
<view class="iconfont">
|
<view class="iconfont">
|
||||||
|
@ -55,13 +55,11 @@
|
||||||
|
|
||||||
const LONGITUDE = 'user_longitude';
|
const LONGITUDE = 'user_longitude';
|
||||||
const LATITUDE = 'user_latitude';
|
const LATITUDE = 'user_latitude';
|
||||||
const MAPKEY = 'mapKey';
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
loaded: false,
|
loaded: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
storeList: [],
|
storeList: [],
|
||||||
system_store: {},
|
system_store: {},
|
||||||
// mapKey: cookie.get(MAPKEY),
|
|
||||||
locationShow: false,
|
locationShow: false,
|
||||||
user_latitude: 0,
|
user_latitude: 0,
|
||||||
user_longitude: 0,
|
user_longitude: 0,
|
||||||
|
@ -73,61 +71,62 @@
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const selfLocation = () => {
|
const selfLocation = () => {
|
||||||
// TODO h5 地图
|
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
// if (state.$wechat.isWeixin()) {
|
const jsWxSdk = sheep.$platform.useProvider('wechat').jsWxSdk;
|
||||||
// state.$wechat.location().then(res => {
|
if (jsWxSdk.isWechat()) {
|
||||||
// state.user_latitude = res.latitude;
|
jsWxSdk.getLocation((res) => {
|
||||||
// state.user_longitude = res.longitude;
|
console.log(res);
|
||||||
// uni.setStorageSync(LATITUDE, res.latitude);
|
state.user_latitude = res.latitude;
|
||||||
// uni.setStorageSync(LONGITUDE, res.longitude);
|
state.user_longitude = res.longitude;
|
||||||
// getList();
|
uni.setStorageSync(LATITUDE, res.latitude);
|
||||||
// });
|
uni.setStorageSync(LONGITUDE, res.longitude);
|
||||||
// } else {
|
|
||||||
// #endif
|
|
||||||
uni.getLocation({
|
|
||||||
type: 'gcj02',
|
|
||||||
success: (res) => {
|
|
||||||
try {
|
|
||||||
state.user_latitude = res.latitude;
|
|
||||||
state.user_longitude = res.longitude;
|
|
||||||
uni.setStorageSync(LATITUDE, res.latitude);
|
|
||||||
uni.setStorageSync(LONGITUDE, res.longitude);
|
|
||||||
} catch {
|
|
||||||
}
|
|
||||||
getList();
|
getList();
|
||||||
},
|
});
|
||||||
complete: () => {
|
} else {
|
||||||
getList();
|
// #endif
|
||||||
},
|
uni.getLocation({
|
||||||
});
|
type: 'gcj02',
|
||||||
// #ifdef H5
|
success: (res) => {
|
||||||
// }
|
try {
|
||||||
|
state.user_latitude = res.latitude;
|
||||||
|
state.user_longitude = res.longitude;
|
||||||
|
uni.setStorageSync(LATITUDE, res.latitude);
|
||||||
|
uni.setStorageSync(LONGITUDE, res.longitude);
|
||||||
|
} catch {
|
||||||
|
}
|
||||||
|
getList();
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
getList();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// #ifdef H5
|
||||||
|
}
|
||||||
// #endif
|
// #endif
|
||||||
};
|
};
|
||||||
const showMaoLocation = (e) => {
|
const showMaoLocation = (e) => {
|
||||||
// TODO h5 地图
|
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
// if (state.$wechat.isWeixin()) {
|
const jsWxSdk = sheep.$platform.useProvider('wechat').jsWxSdk;
|
||||||
// state.$wechat.seeLocation({
|
if (jsWxSdk.isWechat()) {
|
||||||
// latitude: Number(e.latitude),
|
jsWxSdk.openLocation({
|
||||||
// longitude: Number(e.longitude),
|
latitude: Number(e.latitude),
|
||||||
// }).then(res => {
|
longitude: Number(e.longitude),
|
||||||
// console.log('success');
|
name: e.name,
|
||||||
// });
|
address: `${e.areaName}-${e.detailAddress}`
|
||||||
// } else {
|
});
|
||||||
// #endif
|
} else {
|
||||||
uni.openLocation({
|
// #endif
|
||||||
latitude: Number(e.latitude),
|
uni.openLocation({
|
||||||
longitude: Number(e.longitude),
|
latitude: Number(e.latitude),
|
||||||
name: e.name,
|
longitude: Number(e.longitude),
|
||||||
address: `${e.areaName}-${e.detailAddress}`,
|
name: e.name,
|
||||||
success: function() {
|
address: `${e.areaName}-${e.detailAddress}`,
|
||||||
console.log('success');
|
success: function() {
|
||||||
},
|
console.log('success');
|
||||||
});
|
},
|
||||||
// #ifdef H5
|
});
|
||||||
// }
|
// #ifdef H5
|
||||||
|
}
|
||||||
// #endif
|
// #endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
/**
|
/**
|
||||||
* 本模块封装微信浏览器下的一些方法。
|
* 本模块封装微信浏览器下的一些方法。
|
||||||
* 更多微信网页开发sdk方法,详见:https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html
|
* 更多微信网页开发sdk方法,详见:https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html
|
||||||
|
* 有 the permission value is offline verifying 报错请参考 @see https://segmentfault.com/a/1190000042289419 解决
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import jweixin, { ready } from 'weixin-js-sdk';
|
import jweixin from 'weixin-js-sdk';
|
||||||
import $helper from '@/sheep/helper';
|
import $helper from '@/sheep/helper';
|
||||||
import AuthUtil from '@/sheep/api/member/auth';
|
import AuthUtil from '@/sheep/api/member/auth';
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ export default {
|
||||||
timestamp: data.timestamp,
|
timestamp: data.timestamp,
|
||||||
nonceStr: data.nonceStr,
|
nonceStr: data.nonceStr,
|
||||||
signature: data.signature,
|
signature: data.signature,
|
||||||
jsApiList: ['chooseWXPay'], // TODO 芋艿:后续可以设置更多权限;
|
jsApiList: ['chooseWXPay', 'openLocation', 'getLocation','updateTimelineShareData','scanQRCode'], // TODO 芋艿:后续可以设置更多权限;
|
||||||
openTagList: data.openTagList
|
openTagList: data.openTagList
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -137,9 +138,10 @@ export default {
|
||||||
openLocation(data, callback) {
|
openLocation(data, callback) {
|
||||||
this.isReady(() => {
|
this.isReady(() => {
|
||||||
jweixin.openLocation({
|
jweixin.openLocation({
|
||||||
//根据传入的坐标打开地图
|
...data,
|
||||||
latitude: data.latitude,
|
success: function (res) {
|
||||||
longitude: data.longitude,
|
console.log(res);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -103,5 +103,5 @@ export default {
|
||||||
unbind,
|
unbind,
|
||||||
getInfo,
|
getInfo,
|
||||||
getOpenid,
|
getOpenid,
|
||||||
jssdk: $wxsdk,
|
jsWxSdk: $wxsdk,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue