ss
微信开放标签是微信公众平台面向网页开发者提供的扩展标签集合。通过使用微信开放标签,网页开发者可安全便捷地使用微信或系统的能力,为微信用户提供更优质的网页体验。
此文档面向网页开发者,介绍微信开放标签如何使用及相关注意事项。需要注意的是,微信开放标签有最低的微信版本要求,以及最低的系统版本要求。
- 微信版本要求为:7.0.12及以上
- 系统版本要求为:iOS 10.3及以上、Android 5.0及以上
对于符合微信或系统最低版本要求但仍无法使用微信开放标签的场景,将会在下方使用步骤中的wx.config
权限验证成功后触发WeixinOpenTagsError
事件告知开发者。仅无法使用微信开发标签,JS-SDK其他功能不受影响。
设置入口
使用前需将「 JS 接口安全域名绑定的服务号」绑定在「移动应用的微信开放平台账号」下,并确保服务号与此开放平台账号同主体且均已认证。请前往 微信开放平台-管理中心-公众号详情-接口信息 设置域名与所需跳转的移动应用。
获得此设置入口的权限,需同时满足如下条件:
- 服务号已认证
- 开放平台账号已认证
- 服务号与开放平台账号同主体
遇到的坑
公众号的js接口安全域名 和 微信 开发平台的安全域名需一致
公众号的js接口安全域名 和 微信 开发平台的安全域名需一致
公众号的js接口安全域名 和 微信 开发平台的安全域名需一致
我在这里卡了很久,崩溃ing
代码都写了好几次
另外一个坑
需部署到对应的服务器域名下才能进行测试,且必须用真机进行测试,微信开发者工具可以进行辅助代码调试
废话不多少,写了两套代码,你能明白我是挣扎了好久,内心是崩溃的
谁来拯救我
<template>
<view>
<wx-open-launch-app id="launch-btn" appid="wxb24995f3cd67c573" extinfo="">
<script type="text/wxtag-template">
<style>.btn { padding: 12px }</style>
<button class="btn">App内查看</button>
</script>
</wx-open-launch-app>
<!-- #ifdef H5 -->
<view v-html="wxOpenTags"></view>
<!-- #endif -->
</view>
</template>
<script>
import {
GetJsApiTicketApi
} from "@/api/common.js"
import wx from '../js_sdk/jweixin-module/index.js'
export default {
data() {
return {
wxOpenTags: '1213'
};
},
components: {},
props: {},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
this.JsApiTicketApi();
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
var that = this;
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {},
mounted() {
var btn = document.getElementById('launch-btn');
btn.addEventListener('launch', function(e) {
console.log('success');
uni.showModal({
title: '提示',
content: '成功3--------' + JSON.stringify(e),
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
});
btn.addEventListener('error', function(e) {
console.log('fail', e.detail);
uni.showModal({
title: '提示',
content: '成功4--------' + JSON.stringify(e.detail),
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
});
},
methods: {
async JsApiTicketApi() {
let _this = this;
let shareUrl = window.location.href.split('#')[0];
// let shareUrl = 'https://m.shop.sanxiaxiu.com';
console.log(shareUrl);
let res = await GetJsApiTicketApi({
shareUrl: shareUrl
});
if (res.code === 200) {
console.log('接口返回的参数-----' + res);
wx.config({
debug: true,
appId: res.data.appId, // 必填,公众号的唯一标识
timestamp: res.data.timestamp, // 必填,生成签名的时间戳
nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
signature: res.data.signature, // 必填,签名
jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'checkJsApi',
'scanQRCode'
], // 必填,需要使用的JS接口列表
openTagList: ['wx-open-launch-weapp', 'wx-open-launch-app']
});
wx.ready(function(res1) {
console.log('成功--------' + res1);
uni.showModal({
title: '提示',
content: '成功--------' + res1,
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
//#ifdef H5
setTimeout(() => {
_this.wxOpenTags = `<wx-open-launch-app id="launch-wxapp" appid="wxb24995f3cd67c573">
<template>
<style>
.btn-open-weapp{
background: linear-gradient(to right, #ffd52e 0%, #ffef93 50%, #ffd52e 100%);
border: 0;
color: #424242;
text-shadow: 0px 1px 1px #fff;
border-radius: 50px;
text-align: center;
width: 120px;
height: 35px;
line-height: 35px;
outline:none;
}
</style>
<button class="btn-open-weapp">出来吧皮卡丘</button >
</template>
</wx-open-launch-app>`;
}, 1000);
//#endif
});
wx.error(function(res2) {
close.log('失败---------' + res2);
uni.showModal({
title: '提示',
content: '失败---------' + res2,
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
alert(res2);
this.res2 = res2
});
}
},
handleLaunchFn(e) {
alert(e.detail)
},
handleErrorFn(e) {
console.log('fail', e.detail);
alert(e.detail)
},
}
};
</script>
最终版本
<template>
<view>
<view class="download">
<view class="download-img">
<u-image width="100%" height="100%" src="@/static/images/download.png"></u-image>
</view>
<view class="download-box">
<view class="download-box_btn">
<wx-open-launch-app id="launch-btn" appid="wxb24995f3cd67c573" extinfo="">
<script type="text/wxtag-template">
<style>
.btn{
background: linear-gradient(270deg, rgb(174, 137, 85), rgb(205, 164, 111));
border: 0;
color: #FFFFFF;
border-radius: 50px;
text-align: center;
width: 285px;
height: 40px;
line-height: 40px;
outline:none;
}
</style>
<button class="btn">App内查看</button>
</script>
</wx-open-launch-app>
<block v-if="!weixinFlag">
<u-button type="warning" shape="circle"
:custom-style="{'background': 'linear-gradient(270deg, #AE8955, #CDA46F)'}"
@click="downloadFn" :loading="loading">下载手机版</u-button>
</block>
</view>
<view class="download-box_ul">
<view>开发者:三峡绣手工艺品有限公司</view>
<view>版本:{{versionsData.versionName}}丨更新时间:{{versionsData.versionReplaceTime}}</view>
<view>查看<text @click="goRoute(1)">隐私政策</text>与<text @click="goRoute(2)">应用权限</text>信息</view>
</view>
</view>
</view>
</view>
</template>
<script>
import {
mapGetters
} from 'vuex';
import {
GetJsApiTicketApi
} from "@/api/common.js"
import wx from '../js_sdk/jweixin-module/index.js'
export default {
data() {
return {
weixinFlag: false,
progress: 0,
loading: false,
};
},
components: {},
props: {},
computed: {
...mapGetters(['versionsData']),
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
var ua = window.navigator.userAgent.toLowerCase();
if (ua.indexOf('micromessenger') > -1) {
this.weixinFlag = true; // 是微信端
this.JsApiTicketApi();
} else {
this.weixinFlag = false;
}
},
//显示状态
onShow() {
this.loading = false
},
mounted() {
let _this = this;
var btn = document.getElementById('launch-btn');
btn.addEventListener('launch', function(e) {
console.log('success');
});
btn.addEventListener('error', function(e) {
console.log('fail', e.detail);
uni.showModal({
title: '系统消息',
content: '您的手机未找到当前应用,是否去下载?',
success: function(res) {
if (res.confirm) {
window.location.href = _this.versionsData.versionResources
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
});
},
methods: {
async JsApiTicketApi() {
let _this = this;
let shareUrl = window.location.href.split('#')[0];
let res = await GetJsApiTicketApi({
shareUrl: shareUrl
});
if (res.code === 200) {
console.log('接口返回的参数-----' + res);
wx.config({
appId: res.data.appId, // 必填,公众号的唯一标识
timestamp: res.data.timestamp, // 必填,生成签名的时间戳
nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
signature: res.data.signature, // 必填,签名
jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'checkJsApi',
'scanQRCode'
], // 必填,需要使用的JS接口列表
openTagList: ['wx-open-launch-weapp', 'wx-open-launch-app']
});
wx.ready(function(res1) {
console.log('成功--------' + res1);
});
wx.error(function(res2) {
close.log('失败---------' + res2);
});
}
},
/**
* @Author:HS
* @Function: 跳转页面
* @Date: 2021-5-13 14:35:31
* @Param: {Number:iType}{类型:true}
* @Return: null
*/
goRoute(iType) {
uni.navigateTo({
url: '/pages/introduce?iType=' + iType
});
},
/**
* @Author:HS
* @Function: 下载
* @Date: 2021-5-11 17:05:07
* @Param: null
* @Return: null
*/
downloadFn() {
const _this = this;
_this.loading = true
// #ifdef APP-PLUS
const downloadTask = uni.downloadFile({
url: _this.versionsData.versionResources, //仅为示例,并非真实的资源
success: (res) => {
console.log(res);
if (res.statusCode === 200) {
console.log('下载成功');
plus.runtime.install(res.tempFilePath)
}
}
});
downloadTask.onProgressUpdate((res) => {
_this.progress = res.progress
// 测试条件,取消下载任务。
// if (res.progress > 50) {
// downloadTask.abort();
// }
});
// #endif
// #ifdef H5
if (this.$base.isWeiXin() && uni.getSystemInfoSync().platform === 'android') {
window.location.href = _this.versionsData.versionResources;
return
}
let timeout, t = 3000,
hasApp = true;
let openScript = setTimeout(function() {
if (!hasApp) {
// 跳转下载链接
if (uni.getSystemInfoSync().platform === 'ios') {
// window.location.href = "https://a.app.qq.com/o/simple.jsp?pkgname=xxx";
} else if (uni.getSystemInfoSync().platform === 'android') {
console.log(_this.versionsData.versionResources);
window.location.href = _this.versionsData.versionResources;
_this.loading = false
}
}
document.body.removeChild(ifr);
clearTimeout(openScript)
}, 3500)
let t1 = Date.now();
let ifr = document.createElement("iframe");
if (uni.getSystemInfoSync().platform === 'ios') {
ifr.setAttribute('src', '');
} else if (uni.getSystemInfoSync().platform === 'android') {
ifr.setAttribute('src', 'zqkj://data=777777');
}
ifr.setAttribute('style', 'display:none');
document.body.appendChild(ifr);
timeout = setTimeout(function() {
var t2 = Date.now();
if (t2 - t1 < t + 100) {
hasApp = false;
}
clearTimeout(timeout)
}, t);
// #endif
}
}
};
</script>
<style lang="scss" scoped>
.download {
height: 100vh;
&-img {
height: 722rpx;
}
&-box {
height: calc(100vh - 722rpx);
flex-direction: column;
display: flex;
align-items: center;
justify-content: center;
&_btn {
width: 570rpx;
}
&_ul {
padding-top: 50rpx;
display: flex;
flex-direction: column;
align-items: center;
@include fz1(24rpx, $color-font-6);
line-height: 50rpx;
view {
text {
text-decoration: underline;
}
}
}
}
}
</style>
jweixin-module/index.js
! function(e, n) {
"function" == typeof define && (define.amd || define.cmd) ? define(function() {
return n(e)
}) : n(e, !0)
}(window, function(o, e) {
if (!o.jWeixin) {
var n, c = {
config: "preVerifyJSAPI",
onMenuShareTimeline: "menu:share:timeline",
onMenuShareAppMessage: "menu:share:appmessage",
onMenuShareQQ: "menu:share:qq",
onMenuShareWeibo: "menu:share:weiboApp",
onMenuShareQZone: "menu:share:QZone",
previewImage: "imagePreview",
getLocation: "geoLocation",
openProductSpecificView: "openProductViewWithPid",
addCard: "batchAddCard",
openCard: "batchViewCard",
chooseWXPay: "getBrandWCPayRequest",
openEnterpriseRedPacket: "getRecevieBizHongBaoRequest",
startSearchBeacons: "startMonitoringBeacons",
stopSearchBeacons: "stopMonitoringBeacons",
onSearchBeacons: "onBeaconsInRange",
consumeAndShareCard: "consumedShareCard",
openAddress: "editAddress"
},
a = function() {
var e = {};
for (var n in c) e[c[n]] = n;
return e
}(),
i = o.document,
t = i.title,
r = navigator.userAgent.toLowerCase(),
s = navigator.platform.toLowerCase(),
d = !(!s.match("mac") && !s.match("win")),
u = -1 != r.indexOf("wxdebugger"),
l = -1 != r.indexOf("micromessenger"),
p = -1 != r.indexOf("android"),
f = -1 != r.indexOf("iphone") || -1 != r.indexOf("ipad"),
m = (n = r.match(/micromessenger\/(\d+\.\d+\.\d+)/) || r.match(/micromessenger\/(\d+\.\d+)/)) ? n[1] :
"",
g = {
initStartTime: L(),
initEndTime: 0,
preVerifyStartTime: 0,
preVerifyEndTime: 0
},
h = {
version: 1,
appId: "",
initTime: 0,
preVerifyTime: 0,
networkType: "",
isPreVerifyOk: 1,
systemType: f ? 1 : p ? 2 : -1,
clientVersion: m,
url: encodeURIComponent(location.href)
},
v = {},
S = {
_completes: []
},
y = {
state: 0,
data: {}
};
O(function() {
g.initEndTime = L()
});
var I = !1,
_ = [],
w = {
config: function(e) {
B("config", v = e);
var t = !1 !== v.check;
O(function() {
if (t) M(c.config, {
verifyJsApiList: C(v.jsApiList),
verifyOpenTagList: C(v.openTagList)
}, function() {
S._complete = function(e) {
g.preVerifyEndTime = L(), y.state = 1, y.data = e
}, S.success = function(e) {
h.isPreVerifyOk = 0
}, S.fail = function(e) {
S._fail ? S._fail(e) : y.state = -1
};
var t = S._completes;
return t.push(function() {
! function() {
if (!(d || u || v.debug || m < "6.0.2" || h
.systemType < 0)) {
var i = new Image;
h.appId = v.appId, h.initTime = g.initEndTime -
g.initStartTime, h.preVerifyTime = g
.preVerifyEndTime - g.preVerifyStartTime, w
.getNetworkType({
isInnerInvoke: !0,
success: function(e) {
h.networkType = e
.networkType;
var n =
"https://open.weixin.qq.com/sdk/report?v=" +
h.version + "&o=" + h
.isPreVerifyOk + "&s=" +
h.systemType + "&c=" + h
.clientVersion + "&a=" +
h.appId + "&n=" + h
.networkType + "&i=" + h
.initTime + "&p=" + h
.preVerifyTime + "&u=" +
h.url;
i.src = n
}
})
}
}()
}), S.complete = function(e) {
for (var n = 0, i = t.length; n < i; ++n) t[n]();
S._completes = []
}, S
}()), g.preVerifyStartTime = L();
else {
y.state = 1;
for (var e = S._completes, n = 0, i = e.length; n < i; ++n) e[n]();
S._completes = []
}
}), w.invoke || (w.invoke = function(e, n, i) {
o.WeixinJSBridge && WeixinJSBridge.invoke(e, x(n), i)
}, w.on = function(e, n) {
o.WeixinJSBridge && WeixinJSBridge.on(e, n)
})
},
ready: function(e) {
0 != y.state ? e() : (S._completes.push(e), !l && v.debug && e())
},
error: function(e) {
m < "6.0.2" || (-1 == y.state ? e(y.data) : S._fail = e)
},
checkJsApi: function(e) {
M("checkJsApi", {
jsApiList: C(e.jsApiList)
}, (e._complete = function(e) {
if (p) {
var n = e.checkResult;
n && (e.checkResult = JSON.parse(n))
}
e = function(e) {
var n = e.checkResult;
for (var i in n) {
var t = a[i];
t && (n[t] = n[i], delete n[i])
}
return e
}(e)
}, e))
},
onMenuShareTimeline: function(e) {
P(c.onMenuShareTimeline, {
complete: function() {
M("shareTimeline", {
title: e.title || t,
desc: e.title || t,
img_url: e.imgUrl || "",
link: e.link || location.href,
type: e.type || "link",
data_url: e.dataUrl || ""
}, e)
}
}, e)
},
onMenuShareAppMessage: function(n) {
P(c.onMenuShareAppMessage, {
complete: function(e) {
"favorite" === e.scene ? M("sendAppMessage", {
title: n.title || t,
desc: n.desc || "",
link: n.link || location.href,
img_url: n.imgUrl || "",
type: n.type || "link",
data_url: n.dataUrl || ""
}) : M("sendAppMessage", {
title: n.title || t,
desc: n.desc || "",
link: n.link || location.href,
img_url: n.imgUrl || "",
type: n.type || "link",
data_url: n.dataUrl || ""
}, n)
}
}, n)
},
onMenuShareQQ: function(e) {
P(c.onMenuShareQQ, {
complete: function() {
M("shareQQ", {
title: e.title || t,
desc: e.desc || "",
img_url: e.imgUrl || "",
link: e.link || location.href
}, e)
}
}, e)
},
onMenuShareWeibo: function(e) {
P(c.onMenuShareWeibo, {
complete: function() {
M("shareWeiboApp", {
title: e.title || t,
desc: e.desc || "",
img_url: e.imgUrl || "",
link: e.link || location.href
}, e)
}
}, e)
},
onMenuShareQZone: function(e) {
P(c.onMenuShareQZone, {
complete: function() {
M("shareQZone", {
title: e.title || t,
desc: e.desc || "",
img_url: e.imgUrl || "",
link: e.link || location.href
}, e)
}
}, e)
},
updateTimelineShareData: function(e) {
M("updateTimelineShareData", {
title: e.title,
link: e.link,
imgUrl: e.imgUrl
}, e)
},
updateAppMessageShareData: function(e) {
M("updateAppMessageShareData", {
title: e.title,
desc: e.desc,
link: e.link,
imgUrl: e.imgUrl
}, e)
},
startRecord: function(e) {
M("startRecord", {}, e)
},
stopRecord: function(e) {
M("stopRecord", {}, e)
},
onVoiceRecordEnd: function(e) {
P("onVoiceRecordEnd", e)
},
playVoice: function(e) {
M("playVoice", {
localId: e.localId
}, e)
},
pauseVoice: function(e) {
M("pauseVoice", {
localId: e.localId
}, e)
},
stopVoice: function(e) {
M("stopVoice", {
localId: e.localId
}, e)
},
onVoicePlayEnd: function(e) {
P("onVoicePlayEnd", e)
},
uploadVoice: function(e) {
M("uploadVoice", {
localId: e.localId,
isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1
}, e)
},
downloadVoice: function(e) {
M("downloadVoice", {
serverId: e.serverId,
isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1
}, e)
},
translateVoice: function(e) {
M("translateVoice", {
localId: e.localId,
isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1
}, e)
},
chooseImage: function(e) {
M("chooseImage", {
scene: "1|2",
count: e.count || 9,
sizeType: e.sizeType || ["original", "compressed"],
sourceType: e.sourceType || ["album", "camera"]
}, (e._complete = function(e) {
if (p) {
var n = e.localIds;
try {
n && (e.localIds = JSON.parse(n))
} catch (e) {}
}
}, e))
},
getLocation: function(e) {},
previewImage: function(e) {
M(c.previewImage, {
current: e.current,
urls: e.urls
}, e)
},
uploadImage: function(e) {
M("uploadImage", {
localId: e.localId,
isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1
}, e)
},
downloadImage: function(e) {
M("downloadImage", {
serverId: e.serverId,
isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1
}, e)
},
getLocalImgData: function(e) {
!1 === I ? (I = !0, M("getLocalImgData", {
localId: e.localId
}, (e._complete = function(e) {
if (I = !1, 0 < _.length) {
var n = _.shift();
wx.getLocalImgData(n)
}
}, e))) : _.push(e)
},
getNetworkType: function(e) {
M("getNetworkType", {}, (e._complete = function(e) {
e = function(e) {
var n = e.errMsg;
e.errMsg = "getNetworkType:ok";
var i = e.subtype;
if (delete e.subtype, i) e.networkType = i;
else {
var t = n.indexOf(":"),
o = n.substring(t + 1);
switch (o) {
case "wifi":
case "edge":
case "wwan":
e.networkType = o;
break;
default:
e.errMsg = "getNetworkType:fail"
}
}
return e
}(e)
}, e))
},
openLocation: function(e) {
M("openLocation", {
latitude: e.latitude,
longitude: e.longitude,
name: e.name || "",
address: e.address || "",
scale: e.scale || 28,
infoUrl: e.infoUrl || ""
}, e)
},
getLocation: function(e) {
M(c.getLocation, {
type: (e = e || {}).type || "wgs84"
}, (e._complete = function(e) {
delete e.type
}, e))
},
hideOptionMenu: function(e) {
M("hideOptionMenu", {}, e)
},
showOptionMenu: function(e) {
M("showOptionMenu", {}, e)
},
closeWindow: function(e) {
M("closeWindow", {}, e = e || {})
},
hideMenuItems: function(e) {
M("hideMenuItems", {
menuList: e.menuList
}, e)
},
showMenuItems: function(e) {
M("showMenuItems", {
menuList: e.menuList
}, e)
},
hideAllNonBaseMenuItem: function(e) {
M("hideAllNonBaseMenuItem", {}, e)
},
showAllNonBaseMenuItem: function(e) {
M("showAllNonBaseMenuItem", {}, e)
},
scanQRCode: function(e) {
M("scanQRCode", {
needResult: (e = e || {}).needResult || 0,
scanType: e.scanType || ["qrCode", "barCode"]
}, (e._complete = function(e) {
if (f) {
var n = e.resultStr;
if (n) {
var i = JSON.parse(n);
e.resultStr = i && i.scan_code && i.scan_code.scan_result
}
}
}, e))
},
openAddress: function(e) {
M(c.openAddress, {}, (e._complete = function(e) {
e = function(e) {
return e.postalCode = e.addressPostalCode, delete e
.addressPostalCode, e.provinceName = e.proviceFirstStageName,
delete e.proviceFirstStageName, e.cityName = e
.addressCitySecondStageName, delete e
.addressCitySecondStageName, e.countryName = e
.addressCountiesThirdStageName, delete e
.addressCountiesThirdStageName, e.detailInfo = e
.addressDetailInfo, delete e.addressDetailInfo, e
}(e)
}, e))
},
openProductSpecificView: function(e) {
M(c.openProductSpecificView, {
pid: e.productId,
view_type: e.viewType || 0,
ext_info: e.extInfo
}, e)
},
addCard: function(e) {
for (var n = e.cardList, i = [], t = 0, o = n.length; t < o; ++t) {
var r = n[t],
a = {
card_id: r.cardId,
card_ext: r.cardExt
};
i.push(a)
}
M(c.addCard, {
card_list: i
}, (e._complete = function(e) {
var n = e.card_list;
if (n) {
for (var i = 0, t = (n = JSON.parse(n)).length; i < t; ++i) {
var o = n[i];
o.cardId = o.card_id, o.cardExt = o.card_ext, o.isSuccess = !!o
.is_succ, delete o.card_id, delete o.card_ext, delete o.is_succ
}
e.cardList = n, delete e.card_list
}
}, e))
},
chooseCard: function(e) {
M("chooseCard", {
app_id: v.appId,
location_id: e.shopId || "",
sign_type: e.signType || "SHA1",
card_id: e.cardId || "",
card_type: e.cardType || "",
card_sign: e.cardSign,
time_stamp: e.timestamp + "",
nonce_str: e.nonceStr
}, (e._complete = function(e) {
e.cardList = e.choose_card_info, delete e.choose_card_info
}, e))
},
openCard: function(e) {
for (var n = e.cardList, i = [], t = 0, o = n.length; t < o; ++t) {
var r = n[t],
a = {
card_id: r.cardId,
code: r.code
};
i.push(a)
}
M(c.openCard, {
card_list: i
}, e)
},
consumeAndShareCard: function(e) {
M(c.consumeAndShareCard, {
consumedCardId: e.cardId,
consumedCode: e.code
}, e)
},
chooseWXPay: function(e) {
M(c.chooseWXPay, V(e), e)
},
openEnterpriseRedPacket: function(e) {
M(c.openEnterpriseRedPacket, V(e), e)
},
startSearchBeacons: function(e) {
M(c.startSearchBeacons, {
ticket: e.ticket
}, e)
},
stopSearchBeacons: function(e) {
M(c.stopSearchBeacons, {}, e)
},
onSearchBeacons: function(e) {
P(c.onSearchBeacons, e)
},
openEnterpriseChat: function(e) {
M("openEnterpriseChat", {
useridlist: e.userIds,
chatname: e.groupName
}, e)
},
launchMiniProgram: function(e) {
M("launchMiniProgram", {
targetAppId: e.targetAppId,
path: function(e) {
if ("string" == typeof e && 0 < e.length) {
var n = e.split("?")[0],
i = e.split("?")[1];
return n += ".html", void 0 !== i ? n + "?" + i : n
}
}(e.path),
envVersion: e.envVersion
}, e)
},
openBusinessView: function(e) {
M("openBusinessView", {
businessType: e.businessType,
queryString: e.queryString || "",
envVersion: e.envVersion
}, (e._complete = function(n) {
if (p) {
var e = n.extraData;
if (e) try {
n.extraData = JSON.parse(e)
} catch (e) {
n.extraData = {}
}
}
}, e))
},
miniProgram: {
navigateBack: function(e) {
e = e || {}, O(function() {
M("invokeMiniProgramAPI", {
name: "navigateBack",
arg: {
delta: e.delta || 1
}
}, e)
})
},
navigateTo: function(e) {
O(function() {
M("invokeMiniProgramAPI", {
name: "navigateTo",
arg: {
url: e.url
}
}, e)
})
},
redirectTo: function(e) {
O(function() {
M("invokeMiniProgramAPI", {
name: "redirectTo",
arg: {
url: e.url
}
}, e)
})
},
switchTab: function(e) {
O(function() {
M("invokeMiniProgramAPI", {
name: "switchTab",
arg: {
url: e.url
}
}, e)
})
},
reLaunch: function(e) {
O(function() {
M("invokeMiniProgramAPI", {
name: "reLaunch",
arg: {
url: e.url
}
}, e)
})
},
postMessage: function(e) {
O(function() {
M("invokeMiniProgramAPI", {
name: "postMessage",
arg: e.data || {}
}, e)
})
},
getEnv: function(e) {
O(function() {
e({
miniprogram: "miniprogram" === o.__wxjs_environment
})
})
}
}
},
T = 1,
k = {};
return i.addEventListener("error", function(e) {
if (!p) {
var n = e.target,
i = n.tagName,
t = n.src;
if ("IMG" == i || "VIDEO" == i || "AUDIO" == i || "SOURCE" == i)
if (-1 != t.indexOf("wxlocalresource://")) {
e.preventDefault(), e.stopPropagation();
var o = n["wx-id"];
if (o || (o = T++, n["wx-id"] = o), k[o]) return;
k[o] = !0, wx.ready(function() {
wx.getLocalImgData({
localId: t,
success: function(e) {
n.src = e.localData
}
})
})
}
}
}, !0), i.addEventListener("load", function(e) {
if (!p) {
var n = e.target,
i = n.tagName;
n.src;
if ("IMG" == i || "VIDEO" == i || "AUDIO" == i || "SOURCE" == i) {
var t = n["wx-id"];
t && (k[t] = !1)
}
}
}, !0), e && (o.wx = o.jWeixin = w), w
}
function M(n, e, i) {
o.WeixinJSBridge ? WeixinJSBridge.invoke(n, x(e), function(e) {
A(n, e, i)
}) : B(n, i)
}
function P(n, i, t) {
o.WeixinJSBridge ? WeixinJSBridge.on(n, function(e) {
t && t.trigger && t.trigger(e), A(n, e, i)
}) : B(n, t || i)
}
function x(e) {
return (e = e || {}).appId = v.appId, e.verifyAppId = v.appId, e.verifySignType = "sha1", e
.verifyTimestamp = v.timestamp + "", e.verifyNonceStr = v.nonceStr, e.verifySignature = v.signature, e
}
function V(e) {
return {
timeStamp: e.timestamp + "",
nonceStr: e.nonceStr,
package: e.package,
paySign: e.paySign,
signType: e.signType || "SHA1"
}
}
function A(e, n, i) {
"openEnterpriseChat" != e && "openBusinessView" !== e || (n.errCode = n.err_code), delete n.err_code,
delete n.err_desc, delete n.err_detail;
var t = n.errMsg;
t || (t = n.err_msg, delete n.err_msg, t = function(e, n) {
var i = e,
t = a[i];
t && (i = t);
var o = "ok";
if (n) {
var r = n.indexOf(":");
"confirm" == (o = n.substring(r + 1)) && (o = "ok"), "failed" == o && (o = "fail"), -1 != o
.indexOf("failed_") && (o = o.substring(7)), -1 != o.indexOf("fail_") && (o = o
.substring(5)), "access denied" != (o = (o = o.replace(/_/g, " ")).toLowerCase()) &&
"no permission to execute" != o || (o = "permission denied"), "config" == i &&
"function not exist" == o && (o = "ok"), "" == o && (o = "fail")
}
return n = i + ":" + o
}(e, t), n.errMsg = t), (i = i || {})._complete && (i._complete(n), delete i._complete), t = n.errMsg ||
"", v.debug && !i.isInnerInvoke && alert(JSON.stringify(n));
var o = t.indexOf(":");
switch (t.substring(o + 1)) {
case "ok":
i.success && i.success(n);
break;
case "cancel":
i.cancel && i.cancel(n);
break;
default:
i.fail && i.fail(n)
}
i.complete && i.complete(n)
}
function C(e) {
if (e) {
for (var n = 0, i = e.length; n < i; ++n) {
var t = e[n],
o = c[t];
o && (e[n] = o)
}
return e
}
}
function B(e, n) {
if (!(!v.debug || n && n.isInnerInvoke)) {
var i = a[e];
i && (e = i), n && n._complete && delete n._complete, console.log('"' + e + '",', n || "")
}
}
function L() {
return (new Date).getTime()
}
function O(e) {
l && (o.WeixinJSBridge ? e() : i.addEventListener && i.addEventListener("WeixinJSBridgeReady", e, !1))
}
});