index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <div class="login-box">
  3. <div class="login-content">
  4. <div class="login-header mt-1 ml-1">
  5. <div class="left">
  6. <div ref="phone" :class="['left-qrCode', {'phone-switch': isPhone}]" @click="handlePhone">
  7. <div class="switch-tip">
  8. {{ isPhone ? '短信、密码登录/注册' : '微信扫码快速登录' }}
  9. </div>
  10. </div>
  11. </div>
  12. <div class="right mr-2 mt-3" v-if="showClose">
  13. <v-icon color="grey" size="30">mdi-close</v-icon>
  14. </div>
  15. </div>
  16. <div class="login-content-box mt-5">
  17. <v-menu>
  18. <template v-slot:activator="{ props }">
  19. <v-btn
  20. color="primary"
  21. v-bind="props"
  22. >
  23. Activator slot
  24. </v-btn>
  25. </template>
  26. <v-list>
  27. <v-list-item
  28. v-for="(item, index) in localeStore.localeMap"
  29. :key="index"
  30. :value="item.lang"
  31. >
  32. <v-list-item-title @click="localeStore.setCurrentLocale(item)">{{ item.name }}</v-list-item-title>
  33. </v-list-item>
  34. </v-list>
  35. </v-menu>
  36. <v-btn>{{ localeStore.currentLocale.lang }}</v-btn>
  37. <div v-if="!isPhone" class="login-tab">
  38. <v-tabs v-model="tab" align-tabs="center" color="#00897B">
  39. <v-tab :value="1">短信登录</v-tab>
  40. <v-tab :value="2">密码登录</v-tab>
  41. </v-tabs>
  42. <v-window v-model="tab" class="mt-9">
  43. <v-window-item :value="1">
  44. <!-- 验证码登录 -->
  45. <phoneFrom ref="phoneRef"></phoneFrom>
  46. </v-window-item>
  47. <v-window-item :value="2">
  48. <!-- 账号密码登录 -->
  49. <passwordFrom ref="passRef"></passwordFrom>
  50. </v-window-item>
  51. </v-window>
  52. </div>
  53. <div v-else>
  54. <!-- 微信扫码登录 -->
  55. <qr-code></qr-code>
  56. </div>
  57. <v-btn color="primary" class="white--text mt-5" min-width="350" @click="handleLogin">
  58. {{ tab === 1 ? $t('login.register') : $t('login.login') }}
  59. </v-btn>
  60. <div class="login-tips mt-3">
  61. 登录/注册即代表您同意
  62. <span class="color" style="cursor: pointer;" @click="handleToUserAgreement">[用户协议]</span>
  63. <span class="color" style="cursor: pointer;" @click="handlePrivacyPolicy">[隐私政策]</span>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </template>
  69. <script setup>
  70. import { ref } from 'vue'
  71. import passwordFrom from './components/password.vue'
  72. import phoneFrom from './components/phone.vue'
  73. import qrCode from './components/qrCode.vue'
  74. defineOptions({ name: 'login-index' })
  75. import { useLocaleStore } from '@/store/locale'
  76. const localeStore = useLocaleStore()
  77. const phone = ref()
  78. let isPhone = ref(false)
  79. const handlePhone = () => {
  80. isPhone.value = !isPhone.value
  81. phone.value.style.backgroundPosition = isPhone.value ? '0 -80px' : '0 0'
  82. }
  83. const tab = ref(1)
  84. const showClose = ref(false)
  85. const phoneRef = ref()
  86. const passRef = ref()
  87. const handleLogin = () => {
  88. }
  89. import { useRouter } from 'vue-router'
  90. const router = useRouter()
  91. const handleToUserAgreement = () => {
  92. router.push({ path: '/userAgreement' })
  93. }
  94. const handlePrivacyPolicy = () => {
  95. router.push({ path: '/privacyPolicy' })
  96. }
  97. </script>
  98. <style lang="scss" scoped>
  99. .login-box {
  100. position: relative;
  101. width: 100%;
  102. height: 100%;
  103. background-image: url('https://www.menduner.com/images/userfiles/92d7e4a755e2428b94aab3636d5047f3/images/recruitment/adImages/2018/11/1920x940.jpg');
  104. background-size: cover;
  105. }
  106. .login-content {
  107. position: absolute;
  108. top: 50%;
  109. left: 50%;
  110. translate: -50% -50%;
  111. width: 450px;
  112. height: 430px;
  113. background-color: #fff;
  114. border-radius: 10px;
  115. }
  116. .login-header {
  117. display: flex;
  118. justify-content: space-between;
  119. align-items: center;
  120. height: 40px;
  121. }
  122. .login-content-box {
  123. padding: 0 50px;
  124. }
  125. .left {
  126. display: flex;
  127. }
  128. .left-qrCode {
  129. position: absolute;
  130. left: 8px;
  131. top: 8px;
  132. width: 40px;
  133. height: 40px;
  134. cursor: pointer;
  135. background: url('../../assets/login.png') 0 0/40px auto no-repeat;
  136. }
  137. .left-qrCode:hover {
  138. background-position: 0 -40px !important;
  139. }
  140. .left-qrCode.phone-switch {
  141. background-position: 0 -80px !important;
  142. }
  143. .left-qrCode.phone-switch:hover {
  144. background-position: 0 -120px !important;
  145. }
  146. .switch-tip {
  147. position: absolute;
  148. left: 60px;
  149. top: 4px;
  150. padding: 0 14px;
  151. border-radius: 4px;
  152. font-size: 12px;
  153. color: #666;
  154. line-height: 32px;
  155. text-align: center;
  156. background-color: #fff;
  157. box-shadow: 0 6px 13px 0 rgba(0,0,0,.1);
  158. white-space: nowrap;
  159. &::before {
  160. content: '';
  161. position: absolute;
  162. left: -5px;
  163. top: 50%;
  164. transform: translateY(-50%) rotate(45deg);
  165. width: 10px;
  166. height: 10px;
  167. background-color: #fff;
  168. box-shadow: 0 6px 13px 0 rgba(0,0,0,.1);
  169. }
  170. }
  171. .login-tips {
  172. width: 100%;
  173. font-size: 12px;
  174. text-align: center;
  175. }
  176. .color {
  177. color: var(--default-color);
  178. }
  179. </style>