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.

398 lines
7.6 KiB

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