BUG 30141
This commit is contained in:
@@ -119,3 +119,118 @@ export const waterMarker = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 企微jssdk功能
|
||||||
|
*/
|
||||||
|
let apiList = []
|
||||||
|
export const wxwork = {
|
||||||
|
actions: {
|
||||||
|
injectJWeixin({commit, dispatch, state}, ops) {
|
||||||
|
const inject = (jsApiList, config = state.config) => new Promise((resolve, reject) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
let sdk = wx?.agentConfig ? wx : jWeixin
|
||||||
|
sdk?.agentConfig({
|
||||||
|
...config, jsApiList,
|
||||||
|
success: res => resolve(res),
|
||||||
|
fail: err => {
|
||||||
|
console.error(err)
|
||||||
|
reject(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, 500)
|
||||||
|
})
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
dispatch("agentSign").then(config => {
|
||||||
|
if (typeof ops == "object") {
|
||||||
|
ops?.map(api => {
|
||||||
|
if (!apiList?.includes(api)) apiList.push(api)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
if (!apiList?.includes(ops)) apiList.push(ops)
|
||||||
|
}
|
||||||
|
inject(apiList, config).then(r => resolve(r)).catch(err => reject(err))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
wxInvoke(state, op) {
|
||||||
|
setTimeout(() => {
|
||||||
|
let sdk = typeof wx?.invoke == 'function' ? wx : jWeixin
|
||||||
|
sdk?.invoke(op?.[0], op?.[1], op?.[2])
|
||||||
|
}, 500)
|
||||||
|
},
|
||||||
|
previewFile({dispatch}, op) {
|
||||||
|
if (window.navigator.userAgent.indexOf("Windows NT") > -1) {
|
||||||
|
uni.showToast({
|
||||||
|
title: "企业微信暂不支持PC端的预览文件!",
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
dispatch("injectJWeixin", "previewFile").then(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
let sdk = typeof wx?.invoke == 'function' ? wx : jWeixin
|
||||||
|
sdk?.invoke('previewFile', {...op}, res => {
|
||||||
|
console.log(res)
|
||||||
|
})
|
||||||
|
}, 500)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
closeAgent({dispatch}) {
|
||||||
|
dispatch("injectJWeixin", "closeWindow").then(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
let sdk = typeof wx?.closeWindow == 'function' ? wx : jWeixin
|
||||||
|
sdk?.closeWindow()
|
||||||
|
}, 500)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
selectEnterpriseContact({dispatch}, params) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
dispatch("injectJWeixin", "selectEnterpriseContact").then(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
let sdk = typeof wx?.invoke == 'function' ? wx : jWeixin
|
||||||
|
sdk?.invoke("selectEnterpriseContact", {
|
||||||
|
fromDepartmentId: -1,
|
||||||
|
mode: "multi",
|
||||||
|
type: ["user"],
|
||||||
|
...params
|
||||||
|
}, res => {
|
||||||
|
if (res.err_msg == "selectEnterpriseContact:ok") {
|
||||||
|
if (typeof res.result == 'string') {
|
||||||
|
res.result = JSON.parse(res.result)
|
||||||
|
}
|
||||||
|
resolve(res.result)
|
||||||
|
} else {
|
||||||
|
reject(res)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, 500)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
selectPrivilegedContact({dispatch}, params) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
dispatch("injectJWeixin", "selectPrivilegedContact").then(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
let sdk = typeof wx?.invoke == 'function' ? wx : jWeixin
|
||||||
|
sdk?.invoke("selectPrivilegedContact", {
|
||||||
|
fromDepartmentId: -1,
|
||||||
|
mode: "multi",
|
||||||
|
...params
|
||||||
|
}, res => {
|
||||||
|
if (res.err_msg == "selectPrivilegedContact:ok") {
|
||||||
|
if (typeof res.result == 'string') {
|
||||||
|
res.result = JSON.parse(res.result)
|
||||||
|
}
|
||||||
|
resolve(res.result)
|
||||||
|
} else {
|
||||||
|
reject(res)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, 300)
|
||||||
|
}).catch(() => {
|
||||||
|
reject('error')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import Vuex from 'vuex'
|
|||||||
import perState from 'vuex-persistedstate'
|
import perState from 'vuex-persistedstate'
|
||||||
import http from '../common/axios'
|
import http from '../common/axios'
|
||||||
import CryptoJS from '../utils/crypto-js'
|
import CryptoJS from '../utils/crypto-js'
|
||||||
import {user, waterMarker} from "../common/modules";
|
import * as modules from "../common/modules";
|
||||||
|
|
||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
let agentSignURL = "", apiList = []
|
let agentSignURL = "", apiList = []
|
||||||
@@ -165,115 +165,8 @@ const store = new Vuex.Store({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
injectJWeixin(state, ops) {
|
|
||||||
const inject = (jsApiList, config = state.state.config) => new Promise((resolve, reject) => {
|
|
||||||
setTimeout(() => {
|
|
||||||
let sdk = wx?.agentConfig ? wx : jWeixin
|
|
||||||
sdk?.agentConfig({
|
|
||||||
...config, jsApiList,
|
|
||||||
success: res => resolve(res),
|
|
||||||
fail: err => {
|
|
||||||
console.error(err)
|
|
||||||
reject(err)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}, 500)
|
|
||||||
})
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
state.dispatch("agentSign").then(config => {
|
|
||||||
if (typeof ops == "object") {
|
|
||||||
ops?.map(api => {
|
|
||||||
if (!apiList?.includes(api)) apiList.push(api)
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
if (!apiList?.includes(ops)) apiList.push(ops)
|
|
||||||
}
|
|
||||||
inject(apiList, config).then(r => resolve(r)).catch(err => reject(err))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
|
||||||
wxInvoke(state, op) {
|
|
||||||
setTimeout(() => {
|
|
||||||
let sdk = typeof wx?.invoke == 'function' ? wx : jWeixin
|
|
||||||
sdk?.invoke(op?.[0], op?.[1], op?.[2])
|
|
||||||
}, 500)
|
|
||||||
},
|
|
||||||
previewFile(state, op) {
|
|
||||||
if (window.navigator.userAgent.indexOf("Windows NT") > -1) {
|
|
||||||
uni.showToast({
|
|
||||||
title: "企业微信暂不支持PC端的预览文件!",
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
state.dispatch("injectJWeixin", "previewFile").then(() => {
|
|
||||||
setTimeout(() => {
|
|
||||||
let sdk = typeof wx?.invoke == 'function' ? wx : jWeixin
|
|
||||||
sdk?.invoke('previewFile', {...op}, res => {
|
|
||||||
console.log(res)
|
|
||||||
})
|
|
||||||
}, 500)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
closeAgent(state) {
|
|
||||||
state.dispatch("injectJWeixin", "closeWindow").then(() => {
|
|
||||||
setTimeout(() => {
|
|
||||||
let sdk = typeof wx?.closeWindow == 'function' ? wx : jWeixin
|
|
||||||
sdk?.closeWindow()
|
|
||||||
}, 500)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
selectEnterpriseContact(state, params) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
state.dispatch("injectJWeixin", "selectEnterpriseContact").then(() => {
|
|
||||||
setTimeout(() => {
|
|
||||||
let sdk = typeof wx?.invoke == 'function' ? wx : jWeixin
|
|
||||||
sdk?.invoke("selectEnterpriseContact", {
|
|
||||||
fromDepartmentId: -1,
|
|
||||||
mode: "multi",
|
|
||||||
type: ["user"],
|
|
||||||
...params
|
|
||||||
}, res => {
|
|
||||||
if (res.err_msg == "selectEnterpriseContact:ok") {
|
|
||||||
if (typeof res.result == 'string') {
|
|
||||||
res.result = JSON.parse(res.result)
|
|
||||||
}
|
|
||||||
resolve(res.result)
|
|
||||||
} else {
|
|
||||||
reject(res)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}, 500)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
|
||||||
selectPrivilegedContact(state, params) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
state.dispatch("injectJWeixin", "selectPrivilegedContact").then(() => {
|
|
||||||
setTimeout(() => {
|
|
||||||
let sdk = typeof wx?.invoke == 'function' ? wx : jWeixin
|
|
||||||
sdk?.invoke("selectPrivilegedContact", {
|
|
||||||
fromDepartmentId: -1,
|
|
||||||
mode: "multi",
|
|
||||||
...params
|
|
||||||
}, res => {
|
|
||||||
if (res.err_msg == "selectPrivilegedContact:ok") {
|
|
||||||
if (typeof res.result == 'string') {
|
|
||||||
res.result = JSON.parse(res.result)
|
|
||||||
}
|
|
||||||
resolve(res.result)
|
|
||||||
} else {
|
|
||||||
reject(res)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}, 300)
|
|
||||||
}).catch(() => {
|
|
||||||
reject('error')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
modules: {user, waterMarker},
|
modules,
|
||||||
plugins: [perState({
|
plugins: [perState({
|
||||||
storage: {
|
storage: {
|
||||||
getItem: key => uni.getStorageSync(key),
|
getItem: key => uni.getStorageSync(key),
|
||||||
|
|||||||
Reference in New Issue
Block a user