123
This commit is contained in:
+48
-14
@@ -1,15 +1,49 @@
|
||||
export default {
|
||||
install(Vue){
|
||||
wx.config({
|
||||
debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
||||
appId: '', // 必填,公众号的唯一标识
|
||||
timestamp: 123, // 必填,生成签名的时间戳
|
||||
nonceStr: '', // 必填,生成签名的随机串
|
||||
signature: '',// 必填,签名
|
||||
jsApiList: [] // 必填,需要使用的JS接口列表
|
||||
});
|
||||
wx.ready(function(){
|
||||
Vue.prototype.$wx = wx;
|
||||
})
|
||||
// export default {
|
||||
// install(Vue){
|
||||
// wx.config({
|
||||
// debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
||||
// appId: '', // 必填,公众号的唯一标识
|
||||
// timestamp: 123, // 必填,生成签名的时间戳
|
||||
// nonceStr: '', // 必填,生成签名的随机串
|
||||
// signature: '',// 必填,签名
|
||||
// jsApiList: [] // 必填,需要使用的JS接口列表
|
||||
// });
|
||||
// wx.ready(function(){
|
||||
// Vue.prototype.$wx = wx;
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
let wechatInstance;
|
||||
|
||||
function signToWechat(config){
|
||||
if(!wx){
|
||||
console.warn('请安装微信网页JS-SDK, url: https://res2.wx.qq.com/open/js/jweixin-1.6.0.js');
|
||||
}
|
||||
}
|
||||
const defaultConfig = {
|
||||
debug: true,
|
||||
}
|
||||
return new Promise((resolve) => {
|
||||
wx.config({
|
||||
...defaultConfig,
|
||||
...config,
|
||||
})
|
||||
wx.ready(function(){
|
||||
console.warn('wechat sdk config success')
|
||||
wechatInstance = wx;
|
||||
resolve(wx)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function getLocation(){
|
||||
return new Promise(resolve => {
|
||||
wechatInstance.getLocation({
|
||||
type: 'wgs84',
|
||||
success: res => {
|
||||
resolve(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export { signToWechat, getLocation };
|
||||
Reference in New Issue
Block a user