resetPassword.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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-content" :class="dialogContentClass">
  7. <view class="form-label-input">
  8. <view class="phone-form-label"><text class="form-label-require"></text>密码</view>
  9. <input v-model="password" placeholder="请输入密码" />
  10. </view>
  11. </view>
  12. <view class="common-btn-box">
  13. <view class="not-confirm-btn" @click="handleClose">{{notBtn}}</view>
  14. <view class="confirm-btn" @click="confirmBtn">{{okBtn}}</view>
  15. </view>
  16. </view>
  17. </view>
  18. </uni-popup>
  19. </template>
  20. <script setup>
  21. import {
  22. ref
  23. } from 'vue';
  24. import {
  25. getUserGuanliReset
  26. } from "@/api/zizhanghao.js"
  27. const props = defineProps({
  28. title: {
  29. type: String,
  30. default: ''
  31. },
  32. dialogContentClass: {
  33. type: String,
  34. require: true,
  35. default: 'content-center-class'
  36. },
  37. notBtn: {
  38. type: String,
  39. require: true,
  40. default: '取消'
  41. },
  42. okBtn: {
  43. type: String,
  44. require: true,
  45. default: '确认'
  46. },
  47. });
  48. const password = ref('');
  49. const userId = ref(null)
  50. const commonPopup = ref(null); // 索引
  51. const $emit = defineEmits(['confirm-btn'])
  52. // 打开弹窗
  53. function handleShow(userIdData) {
  54. userId.value = userIdData;
  55. commonPopup.value.open();
  56. }
  57. // 取消
  58. function handleClose() {
  59. password.value = null;
  60. userId.value = null;
  61. commonPopup.value.close();
  62. }
  63. // 确认
  64. function confirmBtn() {
  65. if (!password.value) {
  66. uni.showToast({
  67. icon: 'none',
  68. title: '请输入密码'
  69. })
  70. return;
  71. }
  72. getUserGuanliReset({
  73. userId: userId.value,
  74. password: password.value
  75. }).then(res => {
  76. if (res.data) {
  77. uni.showToast({
  78. icon: 'none',
  79. title: '更新成功'
  80. })
  81. $emit('confirm-btn');
  82. commonPopup.value.close();
  83. password.value = null;
  84. userId.value = null;
  85. }
  86. })
  87. }
  88. defineExpose({
  89. handleShow,
  90. handleClose
  91. })
  92. </script>
  93. <style>
  94. </style>