resetPassword.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 class="form-label-input">
  12. <view class="phone-form-label"><text class="form-label-require"></text>确认密码</view>
  13. <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. userId.value = null;
  66. commonPopup.value.close();
  67. }
  68. // 确认
  69. function confirmBtn() {
  70. if (!password.value) {
  71. uni.showToast({
  72. icon: 'none',
  73. title: '请输入密码'
  74. })
  75. return;
  76. }
  77. if (!password2.value) {
  78. uni.showToast({
  79. icon: 'none',
  80. title: '请输入二次确认密码'
  81. })
  82. return;
  83. }
  84. if (password.value !== password2.value) {
  85. uni.showToast({
  86. icon: 'none',
  87. title: '两次输入密码不同'
  88. })
  89. return;
  90. }
  91. getUserGuanliReset({
  92. userId: userId.value,
  93. password: password.value
  94. }).then(res => {
  95. if (res.data) {
  96. uni.showToast({
  97. icon: 'none',
  98. title: '更新成功'
  99. })
  100. $emit('confirm-btn');
  101. commonPopup.value.close();
  102. password.value = null;
  103. userId.value = null;
  104. }
  105. })
  106. }
  107. defineExpose({
  108. handleShow,
  109. handleClose
  110. })
  111. </script>
  112. <style>
  113. </style>