收藏
回答

小程序隐私授权弹窗,拒绝按钮关不掉怎么办?

小程序隐私授权弹窗,拒绝按钮关不掉怎么办?

请大家帮忙看看,怎么能关闭这个弹窗? 谢谢 !


 // component/privacy/privacy.js

Component({

    /**

     * 组件的初始数据

     */

    data: {

        privacyContractName: '',

        showPrivacy: false

    },

    /**

     * 组件的生命周期

     */

    pageLifetimes: {

        show() {

            const that = this

         if( wx.getPrivacySetting){

            wx.getPrivacySetting({

                success(res) {

                    console.log("是否需要授权:",res.needAuthorization,  "\n隐私协议的名称为:", res.privacyContractName)

                    if (res.errMsg == "getPrivacySetting:ok") {

                        that.setData({

                            privacyContractName: res.privacyContractName,

                            showPrivacy: res.needAuthorization

                        })

                    }

                }

            })

         }else{

             console.log("基础库低于2.23.3版本")

         }

            

        }

    },

    /**

     * 组件的方法列表

     */

    methods: {

        // 打开隐私协议页面

        openPrivacyContract() {

            wx.openPrivacyContract({

                fail: () => {

                    wx.showToast({

                        title: '遇到错误',

                        icon: 'error'

                    })

                }

            })

        },

        // 拒绝隐私协议

        handleDisagree() {

        console.log("拒绝协议")

        wx.showToast({

            title: '需同意才能继续使用小程序',

            icon: 'none',

            duration: 2000

            })

       // 拒绝隐私协议

       const that= this

       that.setData({

           showPrivacy: true

       }) 

        // wx.exitMiniProgram()

     },

        // 同意隐私协议

        handleAgree() {

            const that= this

            that.setData({

                showPrivacy: false

            })

        },

    }

})


回答关注问题邀请回答
收藏

3 个回答

  • optimistic
    optimistic
    2023-09-14

    给你改了,标志位改为 false,这是代码控制问题

           // 拒绝隐私协议
    
           const that= this
    
           that.setData({
    
               showPrivacy: false
    
           }) 
    
    
    
    
    2023-09-14
    有用 1
    回复 1
  • 李振中@特产帮帮主
    李振中@特产帮帮主
    2023-09-14

    谢谢@Jerry,测试了一下还是不行。 看看能不能帮助写一个函数来关闭这个弹窗。

    2023-09-14
    有用
    回复 2
    • Jerry
      Jerry
      2023-09-14
      你照楼下的代码改,再试试
      2023-09-14
      回复
    • 李振中@特产帮帮主
      李振中@特产帮帮主
      2023-09-14回复Jerry
      改成这个 showPrivacy: false  就可以了
      2023-09-14
      回复
  • Jerry
    Jerry
    2023-09-14

     // 拒绝隐私协议

           const that= this

           that.setData({

               showPrivacy: true

           }) 


    2023-09-14
    有用
    回复
登录 后发表内容