视频一区二区三区自拍_千金肉奴隷1985未删减版在线观看_国产成人黄色视频在线播放_少女免费播放片高清在线观看_国产精品v欧美精品v

JSAPI調(diào)起支付分-授權(quán)服務(wù)

更新時(shí)間:2024.06.18

商戶通過調(diào)用授權(quán)服務(wù)接口打開微信支付分小程序,引導(dǎo)用戶授權(quán)服務(wù)(Web端)

# 接口說明

支持商戶: 【普通服務(wù)商】

接口名稱: openBusinessView

# 接口兼容

此接口引用 JSAPI版本1.5.0,引用地址:https://res.wx.qq.com/open/js/jweixin-1.5.0.js (opens new window)

要求用戶微信版本>=7.0.5

# 接口參數(shù)

# Object

  • businessType 必填 string(16)
    【跳轉(zhuǎn)類型】
    固定配置:wxpayScoreEnable。
  • queryString 必填 string(2048)
    【業(yè)務(wù)參數(shù)】
    使用URL的query string方式傳遞參數(shù),格式為key=value&key2=value2,其中value,value2需要進(jìn)行UrlEncode處理。
    • 屬性

query示例

1apply_permissions_token=zyx53Nkey8o4bHpxTQvd8m7e92nG5mG2

示例

1let wechatInfo = navigator.userAgent.match(/MicroMessenger\/([\d\.]+)/i);
2let wechatVersion = wechatInfo[1];
3
4if (compareVersion(wechatVersion, '7.0.5') >= 0) {
5 goToWXScore();
6} else {
7 // 提示用戶升級(jí)微信客戶端版本
8 window.href = 'https://support.weixin.qq.com/cgi-bin/readtemplate?t=page/
9 common_page__upgrade&text=text005&btn_text=btn_text_0'
10}
11
12/**
13 * 跳轉(zhuǎn)微信支付分
14 */
15function goToWXScore() {
16 wx.checkJsApi({
17 jsApiList: ['openBusinessView'], // 需要檢測(cè)的JS接口列表
18 success: function (res) {
19 // 以鍵值對(duì)的形式返回,可用的api值true,不可用為false
20 // 如:{"checkResult":{"openBusinessView":true},"errMsg":"checkJsApi:ok"}
21 if (res.checkResult.openBusinessView) {
22 wx.invoke(
23 'openBusinessView', {
24 businessType: 'wxpayScoreEnable',
25 queryString: 'apply_permissions_token=zyx53Nkey8o4bHpxTQvd8m7e92nG5mG2'
26 },
27 function (res) {
28 // 從微信側(cè)小程序返回時(shí)會(huì)執(zhí)行這個(gè)回調(diào)函數(shù)
29 if (parseint(res.err_code) === 0) {
30 // 返回成功
31 } else {
32 // 返回失敗
33 }
34 });
35 }
36 }
37 });
38 }
39
40 /**
41 * 版本號(hào)比較
42 * @param {string} v1
43 * @param {string} v2
44 */
45function compareVersion(v1, v2) {
46 v1 = v1.split('.')
47 v2 = v2.split('.')
48 const len = Math.max(v1.length, v2.length)
49
50 while (v1.length < len) {
51 v1.push('0')
52 }
53 while (v2.length < len) {
54 v2.push('0')
55 }
56
57 for (let i = 0; i < len; i++) {
58 const num1 = parseint(v1[i])
59 const num2 = parseint(v2[i])
60
61 if (num1 > num2) {
62 return 1
63 } else if (num1 < num2) {
64 return -1
65 }
66 }
67
68 return 0
69 }
更多技術(shù)問題
技術(shù)咨詢
反饋
咨詢
目錄