123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <template>
- <div class="share">
- <div class="main">
- <h3>分享页面</h3>
- <div class="code">
- <img src="@/assets/img/code.png" alt="" />
- <p>长按保存二维码<br />或点击 复制链接</p>
- </div>
- <div class="btnn" @click="copyPcTxt">复制分享链接</div>
- <!-- 关闭按钮 -->
- <div class="close" @click="$emit('close')"></div>
- </div>
- </div>
- </template>
- <script>
- export default {
- name: "share",
- components: {},
- data() {
- //这里存放数据
- return {};
- },
- //监听属性 类似于data概念
- computed: {},
- //监控data中的数据变化
- watch: {},
- //方法集合
- methods: {
- //点击复制链接
- copyPcTxt() {
- // 存储传递过来的数据
- let OrderNumber = "9999999999";
- // 创建一个input 元素
- // createElement() 方法通过指定名称创建一个元素
- let newInput = document.createElement("input");
- // 讲存储的数据赋值给input的value值
- newInput.value = OrderNumber;
- // appendChild() 方法向节点添加最后一个子节点。
- document.body.appendChild(newInput);
- // 选中input元素中的文本
- // select() 方法用于选择该元素中的文本。
- newInput.select();
- // 执行浏览器复制命令
- // execCommand方法是执行一个对当前文档,当前选择或者给出范围的命令
- document.execCommand("Copy");
- // 清空输入框
- newInput.remove();
- // 下面是element的弹窗 不需要的自行删除就好
- this.$message({
- message: "复制成功",
- type: "success",
- });
- },
- },
- //生命周期 - 创建完成(可以访问当前this实例)
- created() {},
- //生命周期 - 挂载完成(可以访问DOM元素)
- mounted() {},
- beforeCreate() {}, //生命周期 - 创建之前
- beforeMount() {}, //生命周期 - 挂载之前
- beforeUpdate() {}, //生命周期 - 更新之前
- updated() {}, //生命周期 - 更新之后
- beforeDestroy() {}, //生命周期 - 销毁之前
- destroyed() {}, //生命周期 - 销毁完成
- activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
- };
- </script>
- <style lang='less' scoped>
- .share {
- position: fixed;
- width: 100vw;
- height: calc(100% - 50px);
- bottom: 0;
- left: 0;
- z-index: 9998;
- &::before {
- content: "";
- position: absolute;
- left: 0;
- top: 0;
- width: 100%;
- height: 100%;
- backdrop-filter: blur(10px);
- z-index: -1;
- }
- .main {
- padding-top: 20px;
- border-radius: 8px;
- width: 320px;
- height: 470px;
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- background-color: rgba(161, 101, 59, 0.8);
- & > h3 {
- color: #fff6d2;
- font-size: 20px;
- text-align: center;
- }
- .code {
- padding-top: 15px;
- background-color: #fff6d2;
- border-radius: 5px;
- width: 240px;
- height: 280px;
- margin: 20px auto;
- text-align: center;
- & > img {
- width: 200px;
- height: 200px;
- }
- & > p {
- color: #774926;
- margin-top: 15px;
- font-size: 14px;
- }
- }
- .btnn {
- cursor: pointer;
- margin: 0 auto;
- width: 240px;
- height: 40px;
- border-radius: 20px;
- border: 2px solid #fff6d2;
- font-size: 20px;
- color: #fff6d2;
- text-align: center;
- line-height: 36px;
- }
- .close {
- cursor: pointer;
- position: absolute;
- left: 50%;
- bottom: 15px;
- transform: translateX(-50%);
- width: 30px;
- height: 30px;
- background: url("../../../assets/img/close.png");
- background-size: 100% 100%;
- }
- }
- }
- </style>
|