123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- <template>
- <div class="login">
- <div class="login-par">
- <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-position="left" label-width="0px" class="demo-ruleForm login-container">
- <div class="login-logo">
- <img src="../assets/image/login_logo.png" style="width:80px;height:80px;"/>
- </div>
- <h3 class="title">工时管家</h3>
- <el-form-item class="login-input" prop="username">
- <el-input type="text" v-model="ruleForm.username" autocomplete="off" placeholder="账号" clearable prefix-icon="el-icon-user-solid"></el-input>
- </el-form-item>
- <el-form-item class="login-input" prop="password">
- <el-input type="password" v-model="ruleForm.password" @keyup.enter.native="handleSubmit" autocomplete="off" placeholder="密码" show-password prefix-icon="el-icon-lock"></el-input>
- </el-form-item>
- <el-form-item class="login-button" style="width:100%;">
- <el-button type="primary" style="width:100%;" @click.native.prevent="handleSubmit" :loading="logining">登录</el-button>
- </el-form-item>
- <div class="toRegister">
- <el-link type="primary" class="btn" style="float:left;" :underline="false">联系客服
- <div class="service">
- <p style="color: #333">扫码加客服微信</p>
- <img src="../assets/image/code.jpg">
- <p><span style="color: #333">QQ:</span><span id="QQ">3052894409</span></p>
- </div>
- </el-link>
- <el-link type="primary" style="margin-right:5px;" @click="dialogVisible=true" :underline="false">
- 使用说明
- </el-link>
- <el-link type="primary" @click="jumpTo" :underline="false">企业注册</el-link>
- </div>
- </el-form>
- </div>
- <el-dialog title="使用说明" :visible.sync="dialogVisible" width="500px">
- <p><a style="color:#409EFF;text-decoration:none" href="upload/工时管家使用说明_管理员.docx" download="工时管家使用说明_管理员.docx"
- target="_blank">工时管家使用说明_管理员.docx</a></p>
- <p><a style="color:#409EFF;text-decoration:none" href="upload/工时管家使用说明_项目经理.docx" download="工时管家使用说明_项目经理.docx"
- target="_blank">工时管家使用说明_项目经理.docx</a></p>
- <p><a style="color:#409EFF;text-decoration:none" href="upload/工时管家使用说明_普通员工.docx" download="工时管家使用说明_普通员工.docx"
- target="_blank">工时管家使用说明_普通员工.docx</a></p>
-
- </el-dialog>
- </div>
- </template>
- <script>
- import * as dd from 'dingtalk-jsapi';
- export default {
- data() {
- return {
- dialogVisible: false,
- logining: false,
- // 登录信息
- ruleForm: {
- username: '',
- password: ''
- },
- rules: {
- username: [{ required: true, message: '请输入账号', trigger: 'blur' },],
- password: [{ required: true, message: '请输入密码', trigger: 'blur' },]
- }
- };
- },
- created() {
- if (localStorage.userInfo != null) {
- var user = JSON.parse(localStorage.userInfo);
- if (user.role == 3) {
- //公司高层
- this.$router.push({ path: '/cost' });
- } else if (user.role == 4) {
- //人事管理员
- this.$router.push({ path: '/team' });
- } else {
- this.$router.push({ path: '/daily' });
- }
- }
- },
- mounted() {
- if (localStorage.userInfo != null) {
- var user = JSON.parse(localStorage.userInfo);
- if (user.role == 3) {
- //公司高层
- this.$router.push({ path: '/cost' });
- } else if (user.role == 4) {
- //人事管理员
- this.$router.push({ path: '/team' });
- } else {
- this.$router.push({ path: '/daily' });
- }
- } else {
- //检查环境,如果是钉钉有$CORPID$
- var key = '?corpid=';
- var url = location.href;
- var that = this;
- if (url.indexOf(key) > 0) {
- var corpId = url.substring(url.indexOf(key)+key.length,url.indexOf('#'));
- dd.ready(function() {
- dd.runtime.permission.requestAuthCode({
- corpId: corpId, // 企业id
- onSuccess: function (info) {
- var code = info.code // 通过该免登授权码可以获取用户身份
- that.loginByCode(code, corpId);
- }});
- });
- }
- }
- },
- methods: {
- loginByCode(code, corpId) {
- this.http.post("/dingding/getUserByCode", {code:code, corpid:corpId} , res => {
- if (res.code == "ok") {
- var user = res.data;
- localStorage.user = JSON.stringify(res.data);
- sessionStorage.setItem('user', JSON.stringify(res.data));
- if (user.role == 3) {
- //公司高层
- this.$router.push({ path: '/cost' });
- } else if (user.role == 4) {
- //人事管理员
- this.$router.push({ path: '/team' });
- } else {
- this.$router.push({ path: '/daily' });
- }
- } else {
- this.$message({
- message: res.msg,
- type: 'error'
- });
- }
- }, error => {
- this.$message({
- message: error,
- type: 'error'
- });
- })
- },
- handleReset2() {
- this.$refs.ruleForm.resetFields();
- },
- jumpTo() {
- this.$router.push({ path: '/register' });
- },
- handleSubmit(ev) {
- this.$refs.ruleForm.validate((valid) => {
- if (valid) {
- var _this = this;
- this.logining = true;
- this.http.post(this.port.manage.login, this.ruleForm , res => {
- this.logining = false;
- if (res.code == "ok") {
- var user = res.data;
- sessionStorage.setItem('user', JSON.stringify(res.data));
- if (user.role == 3) {
- //公司高层
- this.$router.push({ path: '/cost' });
- } else if (user.role == 4) {
- //人事管理员
- this.$router.push({ path: '/team' });
- } else {
- this.$router.push({ path: '/daily' });
- }
-
- } else {
- this.$message({
- message: res.msg,
- type: 'error'
- });
- }
- }, error => {
- this.logining = false;
- this.$message({
- message: error,
- type: 'error'
- });
- })
- }
- });
- },
- },
- }
- </script>
- <style lang="scss" scoped>
- .login {
- height: 100%;
- .login-par {
- width: 100%;
- min-height: 100%;
- background: #f0f2f5 url('../assets/image/background.png') no-repeat 50%;
- background-size: 100%;
- padding: 110px 0 144px;
- position: relative;
- box-sizing: border-box;
- .login-logo {
- text-align: center;
- margin: 0 0 20px 0;
- }
- .login-container {
- -webkit-border-radius: 5px;
- border-radius: 5px;
- -moz-border-radius: 5px;
- background-clip: padding-box;
- width: 315px;
- height: 380px;
- padding: 25px 35px 25px 35px;
- background: #fff;
- border: 1px solid #eaeaea;
- box-shadow: 0 0 5px #cac6c6;
- border-top: 10px solid #20a0ff;
- margin:auto;
- .title {
- font-size: 20px;
- margin: 0px auto 40px auto;
- text-align: center;
- color: #505458;
- }
- .remember {
- margin: 0px 0px 35px 0px;
- }
- .login-input {
- margin: 30px 0 0 0;
- }
- .login-button {
- margin: 30px 0 0 0;
- }
- .login-button .el-button {
- padding: 14px;
- }
- }
- }
- }
- .toRegister {
- margin: 15px 0;
- text-align: right;
- position: relative;
- .service {
- display: none;
- width: 120px;
- position: absolute;
- background: #fff;
- text-align: center;
- padding: 10px;
- left: -30px;
- top: -210px;
- border-radius: 5px;
- box-shadow: 3px 3px 10px #dfdfdf;
- img {
- width: 80px;
- }
- }
- }
- .btn:hover .service {
- display: block;
- }
- </style>
|