Commit dfeb1b65 by zhujian

fix

parent 62df917a
...@@ -13,24 +13,59 @@ import User from '@/common/js/user'; ...@@ -13,24 +13,59 @@ import User from '@/common/js/user';
import Service from '@/common/js/service'; import Service from '@/common/js/service';
export default class WechatApi { export default class WechatApi {
static async initConfig(params = { isAgentConfig: false, url: '' }) { static initConfig(params = { isAgentConfig: false, url: '' }) {
if (Platform.isWorkWx()) { if (Platform.isWorkWx()) {
Service.Hades('anon/hades/getWxCorpJSAPISignature', { return new Promise(async (resolve, reject) => {
storeId: User.getStoreId(), Service.Hades('anon/hades/getWxCorpJSAPISignature', {
url: window.location.href.split('#')[0], storeId: User.getStoreId(),
}).then((result) => { url: window.location.href.split('#')[0],
const res = result.result; }).then((result) => {
wx.config({ const res = result.result;
beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题 wx.config({
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
appId: res.appId, // 必填,企业微信的corpID debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
timestamp: res.timestamp, // 必填,生成签名的时间戳 appId: res.appId, // 必填,企业微信的corpID
nonceStr: res.nonceStr, // 必填,生成签名的随机串 timestamp: res.timestamp, // 必填,生成签名的时间戳
signature: res.signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法 nonceStr: res.nonceStr, // 必填,生成签名的随机串
jsApiList: ['scanQRCode'], signature: res.signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法
jsApiList: ['scanQRCode'],
});
})
wx.ready(() => {
Service.Hades('anon/hades/getWxWorkJSAPISignature', {
storeId: User.getStoreId(),
url: window.location.href.split('#')[0],
}).then((result2) => {
const res2 = result2.result;
wx.agentConfig({
corpid: res2.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致
agentid: res2.agentid, // 必填,企业微信的应用id (e.g. 1000247)
timestamp: res2.timestamp, // 必填,生成签名的时间戳
nonceStr: res2.nonceStr, // 必填,生成签名的随机串
signature: res2.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
jsApiList: ['selectExternalContact', 'getCurExternalContact', 'getContext', 'shareToExternalContact', 'sendChatMessage', 'shareToExternalChat', 'startLiving', 'replayLiving'],
success: (res) => {
console.log(res, 'agentConfig 成功', 'res-agentconfig');
resolve(res);
},
fail: (err) => {
console.log(1213545344545)
console.log(err, 'err-agentconfig');
},
});
});
}); });
wx.error((err) => {
console.log('getWxCorpJSAPISignature', err)
});
}) })
wx.ready(() => {
} else {
return new Promise(async (resolve, reject) => {
Service.Hades('anon/hades/getWxWorkJSAPISignature', { Service.Hades('anon/hades/getWxWorkJSAPISignature', {
storeId: User.getStoreId(), storeId: User.getStoreId(),
url: window.location.href.split('#')[0], url: window.location.href.split('#')[0],
...@@ -55,33 +90,6 @@ export default class WechatApi { ...@@ -55,33 +90,6 @@ export default class WechatApi {
}); });
}); });
}); });
wx.error((err) => {
console.log('getWxCorpJSAPISignature', err)
});
} else {
Service.Hades('anon/hades/getWxWorkJSAPISignature', {
storeId: User.getStoreId(),
url: window.location.href.split('#')[0],
}).then((result2) => {
const res2 = result2.result;
wx.agentConfig({
corpid: res2.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致
agentid: res2.agentid, // 必填,企业微信的应用id (e.g. 1000247)
timestamp: res2.timestamp, // 必填,生成签名的时间戳
nonceStr: res2.nonceStr, // 必填,生成签名的随机串
signature: res2.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
jsApiList: ['selectExternalContact', 'getCurExternalContact', 'getContext', 'shareToExternalContact', 'sendChatMessage', 'shareToExternalChat', 'startLiving', 'replayLiving'],
success: (res) => {
console.log(res, 'agentConfig 成功', 'res-agentconfig');
resolve(res);
},
fail: (err) => {
console.log(1213545344545)
console.log(err, 'err-agentconfig');
},
});
});
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment