dialog-confirm.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <dialog-base ref="baseDialog" title="提示">
  3. <view class="msg uni-row">{{message}}</view>
  4. <view class="btn-container uni-row">
  5. <button type="primary" class="btn" @click="handleConfirm">确认</button>
  6. <button type="primary" class="btn" @click="handleCancel">取消</button>
  7. </view>
  8. </dialog-base>
  9. </template>
  10. <script setup>
  11. import {
  12. ref,
  13. getCurrentInstance
  14. } from 'vue'
  15. import {
  16. saveUserequipment
  17. } from '@/api/business/userEquipment/userEquipment.js'
  18. import { defineProps } from 'vue'
  19. const baseDialog = ref(null)
  20. const message = ref('')
  21. const reqParam = ref({})
  22. const fatMethod = defineProps({
  23. init: Function
  24. })
  25. function open(msg,data) {
  26. message.value = msg;
  27. reqParam.value = data;
  28. baseDialog.value.open();
  29. }
  30. function handleConfirm() {
  31. saveUserequipment(reqParam.value).then(res => {
  32. if(res.code === 200){
  33. uni.showToast({
  34. icon: "success",
  35. title: "设备绑定成功"
  36. })
  37. }
  38. })
  39. close();
  40. }
  41. function handleCancel() {
  42. close();
  43. }
  44. function close() {
  45. baseDialog.value.close()
  46. }
  47. defineExpose({
  48. open
  49. })
  50. </script>
  51. <style lang="scss">
  52. .dialog-body {
  53. .msg {
  54. height: 300rpx;
  55. justify-content: center;
  56. align-items: center;
  57. }
  58. .btn-container {
  59. margin-top: 32rpx;
  60. .btn {
  61. flex: 1;
  62. margin: 0 10rpx;
  63. }
  64. }
  65. }
  66. </style>