resetPassword.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <uni-popup ref="commonPopup" :animation="false" :is-mask-click="false" mask-background-color="rgba(0, 0, 0, 0.4)">
  3. <view class="phone-common-dialog">
  4. <view class="common-body-box">
  5. <view class="common-title">{{title}}</view>
  6. <view class="common-input-box">
  7. <view class="common-input-row">
  8. <view class="common-input-label"><text class="common-label-require">*</text>新密码:</view>
  9. <input class="common-input" v-model="password" placeholder="请输入新密码" />
  10. </view>
  11. <view class="common-input-row">
  12. <view class="common-input-label"><text class="common-label-require">*</text>确认密码:</view>
  13. <input class="common-input" v-model="password2" placeholder="请确认密码" />
  14. </view>
  15. </view>
  16. <view class="common-btn-box">
  17. <view class="not-confirm-btn" @click="handleClose">{{notBtn}}</view>
  18. <view class="confirm-btn" @click="confirmBtn">{{okBtn}}</view>
  19. </view>
  20. </view>
  21. </view>
  22. </uni-popup>
  23. </template>
  24. <script setup>
  25. import {
  26. ref
  27. } from 'vue';
  28. import {
  29. getUserGuanliReset
  30. } from "@/api/zizhanghao.js"
  31. const props = defineProps({
  32. title: {
  33. type: String,
  34. default: '重置密码'
  35. },
  36. dialogContentClass: {
  37. type: String,
  38. require: true,
  39. default: 'content-center-class'
  40. },
  41. notBtn: {
  42. type: String,
  43. require: true,
  44. default: '取消'
  45. },
  46. okBtn: {
  47. type: String,
  48. require: true,
  49. default: '确认'
  50. },
  51. });
  52. const password = ref('');
  53. const password2 = ref('');
  54. const userId = ref(null)
  55. const commonPopup = ref(null); // 索引
  56. const $emit = defineEmits(['confirm-btn'])
  57. // 打开弹窗
  58. function handleShow(userIdData) {
  59. userId.value = userIdData;
  60. commonPopup.value.open();
  61. }
  62. // 取消
  63. function handleClose() {
  64. password.value = null;
  65. password2.value = null;
  66. userId.value = null;
  67. commonPopup.value.close();
  68. }
  69. // 确认
  70. function confirmBtn() {
  71. if (!password.value) {
  72. uni.showToast({
  73. icon: 'none',
  74. title: '请输入新密码'
  75. })
  76. return;
  77. }
  78. if (!password2.value) {
  79. uni.showToast({
  80. icon: 'none',
  81. title: '请确认密码'
  82. })
  83. return;
  84. }
  85. if (password.value !== password2.value) {
  86. uni.showToast({
  87. icon: 'none',
  88. title: '两次输入密码不同'
  89. })
  90. return;
  91. }
  92. getUserGuanliReset({
  93. userId: userId.value,
  94. password: password.value
  95. }).then(res => {
  96. if (res.data) {
  97. uni.showToast({
  98. icon: 'none',
  99. title: '更新成功'
  100. })
  101. $emit('confirm-btn');
  102. commonPopup.value.close();
  103. password.value = null;
  104. password2.value = null;
  105. userId.value = null;
  106. }
  107. })
  108. }
  109. defineExpose({
  110. handleShow,
  111. handleClose
  112. })
  113. </script>
  114. <style>
  115. </style>