选择人员调整完毕
This commit is contained in:
@@ -5,7 +5,7 @@ import http from '../common/axios'
|
||||
import CryptoJS from '../utils/crypto-js'
|
||||
|
||||
Vue.use(Vuex)
|
||||
let agentSignURL = "", apiList = [], agentConfig = {}
|
||||
let agentSignURL = "", apiList = []
|
||||
const store = new Vuex.Store({
|
||||
state: {
|
||||
token: "",
|
||||
@@ -30,7 +30,7 @@ const store = new Vuex.Store({
|
||||
state.openUser = user
|
||||
},
|
||||
getConfig(state, params) {
|
||||
Object.keys(params).map(e => state[e] = params[e])
|
||||
state.config = params
|
||||
},
|
||||
bindAccount(state, params) {
|
||||
//具备解决二次登录,绑定手机,token等问题
|
||||
@@ -61,7 +61,7 @@ const store = new Vuex.Store({
|
||||
},
|
||||
redirectCode(state, url = location.href) {
|
||||
let REDIRECT_URI = encodeURIComponent(url),
|
||||
corpid = state.corpId || agentConfig?.corpid
|
||||
corpid = state.corpId
|
||||
const redirectTo = cid => {
|
||||
location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=CORPID&redirect_uri=REDIRECT_URI&response_type=code&scope=snsapi_base#wechat_redirect'
|
||||
.replace(/CORPID/g, cid)
|
||||
@@ -71,7 +71,7 @@ const store = new Vuex.Store({
|
||||
redirectTo(corpid)
|
||||
} else {
|
||||
store.dispatch("agentSign").then(() => {
|
||||
corpid = state.corpId || agentConfig?.corpid
|
||||
corpid = state.corpId
|
||||
redirectTo(corpid)
|
||||
})
|
||||
}
|
||||
@@ -198,7 +198,7 @@ const store = new Vuex.Store({
|
||||
})
|
||||
},
|
||||
getCode(store, url) {
|
||||
if (agentConfig?.corpid) {
|
||||
if (store.state.config?.corpid) {
|
||||
store.commit('redirectCode', url)
|
||||
} else {
|
||||
store.dispatch('agentSign').then(() => {
|
||||
@@ -232,17 +232,20 @@ const store = new Vuex.Store({
|
||||
})
|
||||
}
|
||||
},
|
||||
agentSign(state) {
|
||||
let url = window.location.href
|
||||
agentSign(state, params) {
|
||||
let url = window.location.href,
|
||||
{corpId, suiteId} = state.state.config
|
||||
if (agentSignURL == url) {
|
||||
return Promise.resolve()
|
||||
} else {
|
||||
agentSignURL = url
|
||||
return http.post("/app/wxcp/portal/agentSign", null, {
|
||||
params: {url}
|
||||
params = params || {corpId, suiteId}
|
||||
return http.post("/app/wxcptp/portal/agentSign", null, {
|
||||
params: {...params, url}
|
||||
}).then(res => {
|
||||
if (res?.data) {
|
||||
let params = {
|
||||
let config = {
|
||||
...params,
|
||||
debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
||||
beta: true,// 必须这么写,否则wx.invoke调用形式的jsapi会有问题
|
||||
corpid: res.data.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致
|
||||
@@ -252,8 +255,8 @@ const store = new Vuex.Store({
|
||||
signature: res.data.signature,// 必填,签名,见 附录-JS-SDK使用权限签名算法
|
||||
...res.data,
|
||||
}
|
||||
agentConfig = params
|
||||
state.commit("getConfig", {corpId: params.corpid})
|
||||
state.commit("getConfig", config)
|
||||
return config
|
||||
}
|
||||
}).catch(err => {
|
||||
console.error(err)
|
||||
@@ -261,11 +264,11 @@ const store = new Vuex.Store({
|
||||
}
|
||||
},
|
||||
injectJWeixin(state, ops) {
|
||||
const inject = jsApiList => new Promise((resolve, reject) => {
|
||||
const inject = (jsApiList, config = state.state.config) => new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
let sdk = wx?.agentConfig ? wx : jWeixin
|
||||
sdk?.agentConfig({
|
||||
...agentConfig, jsApiList,
|
||||
...config, jsApiList,
|
||||
success: res => resolve(res),
|
||||
fail: err => {
|
||||
console.error(err)
|
||||
@@ -275,7 +278,7 @@ const store = new Vuex.Store({
|
||||
}, 500)
|
||||
})
|
||||
return new Promise((resolve, reject) => {
|
||||
state.dispatch("agentSign").then(() => {
|
||||
state.dispatch("agentSign").then(config => {
|
||||
if (typeof ops == "object") {
|
||||
ops?.map(api => {
|
||||
if (!apiList?.includes(api)) apiList.push(api)
|
||||
@@ -283,7 +286,7 @@ const store = new Vuex.Store({
|
||||
} else {
|
||||
if (!apiList?.includes(ops)) apiList.push(ops)
|
||||
}
|
||||
inject(apiList).then(r => resolve(r)).catch(err => reject(err))
|
||||
inject(apiList, config).then(r => resolve(r)).catch(err => reject(err))
|
||||
})
|
||||
})
|
||||
},
|
||||
@@ -318,6 +321,27 @@ const store = new Vuex.Store({
|
||||
}, 500)
|
||||
})
|
||||
},
|
||||
selectEnterpriseContact(state) {
|
||||
return new Promise(resolve => {
|
||||
state.dispatch("injectJWeixin", "selectEnterpriseContact").then(() => {
|
||||
setTimeout(() => {
|
||||
let sdk = typeof wx?.invoke == 'function' ? wx : jWeixin
|
||||
sdk?.invoke("selectEnterpriseContact", {
|
||||
fromDepartmentId: -1,
|
||||
mode: "multi",
|
||||
type: ["user"]
|
||||
}, res => {
|
||||
if (res.err_msg == "selectEnterpriseContact:ok") {
|
||||
if (typeof res.result == 'string') {
|
||||
res.result = JSON.parse(res.result)
|
||||
}
|
||||
resolve(res.result)
|
||||
}
|
||||
})
|
||||
}, 500)
|
||||
})
|
||||
})
|
||||
},
|
||||
},
|
||||
getters: {
|
||||
getDict: state => key => {
|
||||
|
||||
Reference in New Issue
Block a user