Repository: 94xy/miniprogram-privacy Branch: main Commit: ffca1248c219 Files: 18 Total size: 7.7 KB Directory structure: gitextract_ar9v3r0d/ ├── .eslintrc.js ├── .gitignore ├── LICENSE ├── README.md ├── app.js ├── app.json ├── app.wxss ├── component/ │ └── privacy/ │ ├── privacy.js │ ├── privacy.json │ ├── privacy.wxml │ └── privacy.wxss ├── pages/ │ └── index/ │ ├── index.js │ ├── index.json │ ├── index.wxml │ └── index.wxss ├── project.config.json ├── project.private.config.json └── sitemap.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .eslintrc.js ================================================ /* * Eslint config file * Documentation: https://eslint.org/docs/user-guide/configuring/ * Install the Eslint extension before using this feature. */ module.exports = { env: { es6: true, browser: true, node: true, }, ecmaFeatures: { modules: true, }, parserOptions: { ecmaVersion: 2018, sourceType: 'module', }, globals: { wx: true, App: true, Page: true, getCurrentPages: true, getApp: true, Component: true, requirePlugin: true, requireMiniProgram: true, }, // extends: 'eslint:recommended', rules: {}, } ================================================ FILE: .gitignore ================================================ .DS_Store ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2023 Jiaqi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # 刚刚,微信发布最新公告(要求必须适配的最后日期的 3 个小时前),开发者可以无须修改,自动使用官方默认配置。 ================================================ FILE: app.js ================================================ App({ onLaunch() { } }) ================================================ FILE: app.json ================================================ { "pages": [ "pages/index/index" ], "window": { "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#fff", "navigationBarTitleText": "隐私协议弹窗模板", "navigationBarTextStyle": "black" }, "style": "v2", "sitemapLocation": "sitemap.json", "lazyCodeLoading": "requiredComponents", "__usePrivacyCheck__": true } ================================================ FILE: app.wxss ================================================ ================================================ FILE: component/privacy/privacy.js ================================================ // component/privacy/privacy.js Component({ /** * 组件的初始数据 */ data: { privacyContractName: '', showPrivacy: false }, /** * 组件的生命周期 */ pageLifetimes: { show() { const _ = this const version = wx.getAppBaseInfo().SDKVersion if (_.compareVersion(version, '2.32.3') >= 0) { wx.getPrivacySetting({ success(res) { if (res.errMsg == "getPrivacySetting:ok") { _.setData({ privacyContractName: res.privacyContractName, showPrivacy: res.needAuthorization }) } } }) } } }, /** * 组件的方法列表 */ methods: { // 打开隐私协议页面 openPrivacyContract() { const _ = this wx.openPrivacyContract({ fail: () => { wx.showToast({ title: '遇到错误', icon: 'error' }) } }) }, // 拒绝隐私协议 exitMiniProgram() { wx.showToast({ title: '必须同意后才可以继续使用当前小程序', icon: 'none' }) }, // 同意隐私协议 handleAgreePrivacyAuthorization() { const _ = this _.setData({ showPrivacy: false }) }, // 比较版本号 compareVersion(v1, v2) { v1 = v1.split('.') v2 = v2.split('.') const len = Math.max(v1.length, v2.length) while (v1.length < len) { v1.push('0') } while (v2.length < len) { v2.push('0') } for (let i = 0; i < len; i++) { const num1 = parseInt(v1[i]) const num2 = parseInt(v2[i]) if (num1 > num2) { return 1 } else if (num1 < num2) { return -1 } } return 0 }, // 通过绑定空事件禁止滑动事件的穿透 handleCatchtouchMove() { return } }, }) ================================================ FILE: component/privacy/privacy.json ================================================ { "component": true, "usingComponents": {} } ================================================ FILE: component/privacy/privacy.wxml ================================================ 隐私保护指引 在使用当前小程序服务之前,请仔细阅读{{privacyContractName}}。如你同意{{privacyContractName}},请点击“同意”开始使用。 ================================================ FILE: component/privacy/privacy.wxss ================================================ /* component/privacy/privacy.wxss */ .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: 16rpx; box-sizing: border-box; border: none; } .btns .reject { background: #f4f4f5; color: #909399; } .btns .agree { background: #07c160; color: #fff; } ================================================ FILE: pages/index/index.js ================================================ Page({}) ================================================ FILE: pages/index/index.json ================================================ { "usingComponents": { "Privacy": "/component/privacy/privacy" } } ================================================ FILE: pages/index/index.wxml ================================================ 需要授权自动弹窗,不需要则不显示弹窗 ================================================ FILE: pages/index/index.wxss ================================================ .tips{ position: fixed; top: 0; right: 0; bottom: 0; left: 0; display: flex; justify-content: center; align-items: center; color: #666; } ================================================ FILE: project.config.json ================================================ { "compileType": "miniprogram", "setting": { "coverView": true, "es6": true, "postcss": true, "minified": true, "enhance": true, "showShadowRootInWxmlPanel": true, "packNpmRelationList": [], "babelSetting": { "ignore": [], "disablePlugins": [], "outputPath": "" }, "ignoreUploadUnusedFiles": true }, "condition": {}, "editorSetting": { "tabIndent": "insertSpaces", "tabSize": 4 }, "packOptions": { "ignore": [], "include": [] }, "appid": "wx99d0f0c106f42045" } ================================================ FILE: project.private.config.json ================================================ { "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", "projectname": "minicode-privacy", "setting": { "compileHotReLoad": true, "skylineRenderEnable": true }, "libVersion": "2.31.1" } ================================================ FILE: sitemap.json ================================================ { "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", "rules": [{ "action": "allow", "page": "*" }] }