From bf8f2e146ad928f1d05b14403e334e3a24cc136e Mon Sep 17 00:00:00 2001 From: WXL <1785969728@qq.com> Date: 星期四, 16 五月 2024 15:07:36 +0800 Subject: [PATCH] 11 --- src/api/login.js | 7 ++- src/api/system/user.js | 7 +++ src/store/modules/user.js | 6 ++- src/views/login.vue | 46 ++++++++++++++++++++++ vue.config.js | 4 +- src/main.js | 14 ++++++ src/views/system/user/profile/userInfo.vue | 20 +++++++++- package.json | 1 8 files changed, 94 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index bfd74fa..d78b8bf 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "clipboard": "2.0.6", "core-js": "3.8.1", "dayjs": "^1.11.1", + "dingtalk-jsapi": "^3.0.33", "echarts": "4.9.0", "element-china-area-data": "^5.0.2", "element-ui": "2.15.6", diff --git a/src/api/login.js b/src/api/login.js index abd49c7..1e5eccc 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -1,12 +1,13 @@ import request from '@/utils/request' // 鐧诲綍鏂规硶 -export function login(username, password, code, uuid) { +export function login(username, password, code, uuid,authCode) { const data = { username, password, code, - uuid + uuid, + authCode } return request({ url: '/login', @@ -50,4 +51,4 @@ method: 'get', timeout: 20000 }) -} \ No newline at end of file +} diff --git a/src/api/system/user.js b/src/api/system/user.js index bb8a61a..ab25ade 100644 --- a/src/api/system/user.js +++ b/src/api/system/user.js @@ -149,3 +149,10 @@ params: data }) } +// 鏌ヨ鎺堟潈瑙掕壊 +export function getdepartment(userName ) { + return request({ + url: '/system/dingtalk/deptidList/' + 1 , + method: 'get', + }) +} diff --git a/src/main.js b/src/main.js index d800d22..60b8011 100644 --- a/src/main.js +++ b/src/main.js @@ -3,7 +3,7 @@ * @Date: 2022-04-25 08:04:47 * @LastEditors: your Name * @LastEditTime: 2022-04-25 16:33:00 - * @Description: + * @Description: */ import Vue from 'vue' import yearPicker from 'vue-year-picker' @@ -47,6 +47,17 @@ // import li_area_select from '@components/Address' import moment from "moment" import '@/utils/drag.js'; +import DingTalkPC from 'dingtalk-jsapi'; + +Vue.prototype.$dingtalk = DingTalkPC; +DingTalkPC.config({ + agentId: 'your_agentId', + corpId: 'your_corpId', + timeStamp: new Date().getTime(), + nonceStr: 'your_nonceStr', + signature: 'your_signature', + jsApiList: ['runtime.permission.requestAuthCode'] +}); Vue.prototype.$moment = moment; @@ -64,6 +75,7 @@ import echarts from 'echarts' Vue.prototype.$echarts = echarts + // 鍏ㄥ眬缁勪欢鎸傝浇 // Vue.component('li_area_select',li_area_select) Vue.component('DictTag', DictTag) diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 7475b22..20c0e33 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -45,8 +45,10 @@ const password = userInfo.password const code = userInfo.code const uuid = userInfo.uuid + const authCode = userInfo.authCode + console.log(authCode,'authCode'); return new Promise((resolve, reject) => { - login(username, password, code, uuid).then(res => { + login(username, password, code, uuid, authCode).then(res => { console.log(res,'log'); setToken(res.token) commit('SET_TOKEN', res.token) @@ -84,7 +86,7 @@ }) }) }, - + // 閫�鍑虹郴缁� LogOut({ commit, state }) { return new Promise((resolve, reject) => { diff --git a/src/views/login.vue b/src/views/login.vue index df7a011..f3be51b 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -96,6 +96,7 @@ data() { return { codeUrl: "", + authCode: "", cookiePassword: "", loginForm: { username: "", @@ -137,6 +138,8 @@ created() { this.getCode(); this.getCookie(); + this.getAuthCode(); + // this.avoidLogin(); }, methods: { tip() { @@ -151,6 +154,47 @@ this.loginForm.uuid = res.uuid; } }); + }, + getAuthCode() { + this.$dingtalk.runtime.permission.requestAuthCode({ + corpId: "dingac30cec5f3570bbea39a90f97fcb1e09", + onSuccess: result => { + // 鍦ㄨ繖閲屽鐞嗘巿鏉冩垚鍔熷悗鐨勯�昏緫锛宺esult涓寘鍚巿鏉冪爜绛変俊鎭� + this.authCode = result.codde; + this.$message.success("鎴愬姛鑾峰彇鎺堟潈鐮侊細" + result.code); + this.avoidLogin(); + }, + onFail: err => { + // 鍦ㄨ繖閲屽鐞嗘巿鏉冨け璐ュ悗鐨勯�昏緫 + this.$message({ + type: "error", + message: err + }); + } + }); + }, + avoidLogin() { + this.loading = true; + this.loginForm.authCode = this.authCode; + this.$store + .dispatch("Login", this.loginForm) + .then(res => { + this.$message.error(this.$store.state); + if (this.$store.state.user.code == 200) { + this.$router.push({ path: this.redirect || "/" }).catch(() => {}); + } else { + this.loading = false; + // this.$message.error(this.$store.state.user.msg); + } + }) + .catch(err => { + console.log(err); + this.loading = false; + this.$message.error("鍏嶇櫥闄嗗け璐ヨ鎵嬪姩鎿嶄綔銆�"); + if (this.captchaOnOff) { + this.getCode(); + } + }); }, getCookie() { const username = Cookies.get("username"); @@ -190,7 +234,7 @@ .push({ path: this.redirect || "/" }) .catch(() => {}); } else { - this.loading = false; + this.loading = false; this.$message.error(this.$store.state.user.msg); } }) diff --git a/src/views/system/user/profile/userInfo.vue b/src/views/system/user/profile/userInfo.vue index 854b819..6e232b3 100644 --- a/src/views/system/user/profile/userInfo.vue +++ b/src/views/system/user/profile/userInfo.vue @@ -2,7 +2,7 @@ <el-form ref="form" :model="user" :rules="rules" label-width="80px"> <el-form-item label="鐢ㄦ埛鏄电О" prop="nickName"> <el-input v-model="user.nickName" maxlength="30" /> - </el-form-item> + </el-form-item> <el-form-item label="鎵嬫満鍙风爜" prop="phonenumber"> <el-input v-model="user.phonenumber" maxlength="11" /> </el-form-item> @@ -18,12 +18,19 @@ <el-form-item> <el-button type="primary" size="mini" @click="submit">淇濆瓨</el-button> <el-button type="danger" size="mini" @click="close">鍏抽棴</el-button> + <el-button + type="danger" + size="mini" + v-if="user.nickName == '瓒呯骇绠$悊鍛�'" + @click="getdepartment" + >鑾峰彇閮ㄩ棬淇℃伅</el-button + > </el-form-item> </el-form> </template> <script> -import { updateUserProfile } from "@/api/system/user"; +import { updateUserProfile, getdepartment } from "@/api/system/user"; export default { props: { @@ -70,6 +77,15 @@ close() { this.$store.dispatch("tagsView/delView", this.$route); this.$router.push({ path: "/index" }); + }, + getdepartment() { + getdepartment().then(res => { + if (res.code == 200) { + this.$modal.msgSuccess("鑾峰彇鎴愬姛"); + } else { + this.$modal.msgError(res.msg); + } + }); } } }; diff --git a/vue.config.js b/vue.config.js index 2d114f5..10254cf 100644 --- a/vue.config.js +++ b/vue.config.js @@ -32,8 +32,8 @@ open: true, proxy: { // detail: https://cli.vuejs.org/config/#devserver-proxy - [process.env.VUE_APP_BASE_API]: { - target:`http://localhost:8080`, + [process.env.VUE_APP_BASE_API]: { + target:`http://localhost:8080`, // target:`http://192.168.2.8:8080`, // target:`http://116.62.18.175:8080`, // target:`https://slb.hospitalstar.com:9093`, -- Gitblit v1.9.3