Browse Source

隐私保护设置更新

yuhao 1 year ago
parent
commit
afbdc6dbb9

+ 2 - 1
app.json

@@ -164,5 +164,6 @@
164 164
     "getLocation"
165 165
   ],
166 166
   "usingComponents": {},
167
-  "sitemapLocation": "sitemap.json"
167
+  "sitemapLocation": "sitemap.json",
168
+  "__usePrivacyCheck__": true
168 169
 }

+ 105 - 0
components/local/privacyPopup/privacyPopup.js

@@ -0,0 +1,105 @@
1
+let privacyHandler
2
+let privacyResolves = new Set()
3
+let closeOtherPagePopUpHooks = new Set()
4
+
5
+if (wx.onNeedPrivacyAuthorization) {
6
+  wx.onNeedPrivacyAuthorization(resolve => {
7
+    if (typeof privacyHandler === 'function') {
8
+      privacyHandler(resolve)
9
+    }
10
+  })
11
+}
12
+
13
+const closeOtherPagePopUp = (closePopUp) => {
14
+  closeOtherPagePopUpHooks.forEach(hook => {
15
+    if (closePopUp !== hook) {
16
+      hook()
17
+    }
18
+  })
19
+}
20
+
21
+Component({
22
+  data: {
23
+    title: "用户隐私保护提示",
24
+    desc1: "感谢您使用本小程序,您使用本小程序前应当阅井同意",
25
+    urlTitle: "《用户隐私保护指引》",
26
+    desc2: "当您点击同意并开始时用产品服务时,即表示你已理解并同息该条款内容,该条款将对您产生法律约束力。如您拒绝,将无法继续访问小程序。",
27
+    innerShow: false,
28
+    height: 0,
29
+  },
30
+  lifetimes: {
31
+    attached: function() {
32
+      const closePopUp = () => {
33
+        this.disPopUp()
34
+      }
35
+      privacyHandler = resolve => {
36
+        privacyResolves.add(resolve)
37
+        this.popUp()
38
+        // 额外逻辑:当前页面的隐私弹窗弹起的时候,关掉其他页面的隐私弹窗
39
+        closeOtherPagePopUp(closePopUp)
40
+      }
41
+      
42
+      this.closePopUp = closePopUp
43
+      closeOtherPagePopUpHooks.add(this.closePopUp)
44
+    },
45
+    detached: function() {
46
+      closeOtherPagePopUpHooks.delete(this.closePopUp)
47
+    }
48
+  },
49
+  methods: {
50
+    handleAgree(e) {
51
+      this.disPopUp()
52
+      // 这里演示了同时调用多个wx隐私接口时要如何处理:让隐私弹窗保持单例,点击一次同意按钮即可让所有pending中的wx隐私接口继续执行 (看page/index/index中的 wx.getClipboardData 和 wx.startCompass)
53
+      privacyResolves.forEach(resolve => {
54
+        resolve({
55
+          event: 'agree',
56
+          buttonId: 'agree-btn'
57
+        })
58
+      })
59
+      privacyResolves.clear()
60
+    },
61
+    handleDisagree(e) {
62
+      this.disPopUp()
63
+      privacyResolves.forEach(resolve => {
64
+        resolve({
65
+          event: 'disagree',
66
+        })
67
+      })
68
+      privacyResolves.clear()
69
+    },
70
+    popUp() {
71
+      if (this.data.innerShow === false) {
72
+        this.setData({
73
+          innerShow: true
74
+        })
75
+      }
76
+    },
77
+    disPopUp() {
78
+      if (this.data.innerShow === true) {
79
+        this.setData({
80
+          innerShow: false
81
+        })
82
+      }
83
+    },
84
+    openPrivacyContract() {
85
+      wx.openPrivacyContract({
86
+        success: res => {
87
+          console.log('openPrivacyContract success')
88
+        },
89
+        fail: res => {
90
+          console.error('openPrivacyContract fail', res)
91
+        }
92
+      })
93
+    },
94
+    tabBarPageShow() {
95
+      if (this.closePopUp) {
96
+        privacyHandler = resolve => {
97
+          privacyResolves.add(resolve)
98
+          this.popUp()
99
+          // 额外逻辑:当前页面的隐私弹窗弹起的时候,关掉其他页面的隐私弹窗
100
+          closeOtherPagePopUp(this.closePopUp)
101
+        }
102
+      }
103
+    }
104
+  }
105
+})

+ 4 - 0
components/local/privacyPopup/privacyPopup.json

@@ -0,0 +1,4 @@
1
+{
2
+    "component": true,
3
+    "usingComponents": {}
4
+}

+ 25 - 0
components/local/privacyPopup/privacyPopup.wxml

@@ -0,0 +1,25 @@
1
+<view wx:if="{{innerShow}}" class="weui-half-screen-dialog" style="border-color:rgb(64, 247, 94); border-style:solid; border-width:3px; position: fixed;  bottom:{{height}}px" >
2
+    <view class="weui-half-screen-dialog__hd">
3
+          <text class="weui-half-screen-dialog__title">{{title}}</text>
4
+    </view>
5
+    <view class="weui-half-screen-dialog__bd">
6
+        <view class="weui-half-screen-dialog__tips">{{desc1}}</view>
7
+        <view class="weui-half-screen-dialog__tips" style="color:blue" bindtap="openPrivacyContract">{{urlTitle}}</view>
8
+        <view class="weui-half-screen-dialog__tips">{{desc2}}</view>
9
+    </view>
10
+    <view class="weui-half-screen-dialog__ft">
11
+      <view class="weui-half-screen-dialog__btn-area">
12
+        <button id="disagree-btn"
13
+          type="default"
14
+          class="weui-btn"
15
+          bindtap="handleDisagree"
16
+        >不同意</button>
17
+        <button id="agree-btn"
18
+          type="default"
19
+          open-type="agreePrivacyAuthorization"
20
+          class="weui-btn"
21
+          bindagreeprivacyauthorization="handleAgree"
22
+        >同意并继续</button>
23
+      </view>
24
+    </view>
25
+  </view>

File diff suppressed because it is too large
+ 5177 - 0
components/local/privacyPopup/privacyPopup.wxss


+ 2 - 1
pages/home/home.json

@@ -7,6 +7,7 @@
7 7
     "home-skeleton": "../../components/local/home-skeleton/home-skeleton",
8 8
     "navigation": "../../components/local/navigation/navigation",
9 9
     "van-empty": "@vant/weapp/empty/index",
10
-    "van-popup": "@vant/weapp/popup/index"
10
+    "van-popup": "@vant/weapp/popup/index",
11
+    "privacy-popup": "../../components/local/privacyPopup/privacyPopup"
11 12
   }
12 13
 }

+ 2 - 2
pages/home/home.wxml

@@ -16,7 +16,6 @@
16 16
     </swiper-item>
17 17
   </swiper>
18 18
 </view>
19
-
20 19
   <!-- 自定义导航 -->
21 20
   <!-- TODO 遇到 bindtap触发不了的问题,应该是层级问题,暂时整体可点击 -->
22 21
   <navigation bindtap="goToStore">
@@ -318,4 +317,5 @@
318 317
 <!-- 悬浮领券图标 -->
319 318
 <!-- <view class="suspend" bindtap="getCoupon" wx:if="{{false}}">
320 319
   <image src="https://we-spa.oss-cn-shenzhen.aliyuncs.com/wxapp/20220822/%E7%BB%84%205%402x.png"></image>
321
-</view> -->
320
+</view> -->
321
+<privacy-popup></privacy-popup>

+ 4 - 0
pages/login/login.js

@@ -89,6 +89,7 @@ Page({
89 89
     wx.getUserProfile({
90 90
       desc: 'desc',
91 91
       success: (res) => {
92
+        console.log(res);
92 93
         that.setData(
93 94
           {
94 95
             userInfo: JSON.parse(res.rawData)
@@ -105,6 +106,9 @@ Page({
105 106
           }
106 107
         )
107 108
         console.log(JSON.parse(res.rawData))
109
+      },
110
+      fail:(res)=>{
111
+          console.log(res,111111);
108 112
       }
109 113
     })
110 114
   },

+ 3 - 1
pages/login/login.json

@@ -1,5 +1,7 @@
1 1
 {
2 2
   "navigationBarTitleText": "登录",
3 3
   "navigationBarBackgroundColor": "#fff",
4
-  "usingComponents": {}
4
+  "usingComponents": {
5
+    "privacy-popup": "../../components/local/privacyPopup/privacyPopup"
6
+  }
5 7
 }

+ 1 - 0
pages/login/login.wxml

@@ -1,4 +1,5 @@
1 1
 <view class="content flex-column">
2
+  <privacy-popup></privacy-popup>
2 3
   <view class="box flex-column flex-center">
3 4
     <image class="logo" src="/images/logo.png"></image>
4 5
     <text class="tips">登录了解更多变美项目</text>

+ 1 - 3
project.config.json

@@ -102,7 +102,5 @@
102 102
     "ignore": [],
103 103
     "include": []
104 104
   },
105
-  "appid": "wx53445e50df00f712",
106
-  "projectname": "we_spa",
107
-  "libVersion": "2.21.0"
105
+  "appid": "wx53445e50df00f712"
108 106
 }

File diff suppressed because it is too large
+ 3 - 428
project.private.config.json