平安校园
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

login.vue 4.3 KiB

1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view style="height: 100%;">
  3. <view class="logoBox">
  4. <image src="/static/image/logo.png" mode="heightFix"></image>
  5. <view class="logoText">
  6. AI监控预警分析平台
  7. </view>
  8. </view>
  9. <view class="loginBox">
  10. <view class="title">
  11. 账号登录
  12. </view>
  13. <u--form labelPosition="left" :model="form" labelWidth="30rpx" :rules="rules" ref="uForm">
  14. <u-form-item prop="account">
  15. <u--input v-model="form.account" border="none" placeholder="请输入账号"
  16. :customStyle="{backgroundColor:'#F5F5F5',height:'98rpx',borderRadius:'20rpx',padding:'0rpx 30rpx'}"></u--input>
  17. </u-form-item>
  18. <u-form-item prop="password">
  19. <u--input v-model="form.password" :type="passType" border="none" placeholder="请输入密码"
  20. :customStyle="{backgroundColor:'#F5F5F5',height:'98rpx',borderRadius:'20rpx',padding:'0rpx 30rpx'}">
  21. <view slot="suffix">
  22. <view :style="{opacity:passType=='text'?'1':'0',height:passType=='text'?'auto':'0'}">
  23. <u-icon name="eye" color="#777777" size="38rpx"
  24. @click="passType='password'"></u-icon>
  25. </view>
  26. <image v-show="passType=='password'" src="/static/image/eyeclose.png"
  27. style="width: 38rpx;height: 38rpx;margin-top: 12rpx;" @click="passType='text'">
  28. </image>
  29. </view>
  30. </u--input>
  31. </u-form-item>
  32. <u-form-item>
  33. <u-button @click="login" :loading="isLoading" :disabled="isLoading" text="登录" :color="'#2388FF'"
  34. :customStyle="{height:'98rpx',borderRadius:'20rpx',marginTop:'60rpx'}"></u-button>
  35. </u-form-item>
  36. </u--form>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import {
  42. login,
  43. } from '@/api/user.js'
  44. import smCrypto from '@/utils/smCrypto'
  45. export default {
  46. data() {
  47. return {
  48. form: {
  49. account: '',
  50. password: '',
  51. },
  52. passType: 'password',
  53. isLoading: false,
  54. redirect: '',
  55. rules: {
  56. account: [{
  57. required: true,
  58. message: '请输入账号',
  59. trigger: ['blur', 'change']
  60. }],
  61. password: [{
  62. required: true,
  63. message: '请输入密码',
  64. trigger: ['blur', 'change']
  65. }, {
  66. validator: (rule, value, callback) => {
  67. if (value.length < 6) {
  68. callback(new Error('请输入正确的密码'));
  69. return
  70. }
  71. callback();
  72. },
  73. }]
  74. }
  75. }
  76. },
  77. onLoad(e) {
  78. if (e.redirect) this.redirect = e.redirect
  79. if (process.env.NODE_ENV === 'development') {
  80. this.form.account = 'superAdmin'
  81. this.form.password = '123456'
  82. }
  83. },
  84. methods: {
  85. async login() {
  86. this.$refs.uForm.validate().then(() => {
  87. this.isLoading = true
  88. login({
  89. ...this.form,
  90. password: smCrypto.doSm2Encrypt(this.form.password)
  91. }).then(res => {
  92. this.isLoading = false
  93. if (res.code != 200) return
  94. let data = res.data
  95. this.$store.dispatch('setToken', {
  96. token: data.token
  97. })
  98. this.$store.dispatch('getUserInfo')
  99. this.$store.dispatch('getAllOptions')
  100. this.NAV_TO('/')
  101. }).finally(() => {
  102. this.isLoading = false
  103. })
  104. })
  105. },
  106. getLoginUser() {
  107. return getLoginUser().then(res => {
  108. if (res.code != 200) return
  109. this.$u.vuex('userInfo', res.data)
  110. })
  111. }
  112. },
  113. onReady() {
  114. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  115. this.$refs.uForm.setRules(this.rules)
  116. },
  117. }
  118. </script>
  119. <style scoped lang="scss">
  120. body,
  121. uni-page-body {
  122. background-color: #fff;
  123. }
  124. uni-page-body {
  125. background-image: url('/static/image/loginBg.png');
  126. background-position: top;
  127. background-size: 100% auto;
  128. background-repeat: no-repeat;
  129. }
  130. input[type="password"]::-ms-reveal {
  131. display: none !important;
  132. }
  133. .logoBox {
  134. /* #ifdef H5*/
  135. padding-top: 42rpx;
  136. /* #endif */
  137. /* #ifndef H5*/
  138. padding-top: 88rpx;
  139. /* #endif */
  140. text-align: center;
  141. uni-image {
  142. height: 80rpx;
  143. margin-top: 160rpx;
  144. }
  145. .logoText {
  146. font-family: 'Alimama ShuHeiTi';
  147. font-weight: 700;
  148. color: #333;
  149. margin-top: 24rpx;
  150. font-size: 40rpx;
  151. }
  152. }
  153. .loginBox {
  154. border-radius: 40rpx;
  155. background-color: #fff;
  156. height: calc(100% - 880rpx);
  157. margin-top: 46rpx;
  158. padding: 60rpx 60rpx 0 60rpx;
  159. min-height: 450rpx;
  160. .title {
  161. color: #333;
  162. font-size: 42rpx;
  163. margin-bottom: 30rpx;
  164. // font-weight: 700;
  165. }
  166. /deep/.u-form-item__body {
  167. padding: 15rpx 0;
  168. }
  169. }
  170. </style>