login.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. <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. title: { type: String, default: '培训会系统登录' },
  54. },
  55. components: { dataForm, qrcode },
  56. data: () => ({
  57. loginBei: require('../../assets/bg.jpg'),
  58. activeName: 'first',
  59. fields: [
  60. { label: '手机号', required: true, model: 'mobile', options: { maxLength: 11, minLength: 11 } },
  61. { label: '密码', required: true, model: 'passwd', type: 'password' },
  62. ],
  63. rules: {
  64. mobile: [{ required: true, message: '请输入手机号' }],
  65. passwd: [{ required: true, message: '请输入密码' }],
  66. },
  67. form: {},
  68. logoUrl: require('../../assets/logo.png'),
  69. qrUri: '',
  70. config: {},
  71. qrcode: '',
  72. loading: true,
  73. }),
  74. created() {
  75. this.toConnection();
  76. },
  77. computed: {},
  78. methods: {
  79. ...mapActions(['login', 'getQrcode']),
  80. async handleSave({ data }) {
  81. let res = await this.login({ user: data, router: this.$router });
  82. },
  83. async toConnection() {
  84. let res = await this.getQrcode();
  85. this.$set(this, `qrcode`, res);
  86. this.$set(this, `config`, { weixin: Vue.config.weixin, stomp: Vue.config.stomp });
  87. let uri = `/api/train/auth?redirect_uri=${Vue.config.weixin.target}/confirm&type=2&qrcode=${res}`;
  88. this.$set(this, `qrUri`, uri);
  89. this.loading = false;
  90. },
  91. async toReturn(message) {
  92. let openid = message.headers.openid;
  93. let res = await this.login({ user: { openid: openid, qrcode: this.qrcode }, router: this.$router, isWx: true });
  94. },
  95. },
  96. };
  97. </script>
  98. <style lang="less" scoped>
  99. .style {
  100. width: 100%;
  101. height: 100vh;
  102. background: #5dac81;
  103. background-size: cover;
  104. text-align: center;
  105. }
  106. .login {
  107. position: absolute;
  108. top: 20%;
  109. left: 25%;
  110. width: 850px;
  111. height: 400px;
  112. background-color: #ffffff8f;
  113. border: 1px solid #3f7dff;
  114. border-radius: 10px;
  115. }
  116. .login .left .image {
  117. margin: 80px 0 0 0;
  118. }
  119. .login .left .title {
  120. font-size: 30px;
  121. padding: 15px 0;
  122. color: #1770c4;
  123. font-family: cursive;
  124. text-shadow: -1px 0 #fff, 0 1px #fff, 1px 0 #fff, 0 -1px #fff;
  125. font-weight: 600;
  126. }
  127. .login .right {
  128. height: 398px;
  129. background: #fff;
  130. border-top-right-radius: 10px;
  131. border-bottom-right-radius: 10px;
  132. }
  133. .login .right .title {
  134. font-size: 20px;
  135. padding: 20px 0;
  136. font-weight: bold;
  137. }
  138. .el-tabs {
  139. height: 330px;
  140. border-bottom-right-radius: 10px;
  141. }
  142. /deep/.el-tabs__header {
  143. margin: 0;
  144. }
  145. /deep/.el-tabs__nav-wrap::after {
  146. background-color: transparent;
  147. }
  148. /deep/.el-tabs--top .el-tabs__item.is-top:nth-child(2) {
  149. padding-left: 30px;
  150. }
  151. /deep/.el-tabs--top .el-tabs__item.is-top:last-child {
  152. padding-right: 30px;
  153. }
  154. /deep/.el-tabs__item {
  155. padding: 0 30px;
  156. }
  157. /deep/.el-tabs--border-card > .el-tabs__content {
  158. padding: 0;
  159. }
  160. </style>