diff --git a/miniprogram/app.json b/miniprogram/app.json index b0e8d37..4244152 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,7 +1,8 @@ { "pages": [ "pages/home/home", - "pages/more/more" + "pages/more/more", + "components/UserPrivacyDialog/index" ], "permission": { "scope.userLocation": { @@ -39,5 +40,6 @@ }, "debug": true, "sitemapLocation": "sitemap.json", - "lazyCodeLoading": "requiredComponents" + "lazyCodeLoading": "requiredComponents", + "__usePrivacyCheck__": true } \ No newline at end of file diff --git a/miniprogram/components/UserPrivacyDialog/index.js b/miniprogram/components/UserPrivacyDialog/index.js new file mode 100644 index 0000000..c7e4392 --- /dev/null +++ b/miniprogram/components/UserPrivacyDialog/index.js @@ -0,0 +1,60 @@ +Component({ + /** + * 组件的初始数据 + */ + data: { + privacyContractName: '', + showPrivacy: false + }, + properties: { + + }, + /** + * 组件的生命周期 + */ + pageLifetimes: { + show() { + const that = this + wx.getPrivacySetting({ + success(res) { + if (res.errMsg == "getPrivacySetting:ok") { + that.setData({ + privacyContractName: res.privacyContractName, + showPrivacy: res.needAuthorization + }) + } + } + }) + } + }, + /** + * 组件的方法列表 + */ + methods: { + // 打开隐私协议页面 + openPrivacyContract() { + wx.openPrivacyContract({ + fail: () => { + wx.showToast({ + title: '出错了', + icon: 'error' + }) + } + }) + }, + // 拒绝隐私协议 + exitMiniProgram() { + // 直接退出小程序 + wx.exitMiniProgram(); + }, + // 同意隐私协议 + handleAgreePrivacyAuthorization() { + const that = this; + that.setData({ + showPrivacy: false + }); + // 同意后加载wifi模块 + this.triggerEvent('onStartWifi'); + }, + }, +}) \ No newline at end of file diff --git a/miniprogram/components/UserPrivacyDialog/index.json b/miniprogram/components/UserPrivacyDialog/index.json new file mode 100644 index 0000000..3928faa --- /dev/null +++ b/miniprogram/components/UserPrivacyDialog/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/miniprogram/components/UserPrivacyDialog/index.wxml b/miniprogram/components/UserPrivacyDialog/index.wxml new file mode 100644 index 0000000..0b5277c --- /dev/null +++ b/miniprogram/components/UserPrivacyDialog/index.wxml @@ -0,0 +1,12 @@ + + + 隐私保护指引 + + 在使用当前小程序服务之前,请仔细阅读{{privacyContractName}}。如你同意{{privacyContractName}},请点击“同意”开始使用。 + + + + + + + \ No newline at end of file diff --git a/miniprogram/components/UserPrivacyDialog/index.wxss b/miniprogram/components/UserPrivacyDialog/index.wxss new file mode 100644 index 0000000..0a3019f --- /dev/null +++ b/miniprogram/components/UserPrivacyDialog/index.wxss @@ -0,0 +1,68 @@ +.privacy { + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + background: rgba(0, 0, 0, .5); + z-index: 9999999; + display: flex; + align-items: center; + justify-content: center; +} + +.content { + width: 632rpx; + padding: 48rpx; + box-sizing: border-box; + background: #fff; + border-radius: 16rpx; +} + +.content .title { + text-align: center; + color: #333; + font-weight: bold; + font-size: 32rpx; +} + +.content .des { + font-size: 26rpx; + color: #666; + margin-top: 40rpx; + text-align: justify; + line-height: 1.6; +} + +.content .des .link { + color: #07c160; + text-decoration: underline; +} + +.btns { + margin-top: 48rpx; + display: flex; +} + +.btns .item { + justify-content: space-between; + width: 244rpx; + height: 80rpx; + display: flex; + align-items: center; + justify-content: center; + border-radius: 15rpx; + box-sizing: border-box; + border: none; +} + +.btns .reject { + background: #f4f4f5; + color: #909399; +} + +.btns .agree { + background: #07c160; + color: #fff; + margin-left: 20rpx; +} \ No newline at end of file diff --git a/miniprogram/model/index.js b/miniprogram/model/index.js index 42bc6f2..9132356 100644 --- a/miniprogram/model/index.js +++ b/miniprogram/model/index.js @@ -1 +1 @@ -export const VersionModel = '2.0.3F'; \ No newline at end of file +export const VersionModel = '2.0.4F'; \ No newline at end of file diff --git a/miniprogram/pages/home/home.js b/miniprogram/pages/home/home.js index fc615d1..7aaa253 100644 --- a/miniprogram/pages/home/home.js +++ b/miniprogram/pages/home/home.js @@ -23,9 +23,23 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - this.onStartWifi(); this.checkOptions(options); this.getAuth(); + this.getPrivacySetting(); + }, + // 获取用户隐私协议授权状态 + getPrivacySetting() { + const that = this + wx.getPrivacySetting({ + success(res) { + if (res.errMsg == "getPrivacySetting:ok") { + if(!res.needAuthorization) { + // 如果已经授权,加载wifi模块 + that.onStartWifi(); + } + } + } + }) }, onHide() { // 点击小程序右上角的关闭按钮时清空authToken @@ -61,6 +75,9 @@ Page({ console.log("error", error); }) }, + agreePrivacy() { + this.onStartWifi(); + }, // 检查并获取从微信公众号传过来的参数 checkOptions(options) { // todo 获取从微信公众号跳转的参数 diff --git a/miniprogram/pages/home/home.json b/miniprogram/pages/home/home.json index 72cceb5..95e8c29 100644 --- a/miniprogram/pages/home/home.json +++ b/miniprogram/pages/home/home.json @@ -1,3 +1,6 @@ { - "navigationBarTitleText": "首页" - } + "navigationBarTitleText": "首页", + "usingComponents": { + "UserPrivacyDialog": "/components/UserPrivacyDialog/index" + } +} \ No newline at end of file diff --git a/miniprogram/pages/home/home.wxml b/miniprogram/pages/home/home.wxml index 09fef15..4192ceb 100644 --- a/miniprogram/pages/home/home.wxml +++ b/miniprogram/pages/home/home.wxml @@ -28,4 +28,5 @@ 搜索不到WLAN + \ No newline at end of file diff --git a/miniprogram/project.private.config.json b/miniprogram/project.private.config.json index 0a9e27b..629db68 100644 --- a/miniprogram/project.private.config.json +++ b/miniprogram/project.private.config.json @@ -18,5 +18,5 @@ ] } }, - "libVersion": "2.28.1" + "libVersion": "2.33.0" } \ No newline at end of file diff --git a/miniprogram/readme.md b/miniprogram/readme.md index e2428ca..ab9924d 100644 --- a/miniprogram/readme.md +++ b/miniprogram/readme.md @@ -22,4 +22,12 @@ - 2023.9.2 ## 功能更新 - 更新内容 - - A 增加 保存WIFI信息成功后自动关闭当前小程序 \ No newline at end of file + - A 增加 保存WIFI信息成功后自动关闭当前小程序 + + +- 2.0.4 + - 2023.9.13 + ## 功能更新 + - 更新内容 + - A 增加 进入首页获取wifi信息时隐私协议提示弹窗 + - A 增加 一个隐私协议弹窗组件 \ No newline at end of file