// component/privacy-popup/privacy-popup.ts
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    show: false,
    needAuthorization: false,
    privacyContractName: ''
  },
  /**
   * 组件的方法列表
   */
  methods: {
    check() {
      if (wx.canIUse('getPrivacySetting')) {
        wx.getPrivacySetting({
          success: res => {
            console.log(res)
            this.setData({
              ...res,
              show: res.needAuthorization
            })
            if (!res.needAuthorization) {
              this.privacySubmit()
            }
          }
        })
      } else {
        this.privacySubmit()
      }
    },
    handleAgreePrivacyAuthorization() {
      this.privacySubmit()
    },
    privacySubmit() {
      this.triggerEvent('privacySubmit')
      this.hidden()
    },
    hidden() {
      this.setData({
        show: false
      })
    },
    openPrivacyContract() {
      wx.openPrivacyContract({
        success() {
          console.log('打开隐私协议')
        }
      })
    }
  }
})
