雖然左上角有個返回 + 首頁的按鈕,但是客戶要返回上一頁的話,大部分人肯定第一操作是按那個 返回 按鈕,按幾下按不動(影響體驗) 按幾下沒反應 才會考慮找別的按鈕操作!
故此稍微改動一下,更人性化一些
pages/goods_details/index.vue
//只截取了關鍵部分代碼
onLoad(options) {
if(options.share==true){ //頁面初次加載判斷有沒有攜帶分享參數
this.share = true,
}
}
data() {
let that = this;
return {
share:false, //默認為false不是從分享頁面打開,為true則是從分享頁面打開
}
// 后退
returns() {
if(this.share==true){ //從分享打開的的
uni.switchTab({ //返回首頁
url:'/pages/index/index'
});
}
else{ //不是從分享打開的
uni.navigateBack({ //返回上一頁
delta: 1,
})}
},
/* 這個是優品推薦那里的
*去商品詳情頁
*/
goDetail(item) {
if (item.activity.length == 0) {
if(this.share==true){
uni.redirectTo({
url: "/pages/goods_details/index?id=" + item.id + '&share=' + true,//如果一開始就是分享進來的,則添加分享參數
});
}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 , //攜帶分享參數
};
},
/**