Login.vue 5.2 KB

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