雖然左上角有個(gè)返回 + 首頁(yè)的按鈕,但是客戶要返回上一頁(yè)的話,大部分人肯定第一操作是按那個(gè) 返回 按鈕,按幾下按不動(dòng)(影響體驗(yàn)) 按幾下沒(méi)反應(yīng) 才會(huì)考慮找別的按鈕操作!
故此稍微改動(dòng)一下,更人性化一些
pages/goods_details/index.vue
//只截取了關(guān)鍵部分代碼
onLoad(options) {
if(options.share==true){ //頁(yè)面初次加載判斷有沒(méi)有攜帶分享參數(shù)
this.share = true,
}
}
data() {
let that = this;
return {
share:false, //默認(rèn)為false不是從分享頁(yè)面打開(kāi),為true則是從分享頁(yè)面打開(kāi)
}
// 后退
returns() {
if(this.share==true){ //從分享打開(kāi)的的
uni.switchTab({ //返回首頁(yè)
url:'/pages/index/index'
});
}
else{ //不是從分享打開(kāi)的
uni.navigateBack({ //返回上一頁(yè)
delta: 1,
})}
},
/* 這個(gè)是優(yōu)品推薦那里的
*去商品詳情頁(yè)
*/
goDetail(item) {
if (item.activity.length == 0) {
if(this.share==true){
uni.redirectTo({
url: "/pages/goods_details/index?id=" + item.id + '&share=' + true,//如果一開(kāi)始就是分享進(jìn)來(lái)的,則添加分享參數(shù)
});
}else{
uni.redirectTo({
url: "/pages/goods_details/index?id=" + item.id,
});
}
return;
}
}
/**
分享到好友*/
// #ifdef MP
onShareAppMessage: function() {
let that = this;
that.$set(that, "actionSheetHidden", !that.actionSheetHidden);
userShare();
return {
title: '¥' + '【' + that.storeInfo.price + '】' + that.storeInfo.store_name || '',
imageUrl: that.storeInfo.image || "",
path: "/pages/goods_details/index?id=" + that.id + "&spid=" + that.uid + "&share=" + true , //攜帶分享參數(shù)
};
},
/**