Login.vue 5.4 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-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. if (res) {
  106. this.$message.success('登录成功');
  107. this.$router.push('/homeIndex');
  108. } else {
  109. this.$message.error('当前用户不是此平台用户,请更换账号登录');
  110. }
  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>