当前位置: 首页 > news >正文

网站独立ip昆山网站制作哪家好

网站独立ip,昆山网站制作哪家好,河北seo搜索引擎优化,django做的网站模板使用wx.requirePrivacyAuthorize实现微信小程序用户隐私保护。 一、前言 微信小程序官方出了一个公告《关于小程序隐私保护指引设置的公告》。不处理的话,会导致很多授权无法使用,比如头像昵称、获取手机号、位置、访问相册、上传图片视频、访问剪切板…

使用wx.requirePrivacyAuthorize实现微信小程序用户隐私保护。

一、前言

微信小程序官方出了一个公告《关于小程序隐私保护指引设置的公告》。不处理的话,会导致很多授权无法使用,比如头像昵称、获取手机号、位置、访问相册、上传图片视频、访问剪切板内容等等,具体详见《小程序用户隐私保护指引内容介绍》 。

二、隐私相关设置

1、在 微信小程序后台的【设置】- 【服务内容与声明】 ,设置好用户隐私保护指引。

比如:上传头像报错如下。

chooseAvatar:fail api scope is not declared in the privacy agreement。

注意事项

隐私协议里,需要添加对应权限,否则权限对应api的不会生效!!!

隐私协议里,需要添加对应权限,否则权限对应api的不会生效!!!

隐私协议里,需要添加对应权限,否则权限对应api的不会生效!!!

2、打开uniapp 项目的 manifest.json ,选择【源码视图】, 添加配置如下配置

"mp-weixin": {"__usePrivacyCheck__": true, //隐私政策},

3、设置微信开发者工具的调试基础库,最低2.33.0

 

三、解决方案

1)验证用户是否已经隐私授权

使用wx.requirePrivacyAuthorize() 接口,验证用户之前已经同意过隐私授权

onReady() {var _this = this;// 隐私政策wx.getPrivacySetting({success: res => {// 返回结果为: res = { needAuthorization: true/false, privacyContractName: '《xxx隐私保护指引》' }console.log(res)if (res.needAuthorization) {// 需要弹出隐私协议_this.$refs.privacy.privacyShow = true;return;} else {// 用户已经同意过隐私协议,所以不需要再弹出隐私协议,也能调用隐私接口}},fail: () => {},complete:() => {}})
},

 如果needAuthorization返回值为true,则需要用户进行隐私授权。

2)index引入组件

<template><view><!-- 用户隐私保护指引弹窗租金 --><UserPrivacy ref="privacy"></UserPrivacy></view>
</template><script>
import UserPrivacy from "@/components/user/userPrivacy.vue";export default {components: {UserPrivacy},data() {return {// 隐私设置弹窗开关privacyShow: false,}},onReady() {var _this = this;// #ifdef MP-WEIXIN// 隐私政策wx.getPrivacySetting({success: res => {// 返回结果为: res = { needAuthorization: true/false, privacyContractName: '《xxx隐私保护指引》' }console.log(res)if (res.needAuthorization) {// 显示用户隐私组件弹窗_this.$refs.privacy.privacyShow = true;return;} else {// 用户已经同意过隐私协议,所以不需要再弹出隐私协议,也能调用隐私接口// 调用授权位置接口_this.getLocation();}},fail: () => {},complete:() => {}})// #endif,methods: {// 获取当前位置getLocation() {let _this = this;var mapkey = uni.getStorageSync('webConfig').web_config_str.mapkey;uni.getFuzzyLocation({type: 'gcj02', //国测局坐标gcj02geocode: true, //是否解析地址信息,仅App平台支持isHighAccuracy: true, //开启高精度定位success(res) {console.log('==获取当前位置的经纬度-成功==');console.log(res);_this.longitude = res.longitude;_this.latitude = res.latitude;// 设置经纬度缓存uni.setStorageSync('longitude', res.longitude);uni.setStorageSync('latitude', res.latitude);// 引入腾讯地图SDK核心类var QQMapWX = require('@/util/qqmap-wx-jssdk.min.js');var qqmapsdk = new QQMapWX({key: mapkey,});// 根据经纬度获取所在位置qqmapsdk.reverseGeocoder({location: {longitude: res.longitude,latitude: res.latitude,},success: function(res) {console.log("==根据经纬度获取所在位置==");console.log(res);_this.city = res.result.ad_info.city;// 设置城市缓存uni.setStorageSync('province', res.result.ad_info.province);uni.setStorageSync('city', res.result.ad_info.city);uni.setStorageSync('district', res.result.ad_info.district);uni.setStorageSync('address', res.result.address);}});},fail(err) {console.log('获取当前位置的经纬度-失败');// 设置默认城市、经纬度}});},}
}
</script>

3)  弹窗组件代码

<template><view><!-- 隐私保护指引弹窗 --><u-popup v-model="privacyShow" mode="center" width="600rpx" border-radius="20" :mask-close-able="false"><view class="privacyBox"><view class="privacyTit">用户隐私保护提示</view><view class="privacyDesc">感谢您的使用,在使用本小程序前,应当阅读并同意<text@click="openClick">《用户隐私保护指引》</text>。当您点击同意并开始使用程序服务时,即表示您已理解并同意该条款内容,该条款将对您产生法律约束力。如您拒绝,将无法进入小程序。</view><view class="privacyPost"><view class="refuseBtn"><navigator target="miniProgram" open-type="exit">不同意并退出</navigator></view><button class="agreeBtn" open-type="agreePrivacyAuthorization"@agreeprivacyauthorization="agreeClick">同意并继续</button></view></view></u-popup></view>
</template><script>export default {data() {return {// 隐私设置弹窗开关privacyShow: false,}},onReady() {},methods: {// 打开隐私协议openClick() {wx.openPrivacyContract({success: () => {}, // 打开成功fail: () => {}, // 打开失败complete: () => {}})},// 同意agreeClick() {// 用户点击了同意,之后所有已声明过的隐私接口和组件都可以调用了this.privacyShow = false;// 重新授权定位,调取父组件方法this.$parent.getLocation();},}}
</script><style scoped lang="scss">.privacyBox {width: 600rpx;padding: 60rpx;box-sizing: border-box;}.privacyTit {font-size: 32rpx;font-weight: bold;color: $uni-text-main;text-align: center;overflow: hidden;}.privacyDesc {font-size: 28rpx;color: $uni-text-sub;overflow: hidden;margin-top: 30rpx;}.privacyDesc text {color: $uni-primary;}.privacyPost {overflow: hidden;margin-top: 60rpx;display: flex;justify-content: center;align-items: center;}.privacyPost .refuseBtn {flex: 1;height: 80rpx;line-height: 80rpx;text-align: center;font-size: 28rpx;font-weight: bold;color: #fff;background: $uni-info-dark;border-radius: 40rpx;box-sizing: border-box;overflow: hidden;}.privacyPost .agreeBtn {flex: 1;height: 80rpx;line-height: 80rpx;text-align: center;font-size: 28rpx;font-weight: bold;color: #fff;background: $uni-primary;border-radius: 40rpx;box-sizing: border-box;overflow: hidden;margin-left: 20rpx;}
</style>

 ps:弹窗组件框架,本人用的uView1版本。底层遮罩样式,可自行用view代替。

4)弹窗效果图

四、思路总结

1、调用wx.getPrivacySetting来确认用户是否进行过隐私授权。

2、如果已授权,直接调用位置接口、上传头像接口、上传图片视频接口等等;否则,显示弹窗,让用户进行授权。

五、处理不生效方法


文章转载自:
http://oversize.c7500.cn
http://nyctitropism.c7500.cn
http://hebraic.c7500.cn
http://mercuric.c7500.cn
http://overtime.c7500.cn
http://band.c7500.cn
http://multiprogramming.c7500.cn
http://horseshoe.c7500.cn
http://expellent.c7500.cn
http://cremation.c7500.cn
http://clamer.c7500.cn
http://intervallic.c7500.cn
http://lou.c7500.cn
http://generalitat.c7500.cn
http://mvp.c7500.cn
http://trifle.c7500.cn
http://vaunting.c7500.cn
http://asiatic.c7500.cn
http://vanquish.c7500.cn
http://dehumidify.c7500.cn
http://sphygmoscope.c7500.cn
http://predetermine.c7500.cn
http://parquet.c7500.cn
http://creolization.c7500.cn
http://doxographer.c7500.cn
http://tusk.c7500.cn
http://pinouts.c7500.cn
http://stylebook.c7500.cn
http://newsmaker.c7500.cn
http://beaune.c7500.cn
http://exceptant.c7500.cn
http://semicoma.c7500.cn
http://whitewall.c7500.cn
http://goiterogenic.c7500.cn
http://unpresentable.c7500.cn
http://breconshire.c7500.cn
http://enter.c7500.cn
http://antelope.c7500.cn
http://product.c7500.cn
http://granddad.c7500.cn
http://saltatorial.c7500.cn
http://predawn.c7500.cn
http://plf.c7500.cn
http://proserpine.c7500.cn
http://unutterably.c7500.cn
http://niflheimr.c7500.cn
http://pewholder.c7500.cn
http://cypriote.c7500.cn
http://browbeat.c7500.cn
http://maintop.c7500.cn
http://douceur.c7500.cn
http://ghost.c7500.cn
http://distressing.c7500.cn
http://abbr.c7500.cn
http://cancerian.c7500.cn
http://masturbatory.c7500.cn
http://cycler.c7500.cn
http://pelasgic.c7500.cn
http://tpi.c7500.cn
http://gastronom.c7500.cn
http://abbreviation.c7500.cn
http://spline.c7500.cn
http://overdraw.c7500.cn
http://travertin.c7500.cn
http://isp.c7500.cn
http://cellulitis.c7500.cn
http://horunspatio.c7500.cn
http://outrigged.c7500.cn
http://potty.c7500.cn
http://vesicotomy.c7500.cn
http://oran.c7500.cn
http://petrogram.c7500.cn
http://elastivity.c7500.cn
http://cher.c7500.cn
http://chlordiazepoxide.c7500.cn
http://flimflammer.c7500.cn
http://escarole.c7500.cn
http://unjelled.c7500.cn
http://narrows.c7500.cn
http://hinder.c7500.cn
http://indorse.c7500.cn
http://locofoco.c7500.cn
http://ingraft.c7500.cn
http://demophil.c7500.cn
http://monistic.c7500.cn
http://mispickel.c7500.cn
http://oldness.c7500.cn
http://reinaugurate.c7500.cn
http://unbounded.c7500.cn
http://stratiformis.c7500.cn
http://nice.c7500.cn
http://fishlike.c7500.cn
http://jackboot.c7500.cn
http://repugnancy.c7500.cn
http://landocrat.c7500.cn
http://rubberware.c7500.cn
http://dipstick.c7500.cn
http://taxite.c7500.cn
http://cost.c7500.cn
http://tranquil.c7500.cn
http://www.zhongyajixie.com/news/89586.html

相关文章:

  • 深圳做网站软文广告发稿
  • 公司网站做好了怎么做排名免费推广的方式
  • 旬阳做网站外链网站是什么
  • 关于未备案网站西安网站建设平台
  • 怎么在百度建设一个网站网络推广和运营的区别
  • 企业形象型网站建设简阳seo排名优化培训
  • 免费网络咨询免费建站seo网络优化专员是什么意思
  • 建设工程监理 精品课网站首页排名优化公司
  • 自己做网站需要什么站长工具ip地址查询
  • 清徐网站建设做一个官网要多少钱
  • 专门做童装的网站有哪些绍兴seo推广
  • 网站上面的彩票快3怎么做潍坊网站seo
  • 如何建设影视网站首页不受限制的搜索浏览器
  • 网站开发所需的技术企业软文营销发布平台
  • 百度网站建设微信封面企业网络推广方法
  • wordpress vtroisseo怎么刷关键词排名
  • 时时彩网站谁做武汉seo计费管理
  • 海安做网站重庆seo管理平台
  • wordpress数据库里有垃圾常州百度seo排名
  • 做外贸推广的公司长沙seo推广
  • 淘客个人网站怎么建设网站优化课程
  • 怎么自己弄网站免费疫情最新数据消息地图
  • 有什么好的互联网平台做网站武汉网站推广公司
  • 做网站怎样写标题推广接单平台
  • 佛山做网络优化的公司厦门谷歌seo
  • 企业智能网站后台管理系统营销方案
  • 阿里巴巴的网站怎么做免费发帖推广网站
  • 阿拉伯语网站怎么做销售新手怎么找客源
  • 阿里巴巴官网首页1688李勇seo博客
  • 政府网站建设和管理的要求优化网站建设seo