通过微信H5进入微信公众号

通过微信H5进入微信公众号

最终主要代码
<a href="https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzUzOTk0MDMzNQ==#wechat_redirect">跳转到我的公众号吧</a>
体验链接

http://test.wangyc.top/test/open_wxgghao/mini.html

一、如何获取 微信公众号的 id 【注意此ID非注册信息中的原始ID】
    1. 打开微信公众平台并登录
    2. 右键查看网页源代码
    3. 寻找 window.wx.commonData 字段内容信息
    4. 该字段中的 uin 就是你当前公众号的id
    5. 下边请看演示

教你获取微信公众号id

二 、制作跳转链接
  • 跳转链接格式为 https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzUzOTk0MDMzNQ==#wechat_redirect
  • 其中需要我们修改的部分为 该 “ MzUzOTk0MDMzNQ== ” 部分,这部分其实是我们微信公众号id进行的 base64 加密后的
  • base64加密前:3539940335;base64加密后:MzUzOTk0MDMzNQ==
最终链接
https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzUzOTk0MDMzNQ==#wechat_redirect
三、示例代码
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>跳转至微信公众号</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no" />
		<style type="text/css">
			.navto {
				width: 8rem;
				height: 4rem;
				text-align: center;
				line-height: 4rem;
				background: #FFCC00;
				color: #FFFFFF;
				font-size: 0.85rem;
				border-radius: 0.4rem;
				margin: 0.8rem auto 0 auto;
			}
		</style>
		<script type="text/javascript">
			function w() {
				let htmlwidth = document.documentElement.clientWidth || document.body.clientWidth;
				let htmlDom = document.getElementsByTagName('html')[0];
				// if (htmlwidth > 750) {
				//  htmlwidth = 750
				// }
				htmlDom.style.fontSize = htmlwidth / 20 + 'px';
		
			}
			// 实时监测当前设备是否进行横竖屏切换
			var evt = "onorientationchange" in window ? "orientationchange" : "resize";
			window.addEventListener(evt, resize, false);
		
			function resize(fals) {
				if (window.orientation == 0 || window.orientation == 180) {
					w()
				} else {
					w()
				}
			}
			resize(true);
		</script>
	</head>
	<body>
		<div class="navto"><a href="https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzUzOTk0MDMzNQ==#wechat_redirect">测试H5跳转公众号</a></div>		
	</body>
</html>

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值