1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- Component({
- properties: {
- },
- /**
- * 组件的初始数据
- */
- data: {
- state: false,
- img: ''
- },
- lifetimes: {
- attached: function () {
- if (wx.getPrivacySetting) {
- wx.getPrivacySetting({
- success: res => {
- if (res.needAuthorization) {
- this.setData({
- state: true
- })
- if (typeof this.getTabBar === 'function') {
- this.getTabBar().setData({
- mask: true
- })
- }
- } else {
- this.triggerEvent("agree")
- }
- },
- fail: () => {},
- complete: () => {},
- })
- } else {
- // 低版本基础库不支持 wx.getPrivacySetting 接口,隐私接口可以直接调用
- this.triggerEvent("agree")
- }
- },
- },
- methods: {
- handleAgree(e) {
- this.triggerEvent("agree")
- this.setData({
- state: false
- })
- this.getTabBar().setData({
- mask: false
- })
- },
- openPrivacyContract() {
- wx.openPrivacyContract({
- success: res => {
- console.log('openPrivacyContract success')
- },
- fail: res => {
- console.error('openPrivacyContract fail', res)
- }
- })
- }
- }
- })
|