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.

177 lines
3.7 KiB

4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
  1. <template>
  2. <view class="main">
  3. <view :style="{height:iSMT+'px'}"></view>
  4. <view style="height:1.5vh;"/>
  5. <view class="title">
  6. <text class="label">确认新密码</text>
  7. </view>
  8. <view class="top">
  9. <view class="top-list">
  10. <view class="left">
  11. <image class="image-lock" src="/static/my/unlock.png"/>
  12. <input type="password" :type="pwdType" placeholder="请输入新密码" class="input" v-model="oldPassword"
  13. />
  14. <image class="image-eye" :src="pwdType === 1 ? '/static/my/hideEye.png' : '/static/my/openEye.png'"
  15. @click="changeEye(1)"/>
  16. </view>
  17. </view>
  18. <view class="top-list">
  19. <view class="left">
  20. <image class="image-lock" src="/static/my/unlock.png"/>
  21. <input type="password" :type="pwdType2" placeholder="再次确认" class="input" v-model="newPassword"/>
  22. <image class="image-eye" :src="pwdType === 1 ? '/static/my/hideEye.png' : '/static/my/openEye.png'"
  23. @click="changeEye(2)"/>
  24. </view>
  25. </view>
  26. <text class="tips">密码最少8位数</text>
  27. </view>
  28. <view class="bottom">
  29. <button class="change-btn" @click="confirmChange">确认</button>
  30. </view>
  31. </view>
  32. </template>
  33. <script setup>
  34. import {onMounted, ref} from 'vue'
  35. import {updatePassword} from "@/api/setting/nextPwd";
  36. const iSMT = ref(0)
  37. const pwdType = ref('password')
  38. const pwdType2 = ref('password')
  39. // 绑定的数据 旧密码 新密码 确认密码
  40. const oldPassword = ref('')
  41. const newPassword = ref('')
  42. // 点击确认按钮
  43. const confirmChange = async () => {
  44. if (newPassword.value !== oldPassword.value) {
  45. uni.showToast({title: '两次输入的密码不一致', icon: 'none'})
  46. return
  47. }
  48. const updatePasswordPromise = updatePassword({
  49. oldPassword: oldPassword.value,
  50. newPassword: newPassword.value
  51. })
  52. updatePasswordPromise
  53. .then(res => {
  54. if (res.code === 200) {
  55. uni.showToast({ title: '修改成功', icon: 'success' });
  56. } else {
  57. uni.showToast({ title: res.message,icon: 'none' });
  58. }
  59. })
  60. .catch(err => {
  61. console.log('修改密码失败:', err);
  62. });
  63. }
  64. const changeEye = (type) => {
  65. if (type === 1) {
  66. pwdType.value = pwdType.value === 'password' ? 'text' : 'password'
  67. } else {
  68. pwdType2.value = pwdType2.value === 'password' ? 'text' : 'password'
  69. }
  70. }
  71. onMounted(() => {
  72. // 状态栏高度
  73. iSMT.value = uni.getSystemInfoSync().statusBarHeight;
  74. console.log('看看高度', iSMT.value)
  75. })
  76. </script>
  77. <style>
  78. .title {
  79. height: 8.5vh;
  80. background-color: white;
  81. }
  82. .label {
  83. height: 8.5vh;
  84. font-size: 40rpx;
  85. font-weight: bold;
  86. display: flex;
  87. align-items: center;
  88. padding: 0 60rpx;
  89. }
  90. .top {
  91. height: auto;
  92. background-color: white;
  93. display: flex;
  94. flex-direction: column;
  95. align-items: center;
  96. }
  97. .top-list {
  98. width: 630rpx;
  99. height: 7vh;
  100. margin: 0rpx 40rpx;
  101. display: flex;
  102. align-items: center;
  103. border-bottom: 1rpx solid #eee;
  104. }
  105. .left {
  106. flex: 1;
  107. display: flex;
  108. align-items: center;
  109. }
  110. .input {
  111. flex: 1;
  112. height: 70rpx;
  113. font-size: 29rpx;
  114. margin-left: 20rpx;
  115. }
  116. .bottom {
  117. height: 22vh;
  118. background-color: white;
  119. display: flex;
  120. align-items: center;
  121. justify-content: center;
  122. }
  123. .change-btn {
  124. height: 85rpx;
  125. width: 610rpx;
  126. padding: 0 20rpx;
  127. background-color: black;
  128. color: white;
  129. border-radius: 40rpx;
  130. display: flex;
  131. align-items: center;
  132. justify-content: center;
  133. }
  134. .tips {
  135. font-size: 24rpx;
  136. color: #999;
  137. margin-top: 20rpx;
  138. margin-left: 60rpx;
  139. align-self: flex-start;
  140. /* 这是左对齐 */
  141. }
  142. .image-lock{
  143. width:40rpx;
  144. height:40rpx;
  145. }
  146. .image-eye{
  147. width:40rpx;
  148. height:30rpx;
  149. }
  150. </style>