H5拉起品牌会员入会组件

更新时间:2025.06.22

品牌通过品牌预授权接口获取授权的必要参数 token 后,可使用微信支付侧提供的 JS 调起品牌会员入会组件,引导用户完成入会流程(公众号端)。

接口说明

支持商户:【普通服务商】

接口名称: openBusinessView

兼容性表现说明

字段说明

请求参数

businessType 必填 string(32)

【跳转类型】固定值,请传入 wxpayCardMember


queryString 必填 string(2048)

【业务参数】需要传递给入会组件的数据。使用 URL 的 query string 方式传递参数,格式为key=value&key2=value2,其中 value、value2 需要进行 UrlEncode 处理。

属性

 

请求示例

1let wechatInfo = navigator.userAgent.match(/MicroMessenger\/([\d\.]+)/i);
2let wechatVersion = wechatInfo[1];
3
4if (compareVersion(wechatVersion, '7.0.5') >= 0) {
5	goToWXCardMember();
6} else {
7	// 提示用户升级微信客户端版本
8	window.location.href = 'https://support.weixin.qq.com/cgi-bin/readtemplate?t=page/common_page__upgrade&text=text005&btn_text=btn_text_0';
9}
10
11/**
12 * 跳转品牌入会组件
13 */
14function goToWXCardMember() {
15    wx.checkJsApi({
16        jsApiList: ['openBusinessView'], // 需要检测的 JS 接口列表
17        success: function (res) {
18        // 以键值对的形式返回,可用的 api 值 true,不可用为 false
19        // 如:{"checkResult":{"openBusinessView":true},"errMsg":"checkJsApi:ok"}
20        if (res.checkResult.openBusinessView) {
21            wx.invoke(
22                'openBusinessView', {
23                    businessType: 'wxpayCardMember',
24                    queryString: 'token=EhhEF0Jt0uDLPK6Cr70KCrJmkTtfPPE2',
25                },
26                function (res) {
27                	// 从入会组件返回时会执行这个回调函数
28                    if (parseInt(res.extraData.errcode) === 0) {
29                    	// 返回成功 
30                    } else {
31                    	// 返回失败
32                    }
33                });
34            }
35        }
36    });
37 }
38
39 /**
40  * 版本号比较
41  * @param {string} v1 
42  * @param {string} v2 
43  */
44function compareVersion(v1, v2) {
45    v1 = v1.split('.')
46    v2 = v2.split('.')
47    const len = Math.max(v1.length, v2.length)
48  
49    while (v1.length < len) {
50		v1.push('0')
51    }
52    while (v2.length < len) {
53		v2.push('0')
54    }
55  
56    for (let i = 0; i < len; i++) {
57        const num1 = parseInt(v1[i])
58        const num2 = parseInt(v2[i])
59  
60      	if (num1 > num2) {
61       		return 1
62      	} else if (num1 < num2) {
63        	return -1
64      	}
65    }
66  
67    return 0
68 }

返回参数

触发场景: 用户从品牌会员入会组件页返回到品牌页面。

注意:

  • 只有用户点击入会组件页面内返回按钮时,才会带上返回参数;如果用户左滑返回或者点击页面左上角的返回图标返回,则不会带上返回参数。

  • 推荐品牌侧以查询用户会员卡信息会员卡事件通知返回的结果为准。

extraData 必填 Object

回传商家小程序的业务数据

属性

 

 

更多技术问题
技术咨询
反馈
咨询
目录
置顶