...
|
...
|
@@ -3,7 +3,9 @@ import wx from "weixin-js-sdk"; |
|
|
const invokeMethod = (obj) => {
|
|
|
let appInterface = window.yohoInterface;
|
|
|
if (appInterface) {
|
|
|
appInterface.triggerEvent(obj.success || function(){}, obj.fail || function(){}, {
|
|
|
appInterface.triggerEvent(obj.success || function () {
|
|
|
}, obj.fail || function () {
|
|
|
}, {
|
|
|
method: obj.method,
|
|
|
arguments: obj.args
|
|
|
});
|
...
|
...
|
@@ -12,28 +14,24 @@ const invokeMethod = (obj) => { |
|
|
}
|
|
|
}
|
|
|
|
|
|
const linkToMiniApp = (goUrl,type) => {
|
|
|
const linkToMiniApp = (goUrl, type) => {
|
|
|
let url = goUrl || '';
|
|
|
if (url && url.indexOf('http') < 0 && type === 'other') {
|
|
|
url = document.location.protocol + '//' + document.location.host + url;
|
|
|
}
|
|
|
|
|
|
if (url) {
|
|
|
let scene;
|
|
|
if (type === 'product' || type === 'brand') {
|
|
|
scene = url;
|
|
|
} else {
|
|
|
let base_url = decodeURIComponent(url).split('?')[0];
|
|
|
let params = getQueryObj(url);
|
|
|
let paramStr = '';
|
|
|
Object.keys(params).forEach(key => {
|
|
|
paramStr += paramStr === '' ? '?' + key + '=' + params[key] : '&' + key + '=' + params[key];
|
|
|
})
|
|
|
|
|
|
let mini_url = '/pages/webview/webview?url=' + base_url;
|
|
|
let scene = mini_url + encodeURIComponent(paramStr);
|
|
|
|
|
|
if (type === 'product' || type === 'brand') {
|
|
|
mini_url = url;
|
|
|
scene = mini_url;
|
|
|
scene = '/pages/webview/webview?url=' + base_url + encodeURIComponent(paramStr);
|
|
|
}
|
|
|
|
|
|
wx.miniProgram.navigateTo({url: scene});
|
|
|
return false;
|
|
|
} else {
|
...
|
...
|
@@ -44,11 +42,9 @@ const linkToMiniApp = (goUrl,type) => { |
|
|
|
|
|
const getQueryObj = (link) => {
|
|
|
let loc = decodeURIComponent(document.location.href);
|
|
|
|
|
|
if (link) {
|
|
|
loc = decodeURIComponent(link);
|
|
|
}
|
|
|
console.log('loc:', loc);
|
|
|
let variables = '';
|
|
|
let variableArr = [];
|
|
|
let finalArr = [];
|
...
|
...
|
|