组保留的标签 余下为需要删除的标签
unset($oldtag[$key]);
}
}
}
if (!empty($oldtag)) {
$tagids = array();
foreach ($oldtag as $tagid => $tagname) {
$tagids[] = $tagid;
}
well_oldtag_delete($tagids, $tid);
}
$r = well_tag_process($tid, $fid, $create_tag, $tagarr);
return $r;
}
// 删除标签和绑定的主题
function well_oldtag_delete($tagids, $tid)
{
$pagesize = count($tagids);
$arrlist = well_tag_find_by_tagids($tagids, 1, $pagesize);
$delete_tagids = array(); // 删除
$tagids = array();
$n = 0;
foreach ($arrlist as $val) {
++$n;
if (1 == $val['count']) {
// 只有一个主题
$delete_tagids[] = $val['tagid'];
} else {
$tagids[] = $val['tagid'];
}
}
!empty($delete_tagids) and well_tag_delete($delete_tagids);
$arlist = well_tag_thread_find_by_tid($tid, 1, $n);
if ($arlist) {
$ids = array();
foreach ($arlist as $val) $ids[] = $val['id'];
well_tag_thread_delete($ids);
}
!empty($tagids) and well_tag_update($tagids, array('count-' => 1));
}
// 标签数据处理 $arr=新提交的数组 $tagarr=保留的旧标签
function well_tag_process($tid, $fid, $new_tags = array(), $tagarr = array())
{
if (empty($tid)) return '';
// 新标签处理入库
if ($new_tags) {
$threadarr = array();
$tagids = array();
$i = 0;
$size = 5;
$n = count($tagarr);
$n = $n > $size ? $size : $size - $n;
foreach ($new_tags as $name) {
++$i;
$name = trim($name);
$name = stripslashes($name);
$name = strip_tags($name);
$name = str_replace(array(' ', '#', "@", "$", "%", "^", '&', '·', '<', '>', ';', '`', '~', '!', '¥', '……', ';', '?', '?', '-', '—', '_', '=', '+', '.', '{', '}', '|', ':', ':', '、', '/', '。', '[', ']', '【', '】', '‘', ' ', ' ', ' ', ' ', ' '), '', $name);
$name = htmlspecialchars($name, ENT_QUOTES);
if ($name && $i <= $n) {
// 查询标签
$read = well_tag_read_name($name);
if ($read) {
// 存在 count+1
$tagids[] = $read['tagid'];
} else {
// 入库
$arr = array('name' => $name, 'count' => 1);
$tagid = well_tag_create($arr);
FALSE === $tagid and message(-1, lang('create_failed'));
$read = array('tagid' => $tagid, 'name' => $name);
}
$tag_thread = array('tagid' => $read['tagid'], 'tid' => $tid);
$threadarr[] = $tag_thread;
$tagarr[$read['tagid']] = $read['name'];
}
}
!empty($threadarr) and tag_thread_big_insert($threadarr);
!empty($tagids) and well_tag_update($tagids, array('count+' => 1));
}
$json = empty($tagarr) ? '' : xn_json_encode($tagarr);
return $json;
}
?>
【HarmonyOS NEXT】鸿蒙跳转华为应用市场目标APP下载页-阿南达文事网
【HarmonyOS NEXT】鸿蒙跳转华为应用市场目标APP下载页
编程日记30
更新时间:2025-05-26 09:01:26 【HarmonyOS NEXT】鸿蒙跳转华为应用市场目标APP下载页
【HarmonyOS NEXT】鸿蒙跳转华为应用市场目标APP下载页
一、问题背景:
如今,大家都离不开各种手机应用。随着鸿蒙系统用户越来越多,大家都希望能在鸿蒙设备上快速找到想用的 APP。华为应用市场里有海量的 APP,但之前从鸿蒙设备进入应用市场找特定 APP 的过程有点繁琐。
从开发角度来说,打通鸿蒙设备到华为应用市场目标 APP 下载页的直接跳转,能优化整个开发链路。从产品需求出发,这能提升应用分发的效率,助力产品推广。
站在用户体验方面,这么做能大大节省用户找 APP 的时间,让大家更快下载想用的应用,极大地提升用户使用鸿蒙设备获取应用的体验。所以,实现这个跳转功能十分必要。
二、解决方案:
源码示例如下,以跳转到华为应用市场的wx界面举例:
跳转目标app的下载页,需要知道其包名即可。
点击跳转按钮后的效果:
代码语言:dart
复制
import Want from '@ohos.app.ability.Want';
import common from '@ohos.app.abilitymon';
import { BusinessError } from '@kit.BasicServicesKit';
@Entry
@Component
struct AGCStorePage {
private TAG: string = "AGCStorePage";
// 以wx举例:
@State mAppId: string = 'com.tencent.wechat';
controller: TextInputController = new TextInputController();
build() {
Row() {
Column() {
TextInput({ text: this.appId, placeholder: '请输入应用的appId', controller: this.controller })
.width('90%')
.onChange((value: string) => {
this.mAppId = value
})
Button('点击跳转到鸿蒙版应用市场详情页面')
.margin({top: 50})
.onClick(()=>{
const want: Want = {
uri: "store://appgallery.huawei/app/detail?id=" + this.mAppId
};
const context = getContext(this) as common.UIAbilityContext;
context.startAbility(want).then(()=>{
//拉起成功
console.log(this.TAG, "跳转成功!");
}).catch((err: BusinessError)=>{
// 拉起失败
console.log(this.TAG, "跳转失败!" + JSON.stringify(err));
});
})
}
.width('100%')
}
.height('100%')
}
}
注意:
拼接分享的应用下载页链接为(以wx举例,替换id即可跳转到目标app): .tencent.wechat
在鸿蒙设备上加载该链接,为自动跳转到应用市场app下载页。若不是鸿蒙设备,会提示:
本文发布于:2025-05-25,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:HarmonyOS NEXT鸿蒙跳转华为应用市场目标APP下载页
发布评论