图书馆小程序
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.

114 lines
2.2 KiB

1 week ago
  1. <template>
  2. <view class="container">
  3. <view class="form-box">
  4. <!-- 原密码 -->
  5. <view class="form-item">
  6. <text class="label">旧密码</text>
  7. <input
  8. class="input"
  9. type="password"
  10. placeholder="请输入当前密码"
  11. v-model="oldPwd"
  12. />
  13. </view>
  14. <!-- 新密码 -->
  15. <view class="form-item">
  16. <text class="label">新密码</text>
  17. <input
  18. class="input"
  19. type="password"
  20. placeholder="请输入6-16位新密码"
  21. v-model="newPwd"
  22. />
  23. </view>
  24. <!-- 确认新密码 -->
  25. <view class="form-item">
  26. <text class="label">确认新密码</text>
  27. <input
  28. class="input"
  29. type="password"
  30. placeholder="请再次输入新密码"
  31. v-model="confirmPwd"
  32. />
  33. </view>
  34. <!-- 提交按钮 -->
  35. <button class="submit-btn" @click="submit">确认修改</button>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. data() {
  42. return {
  43. oldPwd: '',
  44. newPwd: '',
  45. confirmPwd: ''
  46. }
  47. },
  48. methods: {
  49. submit() {
  50. const { oldPwd, newPwd, confirmPwd } = this
  51. if (!oldPwd) {
  52. uni.showToast({ title: '请输入旧密码', icon: 'none' })
  53. return
  54. }
  55. if (!newPwd || newPwd.length < 6) {
  56. uni.showToast({ title: '新密码至少6位', icon: 'none' })
  57. return
  58. }
  59. if (newPwd !== confirmPwd) {
  60. uni.showToast({ title: '两次密码不一致', icon: 'none' })
  61. return
  62. }
  63. // 这里写接口请求
  64. uni.showToast({
  65. title: '修改成功',
  66. icon: 'success'
  67. })
  68. setTimeout(() => {
  69. uni.navigateBack()
  70. }, 1500)
  71. }
  72. }
  73. }
  74. </script>
  75. <style lang="scss" scoped>
  76. .container {
  77. padding: 20px;
  78. }
  79. .form-item {
  80. margin-bottom: 20px;
  81. }
  82. .label {
  83. display: block;
  84. font-size: 15px;
  85. color: #333;
  86. margin-bottom: 8px;
  87. }
  88. .input {
  89. height: 44px;
  90. padding: 0 15px;
  91. background-color: #fff;
  92. border: 1px solid #eee;
  93. border-radius: 6px;
  94. font-size: 15px;
  95. }
  96. .submit-btn {
  97. margin-top: 50px;
  98. padding: 5px 0;
  99. background-color: #007aff;
  100. color: #fff;
  101. border-radius: 23px;
  102. font-size: 16px;
  103. }
  104. </style>