群体优化企微jssdk api调用
This commit is contained in:
@@ -262,15 +262,18 @@ export const wxwork = {
|
|||||||
})
|
})
|
||||||
return inject([apis].flat().filter(Boolean))
|
return inject([apis].flat().filter(Boolean))
|
||||||
},
|
},
|
||||||
previewFile({dispatch, state}, op) {
|
injectSDK({dispatch, state}, apis) {
|
||||||
|
const {corpId, suiteId} = state.config
|
||||||
|
return dispatch('agentSign', {corpId, suiteId}).then(() => dispatch("injectJWeixin", [apis].flat()))
|
||||||
|
},
|
||||||
|
previewFile({dispatch}, op) {
|
||||||
if (window.navigator.userAgent.indexOf("Windows NT") > -1) {
|
if (window.navigator.userAgent.indexOf("Windows NT") > -1) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "企业微信暂不支持PC端的预览文件!",
|
title: "企业微信暂不支持PC端的预览文件!",
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
const {corpId, suiteId} = state.config
|
dispatch("injectSDK", "previewFile").then(() => {
|
||||||
dispatch('agentSign', {corpId, suiteId}).then(() => dispatch("injectJWeixin", "previewFile")).then(() => {
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
let sdk = typeof wx?.invoke == 'function' ? wx : jWeixin
|
let sdk = typeof wx?.invoke == 'function' ? wx : jWeixin
|
||||||
sdk?.invoke('previewFile', {...op}, res => {
|
sdk?.invoke('previewFile', {...op}, res => {
|
||||||
@@ -280,19 +283,17 @@ export const wxwork = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
closeAgent({dispatch, state}) {
|
closeAgent({dispatch}) {
|
||||||
const {corpId, suiteId} = state.config
|
dispatch("injectSDK", "closeWindow").then(() => {
|
||||||
dispatch('agentSign', {corpId, suiteId}).then(() => dispatch("injectJWeixin", "closeWindow")).then(() => {
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
let sdk = typeof wx?.closeWindow == 'function' ? wx : jWeixin
|
let sdk = typeof wx?.closeWindow == 'function' ? wx : jWeixin
|
||||||
sdk?.closeWindow()
|
sdk?.closeWindow()
|
||||||
}, 500)
|
}, 500)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
selectEnterpriseContact({dispatch, state}, params) {
|
selectEnterpriseContact({dispatch}, params) {
|
||||||
const {corpId, suiteId} = state.config
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
dispatch('agentSign', {corpId, suiteId}).then(() => dispatch("injectJWeixin", "selectEnterpriseContact")).then(() => {
|
dispatch("injectSDK", "selectEnterpriseContact").then(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
let sdk = typeof wx?.invoke == 'function' ? wx : jWeixin
|
let sdk = typeof wx?.invoke == 'function' ? wx : jWeixin
|
||||||
sdk?.invoke("selectEnterpriseContact", {
|
sdk?.invoke("selectEnterpriseContact", {
|
||||||
@@ -314,10 +315,9 @@ export const wxwork = {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
selectPrivilegedContact({dispatch, state}, params) {
|
selectPrivilegedContact({dispatch}, params) {
|
||||||
const {corpId, suiteId} = state.config
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
dispatch('agentSign', {corpId, suiteId}).then(() => dispatch("injectJWeixin", "selectPrivilegedContact")).then(() => {
|
dispatch("injectSDK", "selectPrivilegedContact").then(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
let sdk = typeof wx?.invoke == 'function' ? wx : jWeixin
|
let sdk = typeof wx?.invoke == 'function' ? wx : jWeixin
|
||||||
sdk?.invoke("selectPrivilegedContact", {
|
sdk?.invoke("selectPrivilegedContact", {
|
||||||
@@ -341,8 +341,6 @@ export const wxwork = {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
initOpenData({dispatch, commit, state}, params = {}) {
|
initOpenData({dispatch, commit, state}, params = {}) {
|
||||||
const {corpId, suiteId} = state.config
|
|
||||||
params = {corpId, suiteId, ...params}
|
|
||||||
const loadSdk = (count = 0) => {
|
const loadSdk = (count = 0) => {
|
||||||
if (!!window?.WWOpenData) {
|
if (!!window?.WWOpenData) {
|
||||||
const canvas = params?.canvas
|
const canvas = params?.canvas
|
||||||
@@ -355,7 +353,7 @@ export const wxwork = {
|
|||||||
window?.WWOpenData?.checkSession({
|
window?.WWOpenData?.checkSession({
|
||||||
success: () => init(),
|
success: () => init(),
|
||||||
fail: () => {
|
fail: () => {
|
||||||
dispatch('agentSign', params).then(() => dispatch("injectJWeixin", "initWwOpenData")).then(() => init())
|
dispatch("injectSDK", "initWwOpenData").then(() => init())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, 500)
|
}, 500)
|
||||||
@@ -367,7 +365,7 @@ export const wxwork = {
|
|||||||
}, 200)
|
}, 200)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dispatch('agentSign', params).then(() => dispatch("injectJWeixin", "initWwOpenData")).then(() => loadSdk())
|
dispatch("injectSDK", "initWwOpenData").then(() => loadSdk())
|
||||||
},
|
},
|
||||||
bindElements() {
|
bindElements() {
|
||||||
const nodes = document.querySelectorAll('.AiOpenData')
|
const nodes = document.querySelectorAll('.AiOpenData')
|
||||||
@@ -383,10 +381,6 @@ export const wxwork = {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
injectSDK({dispatch, state}, apis) {
|
|
||||||
const {corpId, suiteId} = state.config
|
|
||||||
return dispatch('agentSign', {corpId, suiteId}).then(() => dispatch("injectJWeixin", [apis].flat()))
|
|
||||||
},
|
|
||||||
shareToExternalChat({dispatch}, params) {
|
shareToExternalChat({dispatch}, params) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
dispatch("injectSDK", "shareToExternalChat").then(() => window?.wx?.invoke("shareToExternalChat", {...params}, resolve) || console.error("jssdk未成功加载!"))
|
dispatch("injectSDK", "shareToExternalChat").then(() => window?.wx?.invoke("shareToExternalChat", {...params}, resolve) || console.error("jssdk未成功加载!"))
|
||||||
|
|||||||
Reference in New Issue
Block a user