index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <view class="login">
  3. <view class="login-top">
  4. <image class="login-bg" src="/static/login/login_top_backgroud.png"></image>
  5. <view class="login-top-content">
  6. <image class="login-icon" src="/static/logo.png"></image>
  7. <text class="login-title"> {{ $t('login') }} </text>
  8. </view>
  9. </view>
  10. <!-- 登录框 -->
  11. <view class="login-card cu-card padding radius shadow bg-white">
  12. <view class="flex padding-tb justify-between">
  13. <view class="u-border-bottom text-xl text-red"> {{ $t('userLogin') }} </view>
  14. <view class="text-xl" @click="changeToEnglish"> {{ $t('switchLanguage') }} </view>
  15. </view>
  16. <!-- 输入框 -->
  17. <u-gap height="20"/>
  18. <u--input v-model="user.account" :placeholder="$t('userName')" clearable prefixIcon="account" border="bottom" prefixIconStyle="font-size: 22px;color: #909399" @clear="clearInput(true)"/>
  19. <u-gap height="10"/>
  20. <u--input v-model="user.password" :placeholder="$t('password')" clearable password prefixIcon="lock" border="bottom" prefixIconStyle="font-size: 22px;color: #909399" @clear="clearInput(false)"/>
  21. <!-- 登录按钮 -->
  22. <u-gap height="40"/>
  23. <button class="cu-btn block bg-red margin-tb-sm lg radio" @click="startLogin">
  24. <text v-if="loading" class="cuIcon-loading2 cuIconfont-spin"></text>
  25. <text> {{ $t('logIn') }} </text>
  26. </button>
  27. <!-- 隐私政策 -->
  28. <u-gap height="20"/>
  29. <view class="flex u-row u-flex-start align-center">
  30. <text class="lg text-gray" :class="aggred?'cuIcon-roundcheck':'cuIcon-round'" :style="[{color:aggred?'red':'gray'}]" @click="aggreeBtnClick"></text>
  31. <text class="u-line-2 text-sm">
  32. 请阅读并勾选同意
  33. <text class="text-red"> 用户使用协议 </text>
  34. <text class="text-red"> 隐私政策 </text>
  35. </text>
  36. </view>
  37. </view>
  38. <text class="version-text self-center"> {{ $t('appVersion', {version: '1.0.0'}) }} </text>
  39. </view>
  40. </template>
  41. <script>
  42. export default {
  43. data() {
  44. return {
  45. loading: false,
  46. loginStr: '登录',
  47. user: {
  48. account: '',
  49. password: '',
  50. },
  51. animation: '',
  52. aggred: false,
  53. }
  54. },
  55. methods: {
  56. startLogin() {
  57. if (this.user.account == '') return uni.showToast({
  58. icon:'none',
  59. title: this.$i18n.t('pleaseInput') + this.$i18n.t('userName')
  60. })
  61. if (this.user.password == '') return uni.showToast({
  62. icon:'none',
  63. title: this.$i18n.t('pleaseInput') + this.$i18n.t('password')
  64. })
  65. if (!this.aggred) return uni.showToast({
  66. icon:'none',
  67. title: this.$i18n.t('pleaseReadAndAggreeThePrivacyPolicy')
  68. })
  69. this.loading = true
  70. setTimeout(() => {
  71. this.loading = false
  72. uni.navigateTo({
  73. url:'../index/index'
  74. })
  75. }, 2.0*1000);
  76. },
  77. changeToEnglish() {
  78. let locale = this.$i18n.locale
  79. locale === 'zh' ? this.$i18n.locale = 'en' : this.$i18n.locale = 'zh'
  80. },
  81. /// 清除输入框
  82. clearInput(isUserAccount) {
  83. if (isUserAccount) {
  84. this.user.account = ''
  85. } else {
  86. this.user.password = ''
  87. }
  88. },
  89. aggreeBtnClick() {
  90. this.aggred = !this.aggred
  91. }
  92. }
  93. }
  94. </script>
  95. <style lang="scss">
  96. .login {
  97. width: 100%;
  98. position: absolute;
  99. display: flex;
  100. flex-direction: column;
  101. height: 100%;
  102. .login-top {
  103. width: 100%;
  104. .login-bg {
  105. width: 100%;
  106. height: 55vw;
  107. }
  108. .login-top-content {
  109. position: absolute;
  110. left: 30px;
  111. height: 49px;
  112. top: 50px;
  113. display: flex;
  114. flex-direction: row;
  115. justify-content: flex-start;
  116. align-items: center;
  117. .login-icon {
  118. width: 30px;
  119. height: 30px;
  120. }
  121. .login-title {
  122. margin-left: 10px;
  123. font-size: 48rpx;
  124. color: white;
  125. }
  126. }
  127. }
  128. .login-card{
  129. position: absolute;
  130. top: 45vw;
  131. width: 90%;
  132. left: 5%;
  133. }
  134. .version-text {
  135. position: absolute;
  136. bottom: 35px;
  137. width: 100%;
  138. text-align: center;
  139. }
  140. }
  141. </style>