This commit is contained in:
2021-11-04 21:20:31 +08:00
parent c5c2f661a0
commit ec0724c873
38 changed files with 6870 additions and 189 deletions
+48 -14
View File
@@ -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 };