<script setup>
import  {ref,nextTick} from 'vue'
import WdPopup from "@/uni_modules/wot-design-uni/components/wd-popup/wd-popup.vue";
import TmButton from "@/uni_modules/tmui/components/tm-button/tm-button.vue";
const confirmState=ref(false)
const cancel=ref(true)
let onConfirm=null
let onCancel=null
const confirm=ref(true)
const contentText=ref('')
const sendCancel=()=>{
  confirmState.value=false
  if (typeof onCancel==='function'){
    onCancel()
  }
}
const sendConfirm=()=>{
  confirmState.value=false
  if (typeof onConfirm==='function'){
    onConfirm()
  }
}
const showConfirm=({content,onConfirm:confirm,onCancel:cancel})=>{
  confirmState.value=true
  contentText.value=content
  onConfirm=confirm
  onCancel=cancel
}
defineExpose({
  showConfirm
})
</script>
<template>
  <wd-popup custom-style="border-radius: 16rpx;" modal-style="background-color: rgba(0,0,0,0.3);" v-model="confirmState">
    <div class="flex flex-col w-[640rpx] h-[402rpx]">
      <div class="flex justify-center items-center h-[288rpx] text-[32rpx] font-bold text-[#1A1A1A]">
        {{contentText}}
      </div>
      <div class="flex flex-grow border-t-solid border-[#E7E7E7] border-1rpx text-[32rpx]">
        <div class="flex justify-center items-center text-[#1A1A1A]">
          <tm-button @click="sendCancel" :width="319" @touchstart="cancel=false" @touchend="cancel=true" :fontSize="32" :height="112" :margin="[0]" :font-color="'#1A1A1A'" :transprent="cancel" text label="取消"></tm-button>
        </div>
        <div class="h-[112rpx] w-[1rpx] bg-[#E7E7E7]"></div>
        <div class="flex justify-center items-center text-[#CF3050]">
          <tm-button @click="sendConfirm"  @touchstart="confirm=false" @touchend="confirm=true" :width="319" :fontSize="32" :transprent="confirm" :height="112" :margin="[0]" :font-color="'#46299D'" text label="确定"></tm-button>
        </div>
      </div>
    </div>
  </wd-popup>
</template>
