平安校园
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

175 строки
4.2 KiB

  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 = e.redirect
  77. if (process.env.NODE_ENV === 'development') {
  78. this.form.account = 'superAdmin'
  79. this.form.password = '123456'
  80. }
  81. },
  82. methods: {
  83. async login() {
  84. this.$refs.uForm.validate().then(() => {
  85. login({
  86. ...this.form,
  87. password: smCrypto.doSm2Encrypt(this.form.password)
  88. }).then(res => {
  89. if (res.code != 200) return
  90. let data = res.data
  91. this.$store.dispatch('setToken', {
  92. token: data.token
  93. })
  94. this.$store.dispatch('getUserInfo')
  95. this.$store.dispatch('getAllOptions')
  96. this.NAV_TO('/')
  97. }).finally(() => {
  98. this.isLoading = false
  99. })
  100. })
  101. },
  102. getLoginUser() {
  103. return getLoginUser().then(res => {
  104. if (res.code != 200) return
  105. this.$u.vuex('userInfo', res.data)
  106. })
  107. }
  108. },
  109. onReady() {
  110. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  111. this.$refs.uForm.setRules(this.rules)
  112. },
  113. }
  114. </script>
  115. <style scoped lang="scss">
  116. body,
  117. uni-page-body {
  118. background-color: #fff;
  119. }
  120. uni-page-body {
  121. background-image: url('/static/image/loginBg.png');
  122. background-position: top;
  123. background-size: 100% auto;
  124. background-repeat: no-repeat;
  125. }
  126. input[type="password"]::-ms-reveal {
  127. display: none !important;
  128. }
  129. .logoBox {
  130. /* #ifdef H5*/
  131. padding-top: 42rpx;
  132. /* #endif */
  133. /* #ifndef H5*/
  134. padding-top: 88rpx;
  135. /* #endif */
  136. text-align: center;
  137. uni-image {
  138. height: 80rpx;
  139. margin-top: 160rpx;
  140. }
  141. .logoText {
  142. font-family: 'Alimama ShuHeiTi';
  143. font-weight: 700;
  144. color: #333;
  145. margin-top: 24rpx;
  146. font-size: 40rpx;
  147. }
  148. }
  149. .loginBox {
  150. border-radius: 40rpx;
  151. background-color: #fff;
  152. height: calc(100% - 880rpx);
  153. margin-top: 46rpx;
  154. padding: 60rpx 60rpx 0 60rpx;
  155. .title {
  156. color: #333;
  157. font-size: 42rpx;
  158. margin-bottom: 30rpx;
  159. // font-weight: 700;
  160. }
  161. /deep/.u-form-item__body {
  162. padding: 15rpx 0;
  163. }
  164. }
  165. </style>