SetPassword.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <div class="page-container">
  3. <!-- 导航栏 -->
  4. <div class="nav-bar">
  5. <div class="nav-left" @click="$router.back()">
  6. <svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M15 18L9 12L15 6" stroke="#333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
  7. </div>
  8. <div class="nav-title" >设置密码</div>
  9. <div class="nav-right"></div>
  10. </div>
  11. <div class="content">
  12. <!-- 表单区域 -->
  13. <div class="form-group">
  14. <label class="form-label">填写支付密码</label>
  15. <div class="input-wrapper">
  16. <input
  17. type="password"
  18. v-model="password"
  19. placeholder="请输入"
  20. class="custom-input"
  21. maxlength="6"
  22. />
  23. </div>
  24. </div>
  25. <div class="form-group">
  26. <label class="form-label">请确认支付密码</label>
  27. <!-- 这里的 class 用于演示截图中的选中状态效果,实际使用中浏览器自带 focus 样式 -->
  28. <div class="input-wrapper">
  29. <input
  30. type="password"
  31. v-model="confirmPassword"
  32. placeholder="请输入"
  33. class="custom-input"
  34. maxlength="6"
  35. />
  36. </div>
  37. </div>
  38. <!-- 提交按钮 -->
  39. <div class="footer-action">
  40. <button class="submit-btn" @click="handleSubmit">提交</button>
  41. </div>
  42. </div>
  43. </div>
  44. </template>
  45. <script setup>
  46. import { ref } from 'vue';
  47. import { useRouter } from 'vue-router';
  48. // 引入 Vant Toast (如果你的项目有安装 Vant,没有则用 alert)
  49. // import { showToast } from 'vant';
  50. const router = useRouter();
  51. const password = ref('');
  52. const confirmPassword = ref('');
  53. const handleSubmit = () => {
  54. if (!password.value || !confirmPassword.value) {
  55. alert('请输入密码');
  56. return;
  57. }
  58. if (password.value !== confirmPassword.value) {
  59. alert('两次输入的密码不一致');
  60. return;
  61. }
  62. if (password.value.length < 6) {
  63. alert('密码长度不能少于6位');
  64. return;
  65. }
  66. // 提交逻辑...
  67. console.log('提交密码:', password.value);
  68. alert('设置成功');
  69. router.back();
  70. };
  71. </script>
  72. <style scoped>
  73. .page-container {
  74. min-height: 100vh;
  75. background-color: #fff;
  76. display: flex; flex-direction: column;
  77. }
  78. /* 导航栏 */
  79. .nav-bar {
  80. display: flex; justify-content: space-between; align-items: center;
  81. height: 44px; padding: 0 16px; background: #fff;
  82. position: sticky; top: 0; z-index: 10;
  83. }
  84. .nav-title { font-size: 18px; font-weight: 600; color: #333; }
  85. .nav-left, .nav-right { width: 40px; display: flex; align-items: center; }
  86. /* 内容区 */
  87. .content {
  88. padding: 20px;
  89. flex: 1;
  90. display: flex; flex-direction: column;
  91. }
  92. .form-group {
  93. margin-bottom: 24px;
  94. }
  95. .form-label {
  96. display: block;
  97. font-size: 16px;
  98. color: #333;
  99. font-weight: 500;
  100. margin-bottom: 12px;
  101. }
  102. /* 输入框样式 */
  103. .custom-input {
  104. width: 100%;
  105. height: 50px;
  106. background: #F7F8FA; /* 截图中的浅灰背景 */
  107. border: 1px solid transparent; /* 默认无边框 */
  108. border-radius: 8px;
  109. padding: 0 16px;
  110. font-size: 16px;
  111. color: #333;
  112. box-sizing: border-box;
  113. outline: none; /* 去掉浏览器默认的黑框 */
  114. transition: all 0.2s;
  115. }
  116. /* 占位符颜色 */
  117. .custom-input::placeholder {
  118. color: #C2C4CC;
  119. }
  120. /* 核心细节:输入框聚焦时变蓝 */
  121. .custom-input:focus {
  122. border-color: #2B6BFF; /* 截图中的亮蓝色边框 */
  123. background: #fff; /* 聚焦时背景可能变白,视设计而定,这里保留灰底或变白均可 */
  124. }
  125. /* 底部按钮区域 */
  126. .footer-action {
  127. margin-top: auto; /* 把按钮推到最底部 */
  128. padding-bottom: 30px;
  129. }
  130. .submit-btn {
  131. width: 100%;
  132. height: 48px;
  133. background: #E02F44; /* 截图中的红色 */
  134. color: #fff;
  135. border: none;
  136. border-radius: 24px;
  137. font-size: 16px;
  138. font-weight: 600;
  139. cursor: pointer;
  140. }
  141. .submit-btn:active {
  142. opacity: 0.9;
  143. }
  144. </style>