当前位置:首页 > VUE

vue实现签约合作弹窗

2026-02-09 18:09:40VUE

实现思路

使用Vue的组件化特性封装签约合作弹窗,通过v-modelprops控制显示/隐藏,结合<transition>实现动画效果。弹窗内容可包含表单、协议条款等交互元素。

基础组件结构

<template>
  <transition name="fade">
    <div class="contract-modal" v-show="visible">
      <div class="modal-content">
        <h3>签约合作</h3>
        <div class="contract-text">这里是协议内容...</div>
        <form @submit.prevent="handleSubmit">
          <input v-model="formData.name" placeholder="企业名称">
          <button type="submit">确认签约</button>
        </form>
        <button @click="close">关闭</button>
      </div>
    </div>
  </transition>
</template>

核心功能实现

<script>
export default {
  props: {
    value: Boolean // 通过v-model控制显示
  },
  data() {
    return {
      formData: {
        name: ''
      }
    }
  },
  computed: {
    visible: {
      get() { return this.value },
      set(val) { this.$emit('input', val) }
    }
  },
  methods: {
    close() {
      this.visible = false
    },
    handleSubmit() {
      // 提交逻辑
      console.log('签约数据:', this.formData)
      this.close()
    }
  }
}
</script>

样式设计

<style scoped>
.contract-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  padding: 20px;
  border-radius: 8px;
  width: 80%;
  max-width: 500px;
}

.fade-enter-active, .fade-leave-active {
  transition: opacity 0.3s;
}
.fade-enter, .fade-leave-to {
  opacity: 0;
}
</style>

使用示例

<template>
  <div>
    <button @click="showModal = true">打开签约弹窗</button>
    <contract-modal v-model="showModal"/>
  </div>
</template>

<script>
import ContractModal from './ContractModal.vue'

export default {
  components: { ContractModal },
  data() {
    return {
      showModal: false
    }
  }
}
</script>

进阶功能建议

  1. 协议内容滚动确认:添加滚动监听,确保用户阅读完协议才允许签约

    data() {
    return {
     isScrolledToBottom: false
    }
    },
    methods: {
    handleScroll(e) {
     const el = e.target
     this.isScrolledToBottom = el.scrollHeight - el.scrollTop === el.clientHeight
    }
    }
  2. 多步骤签约流程:使用动态组件切换不同签约阶段

    <component :is="currentStepComponent"/>
  3. 电子签名支持:集成签名板组件

    <signature-pad @save="saveSignature"/>
  4. 移动端适配:通过媒体查询调整弹窗样式

    vue实现签约合作弹窗

    @media (max-width: 768px) {
    .modal-content {
     width: 95%;
    }
    }

标签: vue
分享给朋友:

相关文章

vue实现iframe

vue实现iframe

Vue 中实现 iframe 的方法 在 Vue 项目中,可以通过多种方式实现 iframe 的嵌入。以下是几种常见的方法: 使用原生 HTML iframe 标签 直接在 Vue 组件的模板中使用…

tabbar 实现 vue

tabbar 实现 vue

在 Vue 中实现 TabBar 功能可以通过多种方式完成,以下是几种常见的方法: 使用 Vue Router 结合自定义组件 创建一个自定义的 TabBar 组件,结合 Vue Router 实现…

vue底部实现

vue底部实现

Vue 底部实现方法 在 Vue 项目中实现底部布局可以通过多种方式完成,以下是一些常见的方法: 使用固定定位 将底部元素固定在页面底部,适用于单页应用或需要始终显示的底部栏。 <temp…

vue模版实现

vue模版实现

Vue 模板实现方法 Vue 模板是 Vue.js 的核心特性之一,用于声明式地将 DOM 绑定至底层 Vue 实例的数据。以下是几种常见的 Vue 模板实现方式: 单文件组件(SFC) 使用 .v…

vue实现word文档实现预览

vue实现word文档实现预览

在Vue中实现Word文档预览可以通过多种方式实现,以下是几种常见的方法: 使用mammoth.js库 mammoth.js是一个将Word文档(.docx)转换为HTML的JavaScript库,…

vue滚动加载实现

vue滚动加载实现

vue滚动加载实现 滚动加载是一种常见的优化手段,通过监听滚动事件动态加载数据,减少初始渲染压力。以下是几种实现方式: 使用IntersectionObserver API Intersection…