Commit bc24ba05 by zhujian

fix

parent 80d0e654
...@@ -15,11 +15,9 @@ import Service from '@/common/js/service'; ...@@ -15,11 +15,9 @@ import Service from '@/common/js/service';
export default class WechatApi { export default class WechatApi {
static async initConfig(params = { isAgentConfig: false, url: '' }) { static async initConfig(params = { isAgentConfig: false, url: '' }) {
if (Platform.isWorkWx()) { if (Platform.isWorkWx()) {
return new Promise(async (resolve, reject) => {
Service.Hades('anon/hades/getWxCorpJSAPISignature', { Service.Hades('anon/hades/getWxCorpJSAPISignature', {
storeId: User.getStoreId(), storeId: User.getStoreId(),
url:window.location.href.split('#')[0], url: window.location.href.split('#')[0],
}).then((result) => { }).then((result) => {
const res = result.result; const res = result.result;
wx.config({ wx.config({
...@@ -29,20 +27,15 @@ export default class WechatApi { ...@@ -29,20 +27,15 @@ export default class WechatApi {
timestamp: res.timestamp, // 必填,生成签名的时间戳 timestamp: res.timestamp, // 必填,生成签名的时间戳
nonceStr: res.nonceStr, // 必填,生成签名的随机串 nonceStr: res.nonceStr, // 必填,生成签名的随机串
signature: res.signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法 signature: res.signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法
jsApiList: ['chooseImage'], jsApiList: ['scanQRCode'],
})
wx.error((err) => {
console.log('getWxCorpJSAPISignatureErr', err)
}); });
})
wx.ready(() => { wx.ready(() => {
console.log('微信注册成功')
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],
}).then((result2) => { }).then((result2) => {
const res2 = result2.result; const res2 = result2.result;
console.log('开始注册agent')
wx.agentConfig({ wx.agentConfig({
corpid: res2.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致 corpid: res2.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致
agentid: res2.agentid, // 必填,企业微信的应用id (e.g. 1000247) agentid: res2.agentid, // 必填,企业微信的应用id (e.g. 1000247)
...@@ -51,35 +44,27 @@ export default class WechatApi { ...@@ -51,35 +44,27 @@ export default class WechatApi {
signature: res2.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法 signature: res2.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
jsApiList: ['selectExternalContact', 'getCurExternalContact', 'getContext', 'shareToExternalContact', 'sendChatMessage', 'shareToExternalChat', 'startLiving', 'replayLiving'], jsApiList: ['selectExternalContact', 'getCurExternalContact', 'getContext', 'shareToExternalContact', 'sendChatMessage', 'shareToExternalChat', 'startLiving', 'replayLiving'],
success: (res) => { success: (res) => {
console.log(res, 'res-agentconfig'); console.log(res, 'agentConfig 成功', 'res-agentconfig');
console.info('window.WWOpenData', window.WWOpenData);
resolve(res); resolve(res);
}, },
fail: (err) => { fail: (err) => {
console.log(1213545344545) console.log(1213545344545)
console.log(err, 'err-agentconfig'); console.log(err, 'err-agentconfig');
reject(err);
}, },
}); });
}); });
})
}); });
}) wx.error((err) => {
console.log('getWxCorpJSAPISignature', err)
});
} else { } else {
if (params.isAgentConfig) {
console.log(32132132, 'cesgu')
return new Promise(async (resolve, reject) => {
Service.Hades('anon/hades/getWxWorkJSAPISignature', { Service.Hades('anon/hades/getWxWorkJSAPISignature', {
storeId: User.getStoreId(), storeId: User.getStoreId(),
url: params.url, url: window.location.href.split('#')[0],
}).then((result2) => { }).then((result2) => {
const res2 = result2.result; const res2 = result2.result;
this.agentConfig({ wx.agentConfig({
corpid: res2.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致 corpid: res2.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致
agentid: res2.agentid, // 必填,企业微信的应用id (e.g. 1000247) agentid: res2.agentid, // 必填,企业微信的应用id (e.g. 1000247)
timestamp: res2.timestamp, // 必填,生成签名的时间戳 timestamp: res2.timestamp, // 必填,生成签名的时间戳
...@@ -87,48 +72,19 @@ export default class WechatApi { ...@@ -87,48 +72,19 @@ export default class WechatApi {
signature: res2.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法 signature: res2.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
jsApiList: ['selectExternalContact', 'getCurExternalContact', 'getContext', 'shareToExternalContact', 'sendChatMessage', 'shareToExternalChat', 'startLiving', 'replayLiving'], jsApiList: ['selectExternalContact', 'getCurExternalContact', 'getContext', 'shareToExternalContact', 'sendChatMessage', 'shareToExternalChat', 'startLiving', 'replayLiving'],
success: (res) => { success: (res) => {
console.log(res, 'res-agentconfig'); console.log(res, 'agentConfig 成功', 'res-agentconfig');
console.info('window.WWOpenData', window.WWOpenData);
resolve(res); resolve(res);
}, },
fail: (err) => { fail: (err) => {
console.log(1213545344545) console.log(1213545344545)
console.log(err, 'err-agentconfig'); console.log(err, 'err-agentconfig');
reject(err);
}, },
}); });
}); });
});
}
} }
}
static async config(config) {
return new Promise((resolve, reject) => {
wx.config(config);
wx.ready(resolve);
wx.error(reject);
})
}
static async agentConfig(config) {
wx.agentConfig({ ...config });
} }
static getCurExternalContact() {
return new Promise((resolve, reject) => {
wx.ready(() => {
wx.invoke('getCurExternalContact', {}, function (res) {
if (res.err_msg == 'getCurExternalContact:ok') {
resolve(res.userId); //返回当前外部联系人userId
} else {
reject(res.err_msg); //错误处理
}
});
});
});
}
static getContext() { static getContext() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
......
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