平安校园
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.1 KiB

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