1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- import {
- getAuthentication,
- } from '@/api/dingtalk'
- import { waitAuthentication } from '@/utils/dingtalk'
- const state = {
- // dingdef1d60a96033526a1320dcb25e91351 //客户
- // dingf1b2e9ddf9d214e224f2f5cc6abecb85 //自己
- apiToken: '', // company api-token
- corpId: 'dingdef1d60a96033526a1320dcb25e91351', // 公司 corp id
- appId: '', // 微应用ID
- timeStamp: '',
- nonceStr: '',
- signature: ''
- }
- const mutations = {
- UPDATE_CONF (state, payload) {
- state.corpId = payload.corpId
- state.appId = payload.appId
- state.timeStamp = payload.timeStamp
- state.nonceStr = payload.nonceStr
- state.signature = payload.signature
- }
- }
- const actions = {
- // NOTE: 获取授权关键信息
- authentication ({ state, commit }, params) {
- return new Promise((resolve) => {
- if (state.timeStamp && state.nonceStr && state.signature) {
- resolve(state)
- } else {
- getAuthentication(params).then(result => {
- if (result.code === 1) {
- commit({
- type: 'UPDATE_CONF',
- ...result.data
- })
- resolve(result.data)
- }
- })
- }
- })
- },
-
- // 钉钉 - 鉴权
- postWaitAuthentication () {
- waitAuthentication({
- errorCallback: error => {
- console.log('%c WaitAuthentication errorCallback >>>', 'background: blue; color: #fff', error);
- },
- jsApiList: [
- 'biz.contact.departmentsPicker', // 选择部门信息
- 'biz.contact.complexPicker', // 选择部门和人
- 'biz.contact.choose', // PC端选择企业内部的人
- 'biz.util.chooseImage', // 选择图片
- // 'biz.util.previewImage', // Preview Image
- // 'biz.ding.create', // DING 2.0 发钉
- // 'biz.ding.post', // DING 1.0 发钉
- ]
- })
- }
- }
- export default {
- namespaced: true,
- state,
- mutations,
- actions
- }
|