文件最后提交记录最后更新时间
Issue: \#I6DR14 Description: BasicFeature模块,目录结构迁移 Sig: SIG_Sample Feature or Bugfix: Bugfix Binary Source: No Signed-off-by: hongshengquan <hongshengquan3@huawei.com> 3 年前
Bugfix: 合并修改 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> Bugfix: 事件通知CustomNotificationBadge仓ArkTs整改 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> Bugfix: CustomCommonEvent仓ArkTs整改-补充 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> Bugfix: CustomEmitter仓ArkTs整改-补充 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> Bugfix: CommonEvent仓Arkts整改-修正 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> Bugfix: 回退launcher相关的误提交 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> Bugfix: ArkTs整改-评论意见修复 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> 2 年前
Bugfix: 合并修改 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> Bugfix: 事件通知CustomNotificationBadge仓ArkTs整改 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> Bugfix: CustomCommonEvent仓ArkTs整改-补充 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> Bugfix: CustomEmitter仓ArkTs整改-补充 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> Bugfix: CommonEvent仓Arkts整改-修正 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> Bugfix: 回退launcher相关的误提交 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> Bugfix: ArkTs整改-评论意见修复 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> 2 年前
ArkTs 整改 2 年前
Issue: \#I6DR14 Description: BasicFeature模块,目录结构迁移 Sig: SIG_Sample Feature or Bugfix: Bugfix Binary Source: No Signed-off-by: hongshengquan <hongshengquan3@huawei.com> 3 年前
!2255 【0230】code目录下代码适配 part.1+2+3 * code目录下代码适配 part.3 * code目录下代码适配 part.2 * code目录下代码适配 part.1 Signed-off-by: sunwenxu <sunwenxu1@huawei.com> 3 年前
CustomEmitter、CustomNotification、CustomNotificationBadge、CustomNotificationPush Signed-off-by: yeyedeshen <yangxin181@huawei.com> 2 年前
Bugfix: 合并修改 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> Bugfix: 事件通知CustomNotificationBadge仓ArkTs整改 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> Bugfix: CustomCommonEvent仓ArkTs整改-补充 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> Bugfix: CustomEmitter仓ArkTs整改-补充 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> Bugfix: CommonEvent仓Arkts整改-修正 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> Bugfix: 回退launcher相关的误提交 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> Bugfix: ArkTs整改-评论意见修复 Signed-off-by: xuzhihao <xuzhihao16@huawei.com> 2 年前
Issue: \#I6DR14 Description: BasicFeature模块,目录结构迁移 Sig: SIG_Sample Feature or Bugfix: Bugfix Binary Source: No Signed-off-by: hongshengquan <hongshengquan3@huawei.com> 3 年前
新增FormGame用例,Location、Sensor、Vibrator、MediaCollections、FormGame、ResourceManager、Image、CustomEmitter迁移 Signed-off-by: yeyedeshen <yangxin181@huawei.com> 3 年前
新增FormGame用例,Location、Sensor、Vibrator、MediaCollections、FormGame、ResourceManager、Image、CustomEmitter迁移 Signed-off-by: yeyedeshen <yangxin181@huawei.com> 3 年前
新增FormGame用例,Location、Sensor、Vibrator、MediaCollections、FormGame、ResourceManager、Image、CustomEmitter迁移 Signed-off-by: yeyedeshen <yangxin181@huawei.com> 3 年前
Issue: #I6VLQP description: 1.CustomEmitter新增自动化测试用例。 Sig: SIG_Sample Feature or Bugfix: Bugfix Binary Source: No Signed-off-by: hongshengquan <hongshengquan3@huawei.com> 3 年前
README_zh.md

自定义Emitter

介绍

本示例使用@ohos.events.emitter (Emitter)实现事件的订阅和发布,使用自定义弹窗设置广告信息。

效果预览

首页 列表页 详情 购物车
ads_dialog goods_list good_detail shopping_cart

使用说明

  1. 进入首页后弹出广告弹窗,点击即可关闭。
  2. 点击商品列表中的一个商品可以跳转到商品详情页。
  3. 在商品详情页点击首页可以返回到商品列表页,点击购物车可以跳转到购物车页面,点击加入购物车可以在购物车页面添加一条商品信息。

工程目录

entry/src/main/ets/
|---components
|   |---BottomNavigation.ets                    // 底部按钮导航栏
|   |---Choice.ets                              // 商品规格选择
|   |---EventsDialog.ets                        // 广告弹窗
|   |---Information.ets                         // 详细信息页面
|   |---Valueation.ets                          // 价格页面
|---mock
|   |---DetailData.ets                          // 商品详情数据
|   |---ProductsData.ets                        // 产品列表数据
|---model
|   |---DetailMode.ets                          // 商品详情数据结构
|   |---GoodsModel.ets                          // 商品数据结构
|---pages
|   |---Detail.ets                              // 商品详情
|   |---Index.ets                               // 首页
|   |---ShopCart.ets                            // 购物车
|---shoppingCart
|   |---Cart.ets                                // 购物车
|   |---FavorGoodlist.ets                       // 推荐列表
|---util
|   |---Logger.ets                              // 日志工具
feature/emitter/src/main/ets/
|---common
|   |---EmitterConst.ts                         // 事件通知常量
|---components
|   |---feature
|   |   |---CustomEmitter.ets                   // 封装事件通知类

具体实现

  • 订阅事件通知在CustomEmitter中实现,源码参考CustomEmitter.ets
    • 广告弹窗:使用Emitter的事件单次订阅emitter.once(eventId,call),单次订阅CustomDialogController弹窗事件,弹窗触发后自动取消订阅。
    • 购物车添加商品:使用Emitter.on持续订阅商品添加事件,添加商品时更新购物车商品列表。

相关权限

不涉及。

依赖

不涉及。

约束与限制

  1. 本示例仅支持标准系统上运行,支持设备:RK3568。
  2. 本示例为Stage模型,支持API10版本SDK,SDK版本号(API Version 10 Release),镜像版本号(4.0 Release)
  3. 本示例需要使用DevEco Studio 版本号(4.0 Release)及以上版本才可编译运行。

下载

如需单独下载本工程,执行如下命令:

git init
git config core.sparsecheckout true
echo code/BasicFeature/Notification/CustomEmitter/ > .git/info/sparse-checkout
git remote add origin https://gitee.com/openharmony/applications_app_samples.git
git pull origin master