Merge remote-tracking branch 'origin/master'

pull/69/MERGE
YunaiV 2024-08-08 13:05:00 +08:00
commit a9739208f8
3 changed files with 59 additions and 58 deletions

View File

@ -32,7 +32,7 @@
</view>
<!-- #endif -->
</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-else></text>
<view class="iconfont">
@ -55,13 +55,11 @@
const LONGITUDE = 'user_longitude';
const LATITUDE = 'user_latitude';
const MAPKEY = 'mapKey';
const state = reactive({
loaded: false,
loading: false,
storeList: [],
system_store: {},
// mapKey: cookie.get(MAPKEY),
locationShow: false,
user_latitude: 0,
user_longitude: 0,
@ -73,61 +71,62 @@
});
};
const selfLocation = () => {
// TODO h5
// #ifdef H5
// if (state.$wechat.isWeixin()) {
// state.$wechat.location().then(res => {
// state.user_latitude = res.latitude;
// state.user_longitude = res.longitude;
// uni.setStorageSync(LATITUDE, res.latitude);
// uni.setStorageSync(LONGITUDE, res.longitude);
// getList();
// });
// } 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 {
}
const jsWxSdk = sheep.$platform.useProvider('wechat').jsWxSdk;
if (jsWxSdk.isWechat()) {
jsWxSdk.getLocation((res) => {
console.log(res);
state.user_latitude = res.latitude;
state.user_longitude = res.longitude;
uni.setStorageSync(LATITUDE, res.latitude);
uni.setStorageSync(LONGITUDE, res.longitude);
getList();
},
complete: () => {
getList();
},
});
// #ifdef H5
// }
});
} 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();
},
complete: () => {
getList();
},
});
// #ifdef H5
}
// #endif
};
const showMaoLocation = (e) => {
// TODO h5
// #ifdef H5
// if (state.$wechat.isWeixin()) {
// state.$wechat.seeLocation({
// latitude: Number(e.latitude),
// longitude: Number(e.longitude),
// }).then(res => {
// console.log('success');
// });
// } else {
// #endif
uni.openLocation({
latitude: Number(e.latitude),
longitude: Number(e.longitude),
name: e.name,
address: `${e.areaName}-${e.detailAddress}`,
success: function() {
console.log('success');
},
});
// #ifdef H5
// }
const jsWxSdk = sheep.$platform.useProvider('wechat').jsWxSdk;
if (jsWxSdk.isWechat()) {
jsWxSdk.openLocation({
latitude: Number(e.latitude),
longitude: Number(e.longitude),
name: e.name,
address: `${e.areaName}-${e.detailAddress}`
});
} else {
// #endif
uni.openLocation({
latitude: Number(e.latitude),
longitude: Number(e.longitude),
name: e.name,
address: `${e.areaName}-${e.detailAddress}`,
success: function() {
console.log('success');
},
});
// #ifdef H5
}
// #endif
};

View File

@ -1,9 +1,10 @@
/**
* 本模块封装微信浏览器下的一些方法
* 更多微信网页开发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 AuthUtil from '@/sheep/api/member/auth';
@ -38,7 +39,7 @@ export default {
timestamp: data.timestamp,
nonceStr: data.nonceStr,
signature: data.signature,
jsApiList: ['chooseWXPay'], // TODO 芋艿:后续可以设置更多权限;
jsApiList: ['chooseWXPay', 'openLocation', 'getLocation','updateTimelineShareData','scanQRCode'], // TODO 芋艿:后续可以设置更多权限;
openTagList: data.openTagList
});
}
@ -137,9 +138,10 @@ export default {
openLocation(data, callback) {
this.isReady(() => {
jweixin.openLocation({
//根据传入的坐标打开地图
latitude: data.latitude,
longitude: data.longitude,
...data,
success: function (res) {
console.log(res);
}
});
});
},

View File

@ -103,5 +103,5 @@ export default {
unbind,
getInfo,
getOpenid,
jssdk: $wxsdk,
jsWxSdk: $wxsdk,
};