main.js文件中加入记录首次打开的URL地址。 Vue.prototype.firstUrl = window.location.href; 分享页面:
getShare() {
let linkto = this.$u.os() === 'ios' ? t.firstUrl : window.location.href;
this.$u.api.Jssdk({ url: linkto }).then(res => {
const t = this;
t.$wx.config({
debug: false,
appId: '',
timestamp: res.data.timestamp,
nonceStr: res.data.nonceStr,
signature: res.data.signature,
jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData']
});
t.$wx.ready(function() {
t.$wx.updateAppMessageShareData({
title: t.data.title ? t.data.title : '1', // 分享标题
desc: t.data.desc ? t.data.desc : '1', // 分享描述
link: linkto, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl: t.data.titlepic ? t.data.titlepic : 'https://1/logo.png' // 分享图标
});
t.$wx.updateTimelineShareData({
title: t.data.title ? t.data.title : '1',
imgUrl: t.data.titlepic ? t.data.titlepic : 'https://1/logo.png',
link: linkto
});
});
});
},
路由设置为history,去掉网址中#号:
nginx
location / {
try_files $uri $uri/ /index.html;
}
Apache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>