Login.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <div id="Login">
  3. <el-row>
  4. <el-col :span="24" class="main" :style="{ height: clientHeight + 'px' }">
  5. <div class="w_1200">
  6. <el-row :gutter="20">
  7. <el-col :span="10" :offset="6" class="info">
  8. <el-col :span="24" class="text">
  9. 成果评价系统
  10. </el-col>
  11. <el-col :span="24" class="tabs">
  12. <el-tabs v-model="active" type="card">
  13. <el-tab-pane label="个人用户" name="first">
  14. <el-col :span="24" class="two">
  15. <el-form :model="webForm" :rules="rules" ref="webForm" label-width="100px">
  16. <el-form-item label="账号" prop="phone">
  17. <el-input v-model="webForm.phone" placeholder="请输入账号"></el-input>
  18. </el-form-item>
  19. <el-form-item label="密码" prop="password">
  20. <el-input v-model="webForm.password" placeholder="请输入密码" show-password></el-input>
  21. </el-form-item>
  22. <el-col :span="24" class="btn">
  23. <el-button type="primary" @click="webLogin('webForm')">确认登录</el-button>
  24. </el-col>
  25. </el-form>
  26. </el-col>
  27. </el-tab-pane>
  28. <el-tab-pane label="管理用户" name="second">
  29. <el-col :span="24" class="two">
  30. <el-form :model="form" :rules="rules" ref="form" label-width="100px">
  31. <el-form-item label="手机号" prop="code_phone">
  32. <el-input v-model="form.code_phone" placeholder="请输入手机号"></el-input>
  33. </el-form-item>
  34. <el-form-item label="密码" prop="passwd">
  35. <el-input v-model="form.passwd" placeholder="请输入密码" show-password></el-input>
  36. </el-form-item>
  37. <el-col :span="24" class="btn">
  38. <el-button type="primary" @click="adminLogin('form')">确认登录</el-button>
  39. </el-col>
  40. </el-form>
  41. </el-col>
  42. </el-tab-pane>
  43. <el-tab-pane label="专家用户" name="third">
  44. <el-col :span="24" class="two">
  45. <el-form :model="expert" ref="expert" label-width="100px">
  46. <el-form-item label="手机号" prop="phone">
  47. <el-input v-model="expert.phone" placeholder="请输入手机号"></el-input>
  48. </el-form-item>
  49. <el-form-item label="密码" prop="passwd">
  50. <el-input v-model="expert.password" placeholder="请输入密码" show-password></el-input>
  51. </el-form-item>
  52. <el-col :span="24" class="btn">
  53. <el-button type="primary" @click="toExpertLogin('form')">确认登录</el-button>
  54. </el-col>
  55. </el-form>
  56. </el-col>
  57. </el-tab-pane>
  58. </el-tabs>
  59. </el-col>
  60. </el-col>
  61. </el-row>
  62. </div>
  63. </el-col>
  64. </el-row>
  65. </div>
  66. </template>
  67. <script>
  68. const _ = require('lodash');
  69. import { mapState, createNamespacedHelpers } from 'vuex';
  70. const { mapActions: adminLogin } = createNamespacedHelpers('adminLogin');
  71. const { mapActions: personal } = createNamespacedHelpers('personal');
  72. const { mapActions: organization } = createNamespacedHelpers('organization');
  73. const { mapActions: achieveExpert } = createNamespacedHelpers('achieveExpert');
  74. export default {
  75. metaInfo() {
  76. return { title: this.$route.meta.title };
  77. },
  78. name: 'Login',
  79. props: {},
  80. components: {},
  81. data: function() {
  82. return {
  83. // 页面高度
  84. clientHeight: '',
  85. active: 'first',
  86. // 个人登录
  87. webForm: {},
  88. // 管理登录
  89. form: {},
  90. rules: {
  91. code_phone: [{ required: true, message: '请输入手机号', trigger: 'blur' }],
  92. passwd: [{ required: true, message: '请输入密码', trigger: 'blur' }],
  93. phone: [{ required: true, message: '请输入手机号', trigger: 'blur' }],
  94. password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
  95. type: [{ required: true, message: '请选择用户类别', trigger: 'change' }],
  96. },
  97. // 专家登陆
  98. expert: {},
  99. };
  100. },
  101. created() {},
  102. methods: {
  103. ...personal(['perLogin']),
  104. ...organization(['orgLogin']),
  105. ...adminLogin(['login']),
  106. ...achieveExpert({ expertLogin: 'login' }),
  107. // 个人登录
  108. webLogin(formName) {
  109. this.$refs[formName].validate(async valid => {
  110. if (valid) {
  111. let data = this.webForm;
  112. data.type = '4';
  113. if (data.type == '4') {
  114. let res = await this.perLogin({ user: data });
  115. if (this.$checkRes(res)) {
  116. this.$message.success('登录成功');
  117. this.$router.push('/homeIndex');
  118. }
  119. } else if (data.type == '5') {
  120. data.institution_code = data.phone;
  121. let res = await this.orgLogin({ user: data });
  122. if (this.$checkRes(res)) {
  123. this.$message.success('登录成功');
  124. this.$router.push('/homeIndex');
  125. }
  126. }
  127. } else {
  128. console.log('error submit!!');
  129. return false;
  130. }
  131. });
  132. },
  133. // 管理登录
  134. adminLogin(formName) {
  135. this.$refs[formName].validate(async valid => {
  136. if (valid) {
  137. let res = await this.login({ user: this.form });
  138. if (this.$checkRes(res)) {
  139. this.$message.success('登录成功');
  140. this.$router.push('/homeIndex');
  141. }
  142. } else {
  143. console.log('error submit!!');
  144. return false;
  145. }
  146. });
  147. },
  148. // 专家登陆
  149. async toExpertLogin() {
  150. let dup = _.cloneDeep(this.expert);
  151. const res = await this.expertLogin(dup);
  152. if (this.$checkRes(res)) {
  153. this.$message.success('登录成功');
  154. this.$router.push('/homeIndex');
  155. }
  156. },
  157. },
  158. mounted() {
  159. let clientHeight = document.documentElement.clientHeight || document.body.clientHeight;
  160. this.$set(this, `clientHeight`, clientHeight);
  161. },
  162. computed: {
  163. ...mapState(['user']),
  164. },
  165. watch: {},
  166. };
  167. </script>
  168. <style lang="less" scoped>
  169. .w_1200 {
  170. width: 1200px;
  171. margin: 0 auto;
  172. }
  173. .main {
  174. background-image: url(../assets/img/login-bg.jpg);
  175. background-repeat: no-repeat;
  176. background-size: 100% 100%;
  177. overflow: auto;
  178. .info {
  179. height: 430px;
  180. box-shadow: 0 0 5px #ccc;
  181. position: relative;
  182. top: 150px;
  183. background-color: #ffffff9f;
  184. border-radius: 10px;
  185. .text {
  186. text-align: center;
  187. font-size: 20px;
  188. padding: 20px 0;
  189. font-weight: bold;
  190. border-bottom: 1px solid #000;
  191. margin: 0 0 15px 0;
  192. }
  193. .tabs {
  194. padding: 0 !important;
  195. /deep/.el-tabs__item {
  196. width: 162px;
  197. text-align: center;
  198. font-size: 18px;
  199. font-weight: bold;
  200. }
  201. .btn {
  202. text-align: center;
  203. }
  204. .two {
  205. padding: 30px 0px !important;
  206. }
  207. }
  208. }
  209. }
  210. </style>