// promoPop/promoPop.js
Component({
  properties: {
    show: {           // 控制显示/隐藏
      type: Boolean,
      value: false
    },
    qrcode: {         // 二维码图片
      type: String,
      value: ''
    },
    link: {           // 推广链接
      type: String,
      value: ''
    },
    closeIcon: {      // 关闭按钮图片
      type: String,
      value: ''
    }
  },
  methods: {
    // 点击遮罩或关闭按钮关闭弹窗
    close() {
      this.triggerEvent('close');
    },
    // 放大二维码
    previewQrcode() {
      if (this.data.qrcode) {
        wx.previewImage({
          urls: [this.data.qrcode]
        });
      }
    },
    // 复制推广链接
    copyLink() {
      if (this.data.link) {
        wx.setClipboardData({
          data: this.data.link,
          success: () => {
            wx.showToast({
              title: '复制成功',
              icon: 'success'
            });
          }
        });
      }
    }
  }
});
