Login.vue 5.5 KB

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