微信小程序 解决内层页面分享出去后 用户无法通过分享页面返回首页问题
本质就是设置一个变量isshare来判断是否是分享页面中进入的
data设置
isshare: 0,
js
onShareAppMessage: function () {
return {
title: 'xxx',
path: 'pages/MyPages/my_detail/my_detail?isshare=1&&id=' + this.data.id
}
},
backHome: function () {
wx.reLaunch({
url: '/pages/home/home-index/home-index'
})
}
onload
if (options.isshare == 1) {
console.log('是分享进入');
this.setData({
'isshare': options.isshare
})
}
wxml
<image wx:if="{{isshare}}" bindtap='backHome' class='d-back-home' src='http://cdn.xcx.pemarket.com.cn/icon-Return%20to%20the%20home%20page.png' lazy-load></image>
css
.d-back-home {
position: fixed;
width: 96rpx;
height: 96rpx;
right: 30rpx;
bottom: 166rpx;
z-index: 10000;
}