当前位置:网站首页>[quick application] quick application user agreement and privacy policy content can jump many times. Click back and fail to return to the previous page. How to deal with it?
[quick application] quick application user agreement and privacy policy content can jump many times. Click back and fail to return to the previous page. How to deal with it?
2022-07-16 09:15:00 【Huawei Developer Forum】
【 Phenomenon description 】
There is a link jump in the user agreement and privacy policy , After multiple jumps , Click the upper left corner to return , Will not return to the previous link page , Instead, return to the user agreement and privacy policy page
【 Problem analysis 】
After many link jumps , Click on the return , Return directly to the user agreement and privacy policy page , Because the jump is realized on the same page , There is no event processing for the return key
【 terms of settlement 】
You need to handle the return key event , Click the back button to return to the previous page
onBackPress() { this.$element('web').canBack({ callback: function (e) { if (e) { this.$element('web').back(); } else { router.back(); } }.bind(this) }); return true; },The code is as follows
service.ux
<template> <web id="web" src="{{openUrl}}"></web></template><script> import router from '@system.router' export default { public: { openUrl: '', menuTitle: '' }, onInit() { let { openUrl, menuTitle } = this this.openUrl = openUrl this.$page.setTitleBar({ text: menuTitle, textColor: '#000', backgroundColor: '#FFFFFF', backgroundOpacity: 0.5, menu: true }) }, onBackPress() { this.$element('web').canBack({ callback: function (e) { if (e) { this.$element('web').back(); } else { router.back(); } }.bind(this) }); return true; }, }</script>userAgreement.ux
<template> <div class="label"> <div class="content"> <div class="title"><text> User agreement and privacy policy </text></div> <list class="content-warp"> <list-item class="first-line" type="list-item"> <text> Welcome to quick app :</text> </list-item> <list-item class="primary-line" type="list-item-content"> <text> We solemnly promise to pay attention to and protect users' personal information . We uphold “ All based on user value ” Idea , Enhance your convenience of information management , Ensure your information and communication security . We strictly abide by the laws and regulations , Follow the following privacy protection principles , Provide you with more security 、 Reliable service .</text> <text> Click on “ agree! ”, That means you agree to the above and <a @click="openPage(1)" class="service">《 User agreement 》</a> And <a @click="openPage(2)" class="service">《 Privacy policy 》</a> </text> </list-item> </list> <div @click="agree" class="handle-btn"> <text> agree! </text> </div> <div @click="cancel" class="disagree-btn"> <text> Disagree </text> </div> </div> </div></template><script> export default { onInit() { }, openPage(flag) { this.$emit('openServicePage', { flag }) }, agree() { this.$dispatch("dispatchEvent", { display: false, isagree: "agree" }); }, cancel() { this.$app.exit(); } }</script> <style lang="less"> .content { padding: 30px; border-radius: 12px; width: 600px; flex-direction: column; align-items: center; background-color: #fff; .title { text { font-weight: bold; color: #000000; font-size: 36px; } } .content-warp { height: 500px; flex-direction: column; .service { color: #007aff; text-decoration: underline; } .first-line { flex-direction: column; text { font-weight: bold; color: #000000; font-size: 32px; } } .primary-line { flex-direction: column; text { text-indent: 40px; } } } .handle-btn { width: 474px; height: 82px; border-radius: 41px; justify-content: center; align-items: center; background-color: #d63016; margin-top: 30px; text { font-weight: 600; color: #fff; font-size: 34px; } } .disagree-btn { margin-top: 30px; text { font-weight: 600; font-size: 34px; } } } .label { position: fixed; top: 0; right: 0; left: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.8); flex-direction: column; justify-content: center; align-items: center; }</style>hello.ux
<import name="userAgreement" src="./UserAgreement/userAgreement.ux"></import><template> <!-- Only one root node is allowed in template. --> <div class="container"> <stack> <text class="title" onclick="save">Hello World</text> <block if="{{ display }}"> <userAgreement onopen-service-page="openServicePage"></userAgreement> </block> </stack> </div></template><style> .container { flex-direction: column; justify-content: center; align-items: center; background-color: #d39b75; } .title { font-size: 100px; }</style><script> import storage from "@system.storage"; import router from '@system.router' module.exports = { private: { display: false, isagree: "disagree" }, onInit() { this.$page.setTitleBar({ text: "hello", textColor: "#ffffff", backgroundColor: "#007DFF", backgroundOpacity: 0.5, menu: true }); }, openServicePage({ detail: { flag } }) { let openUrl, menuTitle switch (flag) { case 1: openUrl = '*' menuTitle = ' User agreement ' break; case 2: openUrl = '*' menuTitle = ' Privacy policy ' break; default: break; } router.push({ uri: 'Hello/Service', params: { openUrl, menuTitle } }) }, onShow(options) { var that = this; that.get() setTimeout(() => { if (that.isagree === "agree") { that.display = false; } else { setTimeout(() => { that.display = true; }, 100); } }, 500); console.log("message:", that.isagree); this.$on("dispatchEvent", this.dispatchEvent); }, dispatchEvent(evt) { this.display = evt.detail.display; this.isagree = evt.detail.isagree; this.save(this.isagree); }, save(params) { storage.set({ key: "agreeFlag", value: params, success: function (data) { console.log("handling success"); }, fail: function (data, code) { console.log("handling fail, code = " + code); } }); }, get() { var that = this; storage.get({ key: "agreeFlag", success: function (data) { that.isagree = data; console.log("handling success", data); }, fail: function (data, code) { console.log("handling fail, code = " + code); } }); } };</script>
For more technical articles , Welcome to visit https://developer.huawei.com/consumer/cn/forum/?ha_source=zzh
边栏推荐
- odoo action分析(action.client,action.act_window,action.server)
- uniapp-小程序与H5压缩图片上传
- 字符串库函数和内存操作库函数详解及模拟实现
- 敏捷实践:开站会只问昨天做了什么?今天准备做什么就行了吗?
- input获取焦点
- JMeter 21 day clock in day01
- Transformer 落地出现 | Next-ViT实现工业TensorRT实时落地,超越ResNet、CSWin
- 【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决
- Detailed explanation of odoo Eval
- odoo search视图详解(一)
猜你喜欢

031 Log4j日志框架

Why do more and more people want to take the PMP project management certification?

《Attentional Encoder Network for Targeted Sentiment Classification》论文阅读

Simulate the implementation of the library function strcpy, and further understand strcpy (deeply understand the overlapping problem, and prevent the memory from overlapping with the source)

How to set various displays in 3dmax2021?

成员函数之析构函数

LeetCode 1584. 连接所有点的最小费用

Build your own website (21)

1. JVM class loading mechanism

pytorch_lightning中lightning_logs里的hparams.yaml输出为空问题
随机推荐
Problems encountered when using yolov5
有名管道原理及详解(非常实用)
odoo manifest. Py file details
Flink SQL asks which function was last month?
jupyterlab 安装
3. JVM garbage collector
go grpc: connection reset by peer 的一种解决方案
Message mechanism of dtcloud (2)
林子雨spark scala版编程小结
【AGC】增长服务3-App Linking示例
uniapp-小程序与H5压缩图片上传
Build your own website (21)
如何洞晓深度学习中记忆与注意力机制?这份Deakin大学212页博士论文给您做解答
Detailed explanation of odoo Eval
What is restful style? What is the difference from the traditional interview style?
odoo action分析(action.client,action.act_window,action.server)
Laravel 用户认证中 attempt方法
np.delete详解 返回的数据为删除指定维度后的数据
LeetCode 2155. 分组得分最高的所有下标
建立自己的网站(21)