index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-01-12 11:57:48
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-03-21 15:37:55
  6. * @Description: file content
  7. * @FilePath: \oms\pages\login\index.vue
  8. -->
  9. <template>
  10. <view class="login">
  11. <view class="nav">
  12. <view :style="{ paddingTop }">
  13. <view class="title" :style="[{ height }, { lineHeight: height }]">
  14. <text>OMS</text>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="main">
  19. <view class="bg flex1">
  20. <view class="tips">欢迎使用OMS</view>
  21. <image class="login-img" src="../../static/images/login.png" mode="scaleToFill" />
  22. </view>
  23. <u-form :model="loginForm" :rules="rules" ref="loginForm" label-width="0">
  24. <u-form-item prop="username" customStyle="padding-top:38rpx;border-bottom:1px solid #CDCDCD">
  25. <u-input placeholder="请输⼊账号" v-model="loginForm.username" border="none" clearable></u-input>
  26. </u-form-item>
  27. <u-form-item prop="password" customStyle="padding-top:38rpx;border-bottom:1px solid #CDCDCD">
  28. <u-input
  29. placeholder="请输⼊密码"
  30. :password="true"
  31. v-model="loginForm.password"
  32. border="none"
  33. clearable></u-input>
  34. </u-form-item>
  35. </u-form>
  36. <view style="padding-top: 30rpx">
  37. <u-checkbox-group v-model="loginForm.rememberPassword">
  38. <u-checkbox shape="circle" label="记住密码" name="checked"></u-checkbox>
  39. </u-checkbox-group>
  40. </view>
  41. <u-text
  42. color="#CDCDCD"
  43. size="20rpx"
  44. customStyle="padding-top:32rpx"
  45. text="登录代表您已同意用户协议及隐私条款"></u-text>
  46. <view class="login-btn" @click="handleLogin()">登录</view>
  47. <view class="footer">
  48. <u-text color="#646464" size="24rpx" align="center" text="由-青岛大数华创科技有限公司 提供技术支持"></u-text>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import { mapActions } from 'vuex'
  55. import to from 'await-to-js'
  56. export default {
  57. name: 'omsIndex',
  58. data() {
  59. return {
  60. height: '',
  61. paddingTop: '',
  62. loginForm: {
  63. username: '',
  64. password: '',
  65. rememberPassword: [],
  66. },
  67. rules: {
  68. username: {
  69. type: 'string',
  70. required: true,
  71. message: '请填写账号',
  72. trigger: ['blur'],
  73. },
  74. password: {
  75. type: 'string',
  76. required: true,
  77. message: '请填写密码',
  78. trigger: ['blur'],
  79. },
  80. },
  81. }
  82. },
  83. onLoad() {
  84. // 检查本地存储是否保存了用户名和密码
  85. const userInfo = uni.getStorageSync('userInfo')
  86. if (userInfo) {
  87. this.loginForm.username = userInfo.username
  88. this.loginForm.password = userInfo.password
  89. this.loginForm.rememberPassword = ['checked']
  90. }
  91. },
  92. created() {
  93. const navData = uni.getMenuButtonBoundingClientRect()
  94. this.height = navData.height + 'px'
  95. this.paddingTop = navData.top + 'px'
  96. },
  97. mounted() {},
  98. methods: {
  99. ...mapActions(['login']),
  100. async handleLogin() {
  101. console.log(this.loginForm.rememberPassword)
  102. const [valid] = await to(this.$refs.loginForm.validate())
  103. if (valid !== null) return
  104. await this.login(this.loginForm)
  105. },
  106. },
  107. }
  108. </script>
  109. <style>
  110. page {
  111. background: #fff;
  112. }
  113. </style>
  114. <style lang="scss" scoped>
  115. .login {
  116. padding-top: 188rpx;
  117. .nav {
  118. position: absolute;
  119. left: 0;
  120. top: 0;
  121. width: 100%;
  122. background: #ffffff;
  123. .title {
  124. position: relative;
  125. text-align: center;
  126. font-size: 32rpx;
  127. font-weight: bold;
  128. color: #000;
  129. .back {
  130. position: absolute;
  131. top: 0;
  132. bottom: 0;
  133. margin: auto;
  134. left: 70rpx;
  135. display: flex;
  136. }
  137. }
  138. }
  139. .main {
  140. position: absolute;
  141. width: 100%;
  142. height: calc(100vh - 188rpx);
  143. background: #ffffff;
  144. padding: 0 88rpx 0 90rpx;
  145. .bg {
  146. padding-top: 40rpx;
  147. .tips {
  148. font-size: 46rpx;
  149. font-weight: bold;
  150. color: #060606;
  151. }
  152. .login-img {
  153. width: 292rpx;
  154. height: 292rpx;
  155. }
  156. }
  157. .login-btn {
  158. margin-top: 42rpx;
  159. width: 100%;
  160. height: 92rpx;
  161. background: #3e7ef8;
  162. border-radius: 32rpx;
  163. font-size: 32rpx;
  164. color: #ffffff;
  165. text-align: center;
  166. line-height: 92rpx;
  167. }
  168. .footer {
  169. position: absolute;
  170. bottom: 100rpx;
  171. left: 0;
  172. right: 0;
  173. margin: auto;
  174. }
  175. }
  176. }
  177. </style>