index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. <view class="protocol-wrap">
  42. <u-checkbox-group v-model="isAgreed">
  43. <u-checkbox shape="circle" label="我已阅读并同意" name="checked"></u-checkbox>
  44. </u-checkbox-group>
  45. <text class="btn" @click="openProrocol()">《用户隐私协议》</text>
  46. </view>
  47. <view class="login-btn" @click="handleLogin()">登录</view>
  48. <view class="footer">
  49. <u-text color="#646464" size="24rpx" align="center" text="由-青岛大数华创科技有限公司 提供技术支持"></u-text>
  50. </view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import { mapActions } from 'vuex'
  56. import to from 'await-to-js'
  57. export default {
  58. name: 'omsIndex',
  59. data() {
  60. return {
  61. isAgreed: false,
  62. height: '',
  63. paddingTop: '',
  64. loginForm: {
  65. username: '',
  66. password: '',
  67. rememberPassword: [],
  68. },
  69. rules: {
  70. username: {
  71. type: 'string',
  72. required: true,
  73. message: '请填写账号',
  74. trigger: ['blur'],
  75. },
  76. password: {
  77. type: 'string',
  78. required: true,
  79. message: '请填写密码',
  80. trigger: ['blur'],
  81. },
  82. },
  83. }
  84. },
  85. onLoad() {
  86. // 检查本地存储是否保存了用户名和密码
  87. const userInfo = uni.getStorageSync('userInfo')
  88. if (userInfo) {
  89. this.loginForm.username = userInfo.username
  90. this.loginForm.password = userInfo.password
  91. this.loginForm.rememberPassword = ['checked']
  92. }
  93. },
  94. created() {
  95. const navData = uni.getMenuButtonBoundingClientRect()
  96. this.height = navData.height + 'px'
  97. this.paddingTop = navData.top + 'px'
  98. },
  99. mounted() {},
  100. methods: {
  101. ...mapActions(['login']),
  102. async handleLogin() {
  103. if (!this.isAgreed) {
  104. uni.showToast({
  105. title: '请先阅读并同意用户协议和隐私协议',
  106. icon: 'none',
  107. })
  108. return
  109. }
  110. const [valid] = await to(this.$refs.loginForm.validate())
  111. if (valid !== null) return
  112. await this.login(this.loginForm)
  113. },
  114. async openProrocol() {
  115. const url = '/pages/login/protocol-user'
  116. console.log(url)
  117. uni.navigateTo({
  118. //保留当前页面,跳转到应用内的某个页面
  119. url,
  120. })
  121. },
  122. },
  123. }
  124. </script>
  125. <style>
  126. page {
  127. background: #fff;
  128. }
  129. </style>
  130. <style lang="scss" scoped>
  131. .login {
  132. padding-top: 188rpx;
  133. .nav {
  134. position: absolute;
  135. left: 0;
  136. top: 0;
  137. width: 100%;
  138. background: #ffffff;
  139. .title {
  140. position: relative;
  141. text-align: center;
  142. font-size: 32rpx;
  143. font-weight: bold;
  144. color: #000;
  145. .back {
  146. position: absolute;
  147. top: 0;
  148. bottom: 0;
  149. margin: auto;
  150. left: 70rpx;
  151. display: flex;
  152. }
  153. }
  154. }
  155. .main {
  156. position: absolute;
  157. width: 100%;
  158. height: calc(100vh - 188rpx);
  159. background: #ffffff;
  160. padding: 0 88rpx 0 90rpx;
  161. .bg {
  162. padding-top: 40rpx;
  163. .tips {
  164. font-size: 46rpx;
  165. font-weight: bold;
  166. color: #060606;
  167. }
  168. .login-img {
  169. width: 292rpx;
  170. height: 292rpx;
  171. }
  172. }
  173. .login-btn {
  174. margin-top: 42rpx;
  175. width: 100%;
  176. height: 92rpx;
  177. background: #3e7ef8;
  178. border-radius: 32rpx;
  179. font-size: 32rpx;
  180. color: #ffffff;
  181. text-align: center;
  182. line-height: 92rpx;
  183. }
  184. .footer {
  185. position: absolute;
  186. bottom: 100rpx;
  187. left: 0;
  188. right: 0;
  189. margin: auto;
  190. }
  191. }
  192. }
  193. .protocol-wrap {
  194. display: flex;
  195. align-items: center;
  196. margin-top: 30rpx;
  197. text {
  198. font-size: 26rpx;
  199. color: #646464;
  200. }
  201. .btn {
  202. color: #409eff;
  203. }
  204. }
  205. </style>