login.vue 4.7 KB

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