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