经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 程序设计 » 编程经验 » 查看文章
元服务那些事儿 | 舞刀解决隐私声明,斩断上架牵绊
来源:cnblogs  作者:Mayism123  时间:2023/9/13 17:12:07  对本文有异议
?话说元服务初上的年间,鸿蒙江湖高手云起,都是一顿键盘手猛敲,元服务推陈出新,创意层出不穷,无不风生水起。

 

江湖规矩:每个元服务必须提供规范的隐私声明,否则提交元服务发布上架后,将导致审核无法通过。用户使用元服务前,必须引导其了解隐私声明信息,获取用户授权后,才能继续使用元服务。

 

话说上回,挥剑解决无需登录场景下元服务的隐私声明。

这回,好多高手慕名要求解决需要登录场景下元服务的隐私声明。

 

不少元服务服务直达后,需要通过用户登录获取用户信息,提供更加极致更加领先的元服务体验。那就推荐在登录界面提供隐私声明提示,引导用户阅读和授权,获取授权后才可继续使用。

声明范例如下图。

cke_1587.png?

狂舞四刀后,元服务效果如下图。

07%E6%9C%9F%E4%B8%AD%E6%95%88%E6%9E%9C%E5%9B%BE.gif?

【一 拖刀如林】

拖刀式积蓄大招,犹如丛林之势。

潇洒走江湖,必先熟读江湖规矩。隐私声明具体要求请参见隐私声明规范

【二 抽刀如花】

抽刀式抹去网络权限烦恼。

隐私声明详情必然需要通过访问互联网读取加载,所以需要在config.json配置文件中增加网络访问权限。

cke_6197.png?

代码示例:

  1. "reqPermissions": [
  2. {
  3. "name": "ohos.permission.INTERNET"
  4. }
  5. ]

【三 劈刀如虎】

劈刀式,如猛虎下山,一刀定乾坤。

隐私声明实现的代码结构如下:

cke_15205.png?

新建detailman页面用来显示上图声明范例中超链接跳转的H5页面,common下新增images资源实现checkBox组件效果。其中index页面是元服务首页。

协议详情页面的detailman.hml文件,可以使用web组件显示H5页面内容。

注意:web组件会覆盖页面其他组件,无法使用组件事件实现回退。如果需要回退,可以考虑使用JavaWebView实现。

代码示例:

  1. <div class="container">
  2. <web src="{{param}}"></web>
  3. </div>

协议详情页面的detailman.js文件,定义param变量接受index页面router传过来的参数。

代码示例:

  1. export default {
  2. data: {
  3. param: ""
  4. },
  5. onInit() {
  6. }
  7. }

协议详情页面的detailman.css文件。

代码示例:

  1. .container {
  2. display: flex;
  3. flex-direction: column;
  4. justify-content: center;
  5. align-items: center;
  6. left: 0px;
  7. top: 0px;
  8. width: 100%;
  9. height: 100%;
  10. }

【四 撩刀如龙】

撩刀式,如神龙飞舞,威武霸气。

元服务首页的index.hml文件,因为JS UI中不支持checkBox组件,于是使用image来实现选择效果。

代码示例:

  1. <div class="container">
  2. <!--方式二:首页使用check框-->
  3. <div style="flex-direction: row; align-items: center; justify-content: center;">
  4. <image id="checkImage" style="width: 25px; height: 25px;margin: 3%;" src="{{imagePath}}"
  5. onclick="agreeCheck"></image>
  6. <text style="width: 80%; text-align: start; padding: 2%; line-height: 25px;justify-content: center;">
  7. <span class="fontStyle" style="color: #ff181717;">我已阅读并同意</span>
  8. <span class="fontStyle" style="color: #ff0800ff;" onclick="go(rule)">{{ rule }}</span>
  9. <span class="fontStyle">与</span>
  10. <span class="fontStyle" style="color: #ff0800ff;" onclick="go(privacy)">{{ privacy }}</span>
  11. </text>
  12. </div>
  13. </div>

image资源可参考下图。

cke_45909.png?

cke_54048.png?

元服务首页的index.js文件,在onshow中查询存储数据,初始化check状态。

代码示例:

  1. import Router from '@system.router';
  2. import storage from '@ohos.data.storage';
  3. import featureAbility from '@ohos.ability.featureAbility';
  4. export default {
  5. data: {
  6. privacy: "《隐私政策》",
  7. rule: "《用户协议》",
  8. imagePath: "/common/images/uncheck.png",
  9. context: ""
  10. },
  11. onInit() {
  12. this.context = featureAbility.getContext();
  13. },
  14. onShow() {
  15. //方式二:打开页面时初始化用户是否已同意
  16. this.context.getFilesDir().then((filePath) => {
  17. storage.getStorage(filePath + '/myDatastore').then((dataStorage) => {
  18. dataStorage.get("hasAgree", "false").then((value) => {
  19. if (value == "false") {
  20. this.imagePath = "/common/images/uncheck.png"
  21. }
  22. else {
  23. this.imagePath = "/common/images/check.png"
  24. }
  25. })
  26. })
  27. })
  28. },
  29. go(flag) {
  30. let url = "https://www.51miz.com/so-wendang/11963302.html?utm_term=12452681&utm_source=baidu3&bd_vid=8250967139616741558"
  31. if (flag == "《用户协议》") {
  32. url = "https://www.51miz.com/so-wendang/11963302.html?utm_term=12452681&utm_source=baidu3&bd_vid=8250967139616741558"
  33. }
  34. else {
  35. url = "https://www.tukuppt.com/wordmuban/yinsizhengce.html?plan=11177-37593-12085827&bd_vid=8439929694061694080"
  36. }
  37. Router.push({
  38. uri: "pages/detailman/detailman", params: {
  39. param: url
  40. }
  41. })
  42. this.$element('dragDialog').close();
  43. },
  44. agreeCheck() {
  45. this.context.getFilesDir().then((filePath) => {
  46. storage.getStorage(filePath + '/myDatastore').then((dataStorage) => {
  47. dataStorage.get("hasAgree", "false").then((value) => {
  48. if (value == "false") {
  49. //处理同意逻辑并保存已同意参数
  50. dataStorage.putSync("hasAgree", "true");
  51. dataStorage.flushSync();
  52. this.imagePath = "/common/images/check.png"
  53. }
  54. else {
  55. //处理不同意逻辑并保存已同意参数
  56. dataStorage.putSync("hasAgree", "false");
  57. dataStorage.flushSync();
  58. this.imagePath = "/common/images/uncheck.png"
  59. }
  60. })
  61. });
  62. })
  63. }
  64. }

元服务首页的index.css文件

  1. .container {
  2. display: flex;
  3. flex-direction: column;
  4. justify-content: flex-start;
  5. align-items: center;
  6. left: 0px;
  7. top: 0px;
  8. width: 100%;
  9. height: 100%;
  10. }
  11. .fontStyle{
  12. font-size: 16px
  13. }

 

继承D意志的游侠们,他们三招解一题,千里不留行,事了拂衣去,深藏身与名。鸿蒙江湖高手勿发愁,勿上头,又一个场景的隐私声明问题已帮您解决,斩断了上架的牵绊,快快开启夏日多巴胺,二次激发元服务开发豪情。。。。。。

?

原文链接:https://www.cnblogs.com/mayism123/p/17700199.html

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号