|
|
@@ -1,9 +1,8 @@
|
|
|
-import wxJs from "jweixin-module"
|
|
|
-import jWeixin from "wecomjsdk"
|
|
|
+
|
|
|
import {
|
|
|
Base64
|
|
|
} from '@/js_sdk/js-base64/base64';
|
|
|
-import {getWxJsSign} from "@/api/weChat";
|
|
|
+
|
|
|
|
|
|
let tools = {}
|
|
|
/**
|
|
|
@@ -233,84 +232,7 @@ tools.setLoginData = function (data) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-/**
|
|
|
- * 微信JSDK授权
|
|
|
- * @param jsApiList
|
|
|
- * @returns {Promise<*>}
|
|
|
- */
|
|
|
-tools.wxInitialize = async function (jsApiList) {
|
|
|
-
|
|
|
- return await getWxJsSign({ 'url': window.location.href,'type':1 }).then((ret) => {
|
|
|
- if (ret.code === 1) {
|
|
|
- wxJs.config({
|
|
|
- beta: true,// 必须这么写,否则wx.invoke调用形式的jsapi会有问题
|
|
|
- debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
|
|
- appId: ret.data.appId, // 必填,企业微信的corpID,必须是本企业的corpID,不允许跨企业使用
|
|
|
- timestamp: ret.data.timestamp * 1, // 必填,生成签名的时间戳
|
|
|
- nonceStr: ret.data.noncestr, // 必填,生成签名的随机串
|
|
|
- signature: ret.data.signature,// 必填,签名,见 附录-JS-SDK使用权限签名算法
|
|
|
- jsApiList: jsApiList,// 必填,需要使用的JS接口列表
|
|
|
- success: function(res) {
|
|
|
- console.log(res)
|
|
|
- console.log('config:---------------OK')
|
|
|
- tools.success('成功')
|
|
|
- },
|
|
|
- fail: function(res) {
|
|
|
- console.log('config-error')
|
|
|
- console.log(res)
|
|
|
- }
|
|
|
- });
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- })
|
|
|
-}
|
|
|
|
|
|
-/**
|
|
|
- * 企业微信信息授权
|
|
|
- * @param jsApiList
|
|
|
- * @returns {Promise<unknown>}
|
|
|
- */
|
|
|
-tools.wxAgentInitialize=async function (jsApiList){
|
|
|
-
|
|
|
- return await getWxJsSign({ 'url': window.location.href ,'type':2}).then((ret) => {
|
|
|
- if (ret.code === 1) {
|
|
|
- jWeixin.agentConfig({
|
|
|
- corpid: ret.data.appId, // 必填,企业微信的corpID,必须是本企业的corpID,不允许跨企业使用
|
|
|
- agentid: ret.data.agentid, // 必填,企业微信的应用id (e.g. 1000247)
|
|
|
- timestamp: ret.data.timestamp * 1, // 必填,生成签名的时间戳
|
|
|
- nonceStr: ret.data.noncestr, // 必填,生成签名的随机串
|
|
|
- signature: ret.data.signature,// 必填,签名,见 附录-JS-SDK使用权限签名算法
|
|
|
- jsApiList: jsApiList,// 必填,需要使用的JS接口列表
|
|
|
- success: function(res) {
|
|
|
- console.log('agentConfig:---------------OK')
|
|
|
- console.log(res)
|
|
|
-
|
|
|
- },
|
|
|
- fail: function(res) {
|
|
|
- console.log('agentConfig-error')
|
|
|
- console.log(res)
|
|
|
- if(res.errMsg.indexOf('function not exist') > -1){
|
|
|
- alert('版本过低请升级')
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-tools.wxLogin = function () {
|
|
|
- console.log(Base64.encode('aaa'));
|
|
|
- // 微信浏览器
|
|
|
- let url = encodeURIComponent(window.location.href);
|
|
|
- window.location.href = `https://test-api.wealfavor.cn/api/weChat/wx?redirect_url=${Base64.encode(url)}`
|
|
|
-}
|
|
|
|
|
|
|
|
|
export default tools
|