H5拉起品牌会员入会组件

更新时间:2025.12.10

服务商通过入会组件预授权接口获取授权的必要参数 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&scene=CARD_MEMBER',
25                },
26                function (res) {
27                	// 从入会组件返回时会执行这个回调函数
28                    if (parseInt(res.extraData.errcode) === 0) {
29                    	// 返回成功
30                        if (res.extraData.data.hasJoinCardMember) {
31                            // 用户入会成功
32                        } else {
33                            // 用户入会失败
34                        }
35                    } else {
36                    	// 返回失败
37                    }
38                });
39            }
40        }
41    });
42 }
43
44 /**
45  * 版本号比较
46  * @param {string} v1 
47  * @param {string} v2 
48  */
49function compareVersion(v1, v2) {
50    v1 = v1.split('.')
51    v2 = v2.split('.')
52    const len = Math.max(v1.length, v2.length)
53  
54    while (v1.length < len) {
55		v1.push('0')
56    }
57    while (v2.length < len) {
58		v2.push('0')
59    }
60  
61    for (let i = 0; i < len; i++) {
62        const num1 = parseInt(v1[i])
63        const num2 = parseInt(v2[i])
64  
65      	if (num1 > num2) {
66       		return 1
67      	} else if (num1 < num2) {
68        	return -1
69      	}
70    }
71  
72    return 0
73 }

返回参数

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

注意:

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

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

 extraData    必填 Object

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

属性

 

 

元宝AI
反馈
目录
置顶