You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

370 lines
7.0 KiB

1 month ago
1 month ago
  1. <template>
  2. <view
  3. class="login-registration-container"
  4. >
  5. <!-- 自定义导航栏 -->
  6. <view class="custom-navbar" :style="{ paddingTop: safeAreaInsets?.top + 'px' }">
  7. <view class="nav-left">
  8. <text class="back-btn" @click="goToIndex"></text>
  9. </view>
  10. <view class="nav-right">
  11. <text class="headphone-btn">🎧</text>
  12. </view>
  13. </view>
  14. <!-- Logo -->
  15. <image class="logo" src="/static/logo.png" mode="aspectFit"></image>
  16. <!-- 欢迎语 -->
  17. <text class="welcome-text">登录</text>
  18. <!-- 邮箱/手机号切换 -->
  19. <view class="switch-container">
  20. <text
  21. class="switch-item"
  22. :class="{ active: switchType === 'Email' }"
  23. @click="switchEmail"
  24. >邮箱/用户名</text
  25. >
  26. <text
  27. class="switch-item"
  28. :class="{ active: switchType === 'Phone' }"
  29. @click="switchPhone"
  30. >手机号</text
  31. >
  32. </view>
  33. <!-- 输入框 -->
  34. <view class="input-container">
  35. <input
  36. v-if="switchType === 'Email'"
  37. class="input-field"
  38. type="text"
  39. placeholder="输入邮箱/用户名"
  40. v-model="email"
  41. />
  42. <input
  43. v-else
  44. class="input-field"
  45. type="text"
  46. placeholder="输入手机号"
  47. v-model="phone"
  48. />
  49. </view>
  50. <!-- 用户协议 -->
  51. <!-- <view class="agreement-container">
  52. <checkbox class="checkbox" v-model="agreed" />
  53. <text class="agreement-text"
  54. >接受 <text class="link">用户协议</text>
  55. <text class="link">隐私政策</text></text
  56. >
  57. </view> -->
  58. <!-- 注册按钮 -->
  59. <button class="register-btn" @click="register">下一步</button>
  60. <!-- 或者 -->
  61. <text class="or-text">或者</text>
  62. <!-- 第三方登录 -->
  63. <view class="third-party-login">
  64. <view class="third-party-btn" @click="loginWithApple">
  65. <image
  66. class="apple-icon"
  67. src="/static/apple-icon.png"
  68. mode="aspectFit"
  69. ></image>
  70. <text class="third-party-text">通过 Apple 继续</text>
  71. </view>
  72. <view class="third-party-btn" @click="loginWithGoogle">
  73. <image
  74. class="google-icon"
  75. src="/static/google-icon.png"
  76. mode="aspectFit"
  77. ></image>
  78. <text class="third-party-text">通过 Google 继续</text>
  79. </view>
  80. </view>
  81. <!-- 已有账号 -->
  82. <view class="existing-account">
  83. <text class="account-text">未注册账号</text>
  84. <text class="login-link" @click="goToRegistration">注册</text>
  85. </view>
  86. </view>
  87. </template>
  88. <script setup>
  89. import { ref } from "vue";
  90. const email = ref("");
  91. const phone = ref("");
  92. const agreed = ref(false);
  93. const switchType = ref("Email"); // 默认是邮箱注册
  94. const { safeAreaInsets } = uni.getSystemInfoSync();
  95. function goToIndex() {
  96. // 返回上一页
  97. uni.navigateTo({ url: '/pages/start/index/index' });
  98. }
  99. function switchEmail() {
  100. // 切换到邮箱注册
  101. switchType.value = "Email";
  102. }
  103. function switchPhone() {
  104. // 切换到手机注册
  105. switchType.value = "Phone";
  106. }
  107. function register() {
  108. // 注册逻辑
  109. if (!email.value) {
  110. uni.showToast({
  111. title: "请输入邮箱地址",
  112. icon: "none",
  113. });
  114. return;
  115. }
  116. if (!agreed.value) {
  117. uni.showToast({
  118. title: "请同意用户协议和隐私政策",
  119. icon: "none",
  120. });
  121. return;
  122. }
  123. // 发送注册请求
  124. console.log("注册:", email.value);
  125. }
  126. function loginWithApple() {
  127. // Apple登录逻辑
  128. console.log("通过Apple登录");
  129. }
  130. function loginWithGoogle() {
  131. // Google登录逻辑
  132. console.log("通过Google登录");
  133. }
  134. function goToRegistration() {
  135. // 跳转到登录页
  136. uni.navigateTo({
  137. url: "/pages/start/Registration/Registration",
  138. });
  139. }
  140. </script>
  141. <style scoped>
  142. .login-registration-container {
  143. display: flex;
  144. flex-direction: column;
  145. align-items: center;
  146. justify-content: center;
  147. padding: 0 40rpx;
  148. height: 100vh;
  149. background-color: #ffffff;
  150. }
  151. /* 自定义导航栏样式 */
  152. .custom-navbar {
  153. position: absolute;
  154. top: 0;
  155. left: 0;
  156. /* z-index: 999; */
  157. width: 90%;
  158. height: 80rpx;
  159. display: flex;
  160. justify-content: space-between;
  161. align-items: center;
  162. padding: 10rpx 40rpx;
  163. margin-bottom: 20rpx;
  164. }
  165. .nav-left,
  166. .nav-right {
  167. flex: 1;
  168. }
  169. .nav-right {
  170. display: flex;
  171. justify-content: flex-end;
  172. }
  173. .back-btn,
  174. .headphone-btn {
  175. font-size: 36rpx;
  176. font-weight: bold;
  177. color: #333333;
  178. padding: 10rpx;
  179. }
  180. .logo {
  181. width: 120rpx;
  182. height: 120rpx;
  183. margin-bottom: 60rpx;
  184. border-radius: 20%;
  185. }
  186. .welcome-text {
  187. font-size: 48rpx;
  188. font-weight: bold;
  189. color: #333333;
  190. margin-bottom: 60rpx;
  191. text-align: left;
  192. align-self: flex-start;
  193. }
  194. .switch-container {
  195. display: flex;
  196. margin-bottom: 40rpx;
  197. align-self: flex-start;
  198. }
  199. .switch-item {
  200. font-size: 28rpx;
  201. color: #999999;
  202. padding: 10rpx 20rpx;
  203. position: relative;
  204. }
  205. .switch-item::after {
  206. content: "";
  207. position: absolute;
  208. bottom: 0;
  209. left: 50%;
  210. transform: translateX(-50%);
  211. width: 60%; /* 控制边框宽度 */
  212. height: 2rpx;
  213. background-color: transparent;
  214. }
  215. .switch-item.active {
  216. color: #333333;
  217. font-weight: 700;
  218. }
  219. .switch-item.active::after {
  220. content: "";
  221. position: absolute;
  222. top: 60rpx;
  223. bottom: 0;
  224. left: 50%;
  225. transform: translateX(-50%);
  226. width: 30%; /* 控制边框宽度 */
  227. height: 7rpx;
  228. background-color: #333333;
  229. }
  230. .input-container {
  231. width: 100%;
  232. margin-bottom: 40rpx;
  233. }
  234. .input-field {
  235. width: 90%;
  236. height: 80rpx;
  237. border-radius: 20rpx;
  238. border: 2rpx solid #e5e5e5;
  239. padding: 0 30rpx;
  240. font-size: 28rpx;
  241. color: #333333;
  242. background-color: #f5f5f5;
  243. }
  244. .agreement-container {
  245. /* display: flex; */
  246. align-items: center;
  247. margin-bottom: 40rpx;
  248. align-self: flex-start;
  249. }
  250. .checkbox {
  251. width: 10rpx;
  252. height: 10rpx;
  253. margin-right: 30rpx;
  254. /* flex: content; */
  255. }
  256. .agreement-text {
  257. margin-left: 20rpx;
  258. font-size: 24rpx;
  259. color: #666666;
  260. }
  261. .link {
  262. color: #333333;
  263. font-weight: bold;
  264. text-decoration: underline;
  265. }
  266. .register-btn {
  267. width: 100%;
  268. height: 80rpx;
  269. background-color: #333333;
  270. color: white;
  271. font-size: 32rpx;
  272. font-weight: bold;
  273. border-radius: 40rpx;
  274. margin-bottom: 40rpx;
  275. }
  276. .or-text {
  277. font-size: 24rpx;
  278. color: #999999;
  279. margin-bottom: 40rpx;
  280. }
  281. .third-party-login {
  282. width: 100%;
  283. margin-bottom: 60rpx;
  284. }
  285. .third-party-text {
  286. font-weight: bold;
  287. }
  288. .third-party-btn {
  289. width: 100%;
  290. height: 80rpx;
  291. background-color: white;
  292. border: 2rpx solid #e5e5e5;
  293. border-radius: 40rpx;
  294. display: flex;
  295. align-items: center;
  296. justify-content: center;
  297. margin-bottom: 20rpx;
  298. font-size: 28rpx;
  299. color: #333333;
  300. }
  301. .apple-icon {
  302. width: 30rpx;
  303. height: 30rpx;
  304. margin-right: 20rpx;
  305. }
  306. .google-icon {
  307. width: 30rpx;
  308. height: 30rpx;
  309. margin-right: 20rpx;
  310. }
  311. .existing-account {
  312. display: flex;
  313. align-items: center;
  314. }
  315. .account-text {
  316. font-size: 24rpx;
  317. color: #666666;
  318. }
  319. .login-link {
  320. font-size: 24rpx;
  321. font-weight: bold;
  322. color: #333333;
  323. margin-left: 10rpx;
  324. text-decoration: underline;
  325. }
  326. </style>