|
|
/* global wx */
|
|
|
import $ from 'yoho-jquery';
|
|
|
|
|
|
class LinkHandle {
|
|
|
constructor() {
|
|
|
$('a').map((index, elem) => {
|
|
|
$(elem).on('click', event => {
|
|
|
let $currentTarget = $(event.currentTarget);
|
|
|
let href = $currentTarget.attr('href');
|
|
|
|
|
|
if (!href) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
let path = this.transToPath(href);
|
|
|
|
|
|
this.goMiniProgram(path);
|
|
|
|
|
|
event.preventDefault();
|
|
|
});
|
|
|
|
|
|
return false;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 跳小程序原生页面
|
|
|
*/
|
|
|
goMiniProgram(path) {
|
|
|
if (wx) {
|
|
|
wx.miniProgram.navigateTo({
|
|
|
url: path
|
|
|
});
|
|
|
} else {
|
|
|
// TODO
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 转换为小程序页面地址
|
|
|
*/
|
|
|
transToPath(href) {
|
|
|
let path = href;
|
|
|
|
|
|
return path;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export default new LinkHandle(); |
...
|
...
|
|