组保留的标签 余下为需要删除的标签
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;
}
?> $v = implode(",", $v);
$temp[] = $v;
}
// 去掉重复的字符串,也就是重复的一维数组
$temp = array_unique($temp);
// 再将拆开的数组重新组装
$output = array();
foreach ($temp as $k => $v) {
if ($stkeep) $k = $starr[$k];
if ($ndformat) {
$temparr = explode(",", $v);
foreach ($temparr as $ndkey => $ndval) $output[$k][$ndarr[$ndkey]] = $ndval;
} else $output[$k] = explode(",", $v);
}
return $output;
}
// 合并二维数组 如重复 值以第一个数组值为准
function array2_merge($array1, $array2, $key = '')
{
if (empty($array1) || empty($array2)) return NULL;
$arr = array();
foreach ($array1 as $k => $v) {
isset($v[$key]) ? $arr[$v[$key]] = array_merge($v, $array2[$k]) : $arr[] = array_merge($v, $array2[$k]);
}
return $arr;
}
/*
* 对二维数组排序 两个数组必须有一个相同的键值
* $array1 需要排序数组
* $array2 按照该数组key排序
* */
function array2_sort_key($array1, $array2, $key = '')
{
if (empty($array1) || empty($array2)) return NULL;
$arr = array();
foreach ($array2 as $k => $v) {
if (isset($v[$key]) && $v[$key] == $array1[$v[$key]][$key]) {
$arr[$v[$key]] = $array1[$v[$key]];
} else {
$arr[] = $v;
}
}
return $arr;
}
?>
微信中下载APP,页面跳转提示信息的实现编程频道|福州电脑网
微信中下载APP,页面跳转提示信息的实现
编程之家520
更新时间:2026-04-03 20:25:36 相信做前端的朋友一定都遇到这种情况的,当你的网页中有直接链接apk下载的时候会没有反映的,是因为在微信内是无法下载软件、手机APP等,那么这个时候一般的解决方案就是:必须要点击右上角三个点,选择“在浏览器中打开”才可以。但是这时候问题就来了,怎么添加提示信息页面让用户去点击右上角三个点,选择“在浏览器中打开”呢?
其实原来很简单,就是判断当前是在微信内置浏览器中,然后将默认隐藏的提示层显示出来。
第一步:判断微信的UA。
|
1
2
|
var
ua
=
navigator
.
userAgent
;
var
isWeixin
=
!
!
/
MicroMessenger
/
i
.
test
(
ua
)
;
|
第二步:引入默认隐藏层。
|
1
2
3
4
5
6
|
<
a
href
=
"http://caibaojian/test.apk"
id
=
"JdownApp"
>点击下载
APP
<
/
a
>
<
a
href
=
"http://caibaojian/test.apk"
id
=
"JdownApp2"
class
=
"btn-warn"
>点击下载
APP2
<
/
a
>
<
div
class
=
"wxtip"
id
=
"JweixinTip"
>
<
span
class
=
"wxtip-icon"
>
<
/
span
>
<
p
class
=
"wxtip-txt"
>点击右上角
<
br
/
>选择在浏览器中打开
<
/
p
>
<
/
div
>
|
第三步:添加CSS样式
|
1
2
3
|
.
wxtip
{
background
:
rgba
(
0
,
0
,
0
,
0.8
)
;
text
-
align
:
center
;
position
:
fixed
;
left
:
0
;
top
:
0
;
width
:
100
%
;
height
:
100
%
;
z
-
index
:
998
;
display
:
none
;
}
.
wxtip
-
icon
{
width
:
52px
;
height
:
67px
;
background
:
url
(
weixin
-
tip
.
png
)
no
-
repeat
;
display
:
block
;
position
:
absolute
;
right
:
20px
;
top
:
20px
;
}
.
wxtip
-
txt
{
margin
-
top
:
107px
;
color
:
#fff; font-size: 16px; line-height: 1.5;}
|
第四步:点击按钮显示隐藏层,点击隐藏层关闭,总的JS代码如下:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
function
weixinTip
(
ele
)
{
var
ua
=
navigator
.
userAgent
;
var
isWeixin
=
!
!
/
MicroMessenger
/
i
.
test
(
ua
)
;
if
(
isWeixin
)
{
ele
.
onclick
=
function
(
e
)
{
window
.
event
?
window
.
event
.
returnValue
=
false
:
e
.
preventDefault
(
)
;
document
.
getElementById
(
'JweixinTip'
)
.
style
.
display
=
'block'
;
}
document
.
getElementById
(
'JweixinTip'
)
.
onclick
=
function
(
)
{
this
.
style
.
display
=
'none'
;
}
}
}
var
btn1
=
document
.
getElementById
(
'JdownApp'
)
;
//下载一
weixinTip
(
btn1
)
;
var
btn2
=
document
.
getElementById
(
'JdownApp2'
)
;
//下载二
weixinTip
(
btn2
)
;
|
代码演示:
演示URL链接:http://www.oicto/demo/weixin-downapp/
运行效果:
本文发布于:2025-08-05,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:提示信息跳转信中页面APP
发布评论