tool.js
1.14 KB
import wx from '../utils/wx';
// import gominiapp from './gominiapp';
import gominiapp from '../router/jump-to-miniapp.js';
import { parse, stringify } from '../vendors/query-stringify';
import event from '../common/event';
export default {
scanCode: function() {
wx.scanCode().then(res => {
const domRex = /^http(s)?:\/\/o\.yohobuy\.com/;
const splitAry = res.result.split('?');
const skn = parse(splitAry[1]).skn;
if (domRex.test(res.result) && skn) {
event.emit('scan-success', {URL: res.result}); // 扫码成功后上报
gominiapp({
app: 'yohobuy',
page: 'productDetail',
data: {
productSkn: skn
}
});
} else {
wx.showModal({
content: '您扫描的二维码对应链接格式不正确,请重新扫码',
showCancel: false
});
}
});
},
notJump: function() {
// 配置不跳转连接,解决后台URL必须配置问题
}
};