在目标HTML页面嵌入代码如下:
<wx-open-launch-app id="launch-card" appid="wx2d3827ceed7e4d7e" extinfo="<?php echo $extinfo;?>">
<template>
<style>.wechat_btn{background: #208BD7;color: #fff;display: inline-block; margin: 10px auto; padding:10px 100px;border: none; border-radius: 30px;}.wechat_icon{width: 14px;margin-right: 2px;}</style>
<a href="javascript:;" class="wechat_btn"><img class="wechat_icon" src="<?php echo MOBILE_URL;?>img/icon_edit.png" alt=""/><?php if($info['is_mine']){ echo '再次编辑'; }else{ echo '换成我的名片'; } ?></a>
</template>
</wx-open-launch-app>
<script>
var card_btn = document.getElementById('launch-card');
card_btn.addEventListener('launch', function (e) {
//alert('success');
});
card_btn.addEventListener('error', function (e) {
//检测用户类型,匹配文章可编辑次数
//alert('请下载app');
checkMemberTypeAjax(token);
});
</script>
//嵌入微信jsdk脚本
<script>
jQuery(function(){
//微信按钮跳转
wx.config({
//debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId:signPackage.appId,
timestamp:signPackage.timestamp,
nonceStr:signPackage.nonceStr,
signature:signPackage.signature,
jsApiList: [
'checkJsApi',
'wx-open-launch-app'
],
openTagList: ['wx-open-launch-app']
});
wx.ready(function () {
// 1 判断当前版本是否支持指定 JS 接口,支持批量判断
wx.checkJsApi({
jsApiList: [
'wx-open-launch-app'
],
openTagList: ['wx-open-launch-app']
});
//分享接口
var host = SHOP_DOMAIN_URL; //根路径
});
})
</script>
微信开放标签之唤起app
最新推荐文章于 2024-05-13 15:01:29 发布