login.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <div id="login">
  3. <el-row>
  4. <el-col :span="24" class="style" :style="'background: url(' + loginBei + ')no-repeat center center;'">
  5. <el-col :span="24" class="login">
  6. <el-col :span="16" class="left">
  7. <el-image class="image" :src="logoUrl"></el-image>
  8. <p class="title">吉林省高等学校毕业生就业信息网</p>
  9. </el-col>
  10. <el-col :span="8" class="right">
  11. <el-col :span="24" class="title">
  12. 教师甄选登录系统
  13. </el-col>
  14. <el-col :span="24">
  15. <el-tabs v-model="activeName" type="border-card" :stretch="true">
  16. <el-tab-pane label="账号登录" name="first">
  17. <data-form
  18. :data="{}"
  19. :fields="fields"
  20. :rules="rules"
  21. @save="handleSave"
  22. :isNew="true"
  23. label-width="80px"
  24. :styles="{}"
  25. submitText="登陆"
  26. ></data-form>
  27. </el-tab-pane>
  28. <el-tab-pane label="扫码登录" name="second">
  29. <el-row v-if="!loading" v-loading="loading" style="text-align:center">
  30. <qrcode exchange="qrcode.login" :uri="qrUri" :config="config" :qrcode="qrcode" @toReturn="toReturn"></qrcode>
  31. </el-row>
  32. </el-tab-pane>
  33. </el-tabs>
  34. </el-col>
  35. </el-col>
  36. </el-col>
  37. </el-col>
  38. </el-row>
  39. </div>
  40. </template>
  41. <script>
  42. import Vue from 'vue';
  43. import '@frame/plugins/setting';
  44. import qrcode from '@frame/components/qrcode.vue';
  45. import { mapState, createNamespacedHelpers } from 'vuex';
  46. import dataForm from '@frame/components/form';
  47. import _ from 'lodash';
  48. const { mapActions } = createNamespacedHelpers('login');
  49. export default {
  50. name: 'login',
  51. metaInfo: { title: '登陆' },
  52. props: {},
  53. components: { dataForm, qrcode },
  54. data: () => ({
  55. loginBei: require('../../assets/bg.jpg'),
  56. activeName: 'first',
  57. fields: [
  58. { label: '手机号', required: true, model: 'mobile', options: { maxLength: 11, minLength: 11 } },
  59. { label: '密码', required: true, model: 'passwd', type: 'password' },
  60. ],
  61. rules: {
  62. mobile: [{ required: true, message: '请输入手机号' }],
  63. passwd: [{ required: true, message: '请输入密码' }],
  64. },
  65. form: {},
  66. logoUrl: require('../../assets/logo.png'),
  67. qrUri: '',
  68. config: {},
  69. qrcode: '',
  70. loading: true,
  71. }),
  72. created() {
  73. this.toConnection();
  74. },
  75. computed: {},
  76. methods: {
  77. ...mapActions(['login', 'getQrcode']),
  78. async handleSave({ data }) {
  79. let res = await this.login({ user: data, router: this.$router });
  80. },
  81. async toConnection() {
  82. let res = await this.getQrcode();
  83. this.$set(this, `qrcode`, res);
  84. this.$set(this, `config`, { weixin: Vue.config.weixin, stomp: Vue.config.stomp });
  85. let uri = `/api/train/auth?redirect_uri=${Vue.config.weixin.target}/confirm&type=2&qrcode=${res}`;
  86. this.$set(this, `qrUri`, uri);
  87. this.loading = false;
  88. },
  89. async toReturn(message) {
  90. let openid = message.headers.openid;
  91. let res = await this.login({ user: { openid: openid, qrcode: this.qrcode }, router: this.$router, isWx: true });
  92. },
  93. },
  94. };
  95. </script>
  96. <style lang="less" scoped>
  97. .style {
  98. width: 100%;
  99. height: 100vh;
  100. background: #5dac81;
  101. background-size: cover;
  102. text-align: center;
  103. }
  104. .login {
  105. position: absolute;
  106. top: 20%;
  107. left: 15%;
  108. width: 850px;
  109. height: 400px;
  110. background-color: #ffffff8f;
  111. border: 1px solid #3f7dff;
  112. border-radius: 10px;
  113. }
  114. .login .left .image {
  115. margin: 80px 0 0 0;
  116. }
  117. .login .left .title {
  118. font-size: 30px;
  119. padding: 15px 0;
  120. color: #1770c4;
  121. font-family: cursive;
  122. text-shadow: -1px 0 #fff, 0 1px #fff, 1px 0 #fff, 0 -1px #fff;
  123. font-weight: 600;
  124. }
  125. .login .right {
  126. height: 398px;
  127. background: #fff;
  128. border-top-right-radius: 10px;
  129. border-bottom-right-radius: 10px;
  130. }
  131. .login .right .title {
  132. font-size: 20px;
  133. padding: 20px 0;
  134. font-weight: bold;
  135. }
  136. .el-tabs {
  137. height: 330px;
  138. border-bottom-right-radius: 10px;
  139. }
  140. /deep/.el-tabs__header {
  141. margin: 0;
  142. }
  143. /deep/.el-tabs__nav-wrap::after {
  144. background-color: transparent;
  145. }
  146. /deep/.el-tabs--top .el-tabs__item.is-top:nth-child(2) {
  147. padding-left: 30px;
  148. }
  149. /deep/.el-tabs--top .el-tabs__item.is-top:last-child {
  150. padding-right: 30px;
  151. }
  152. /deep/.el-tabs__item {
  153. padding: 0 30px;
  154. }
  155. /deep/.el-tabs--border-card > .el-tabs__content {
  156. padding: 0;
  157. }
  158. </style>