11
WXL
2024-05-16 bf8f2e146ad928f1d05b14403e334e3a24cc136e
11
已修改8个文件
105 ■■■■ 文件已修改
package.json 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/login.js 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/system/user.js 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main.js 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/modules/user.js 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/login.vue 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/system/user/profile/userInfo.vue 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
vue.config.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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",
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
  })
}
}
src/api/system/user.js
@@ -149,3 +149,10 @@
    params: data
  })
}
// 查询授权角色
export function getdepartment(userName ) {
  return request({
    url: '/system/dingtalk/deptidList/' + 1 ,
    method: 'get',
  })
}
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)
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) => {
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 => {
          // 在这里处理授权成功后的逻辑,result中包含授权码等信息
          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);
              }
            })
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);
        }
      });
    }
  }
};
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`,