12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- // miniprogram/privacyPopup/privacyPopup.js
- Component({
- data: {
- title: "用户隐私保护提示",
- desc1: "尊敬的用户: 您好!感谢您使用本产品,您在使用本产品前应当阅读并同意",
- urlTitle: "《用户隐私保护指引》",
- desc2: "如您同意",
- desc3: "请您点击“同意”按钮后使用我们的产品和服务,我们将依法保护您的个人信息",
- innerShow: false,
- height: 0,
- },
- lifetimes: {
- attached: function () {
- if (wx.getPrivacySetting) {
- wx.getPrivacySetting({
- success: res => {
- console.log("是否需要授权:", res.needAuthorization, "隐私协议的名称为:", res.privacyContractName)
- this.setData({
- urlTitle: res.privacyContractName
- })
- if (res.needAuthorization) {
- this.popUp()
- } else {
- this.triggerEvent("agree")
- }
- },
- fail: () => { },
- complete: () => { },
- })
- } else {
- // 低版本基础库不支持 wx.getPrivacySetting 接口,隐私接口可以直接调用
- this.triggerEvent("agree")
- }
- },
- },
- methods: {
- handleDisagree(e) {
- this.triggerEvent("disagree");
- wx.showModal({
- content: '很抱歉,如您不同意' + this.data.urlTitle + '可能无法继续正常使用我们的产品和服务,请您先同意哦~',
- confirmText: "好的",
- cancelText: "不同意",
- complete: (res) => {
- if (res.cancel) {
- wx.exitMiniProgram()
- }
-
- if (res.confirm) {
-
- }
- }
- })
- },
- handleAgree(e) {
- this.triggerEvent("agree");
- this.disPopUp()
- },
- popUp() {
- this.setData({
- innerShow: true
- })
- },
- disPopUp() {
- this.setData({
- innerShow: false
- })
- },
- openPrivacyContract() {
- wx.openPrivacyContract({
- success: res => {
- console.log('openPrivacyContract success')
- },
- fail: res => {
- console.error('openPrivacyContract fail', res)
- }
- })
- }
- }
- })
|