|
|
import wx from 'weixin-js-sdk';
|
|
|
import {linkToMiniApp, invokeMethod, createLinkButton} from "../utils/common";
|
|
|
|
|
|
let env;
|
|
|
export default class {
|
|
|
constructor(_env) {
|
|
|
env = _env;
|
|
|
this.env = _env;
|
|
|
}
|
|
|
|
|
|
link(event) {
|
...
|
...
|
@@ -14,7 +13,7 @@ export default class { |
|
|
let url = element.getAttribute('data-url') || '';
|
|
|
let name = element.getAttribute('data-name') || '';
|
|
|
let linkUrl = '';
|
|
|
if (env === 'miniprogram') {
|
|
|
if (this.env === 'miniprogram') {
|
|
|
if (type === 'product') {
|
|
|
linkUrl = '/pages/goodsDetail/goodsDetail?productSkn=' + id + '&page_name=goodsList&page_param=5'
|
|
|
} else if (type === 'brand') {
|
...
|
...
|
@@ -23,7 +22,7 @@ export default class { |
|
|
linkUrl = url.split('?')[0];
|
|
|
}
|
|
|
return linkToMiniApp(linkUrl, type);
|
|
|
} else if (env === 'pc') {
|
|
|
} else if (this.env === 'pc') {
|
|
|
if (type === 'product') {
|
|
|
linkUrl = 'https://www.yohobuy.com/product/' + id + '.html';
|
|
|
} else if (type === 'brand') {
|
...
|
...
|
@@ -40,23 +39,24 @@ export default class { |
|
|
linkUrl = url
|
|
|
}
|
|
|
}
|
|
|
if (env === 'app') {
|
|
|
if (document.getElementById('yosdk-goto')) {
|
|
|
createLinkButton(linkUrl,'yosdk-goto');
|
|
|
}
|
|
|
if (this.env === 'app') {
|
|
|
let dom = document.getElementById('yosdk-goto');
|
|
|
if (!dom) {
|
|
|
dom = createLinkButton(linkUrl, 'yosdk-goto');
|
|
|
} else {
|
|
|
dom.setAttribute('href', linkUrl);
|
|
|
}
|
|
|
return dom.click();
|
|
|
|
|
|
} else {
|
|
|
window.location.href = linkUrl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
goBack() {
|
|
|
if (env === 'app') {
|
|
|
if (this.env === 'app') {
|
|
|
invokeMethod({method: 'go.back'})
|
|
|
} else if (env === 'miniprogram') {
|
|
|
} else if (this.env === 'miniprogram') {
|
|
|
wx.miniProgram.navigateBack();
|
|
|
} else {
|
|
|
history.go(-1);
|
...
|
...
|
|