From c7e71a6219294112de87fa9580d6b82521130fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E6=98=9F=E6=98=9F?= <605893810@qq.com> Date: Wed, 22 Jul 2026 23:50:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BE=AE=E4=BF=A1=E5=88=86=E4=BA=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../other_package/components/share-popup.vue | 414 ++++++++++-------- .../other_package/productInfo/productInfo.vue | 76 +++- 2 files changed, 283 insertions(+), 207 deletions(-) diff --git a/pages/other_package/components/share-popup.vue b/pages/other_package/components/share-popup.vue index 7739322..a60e23b 100644 --- a/pages/other_package/components/share-popup.vue +++ b/pages/other_package/components/share-popup.vue @@ -1,219 +1,257 @@ diff --git a/pages/other_package/productInfo/productInfo.vue b/pages/other_package/productInfo/productInfo.vue index 866443d..210fb13 100644 --- a/pages/other_package/productInfo/productInfo.vue +++ b/pages/other_package/productInfo/productInfo.vue @@ -334,8 +334,8 @@ 确认 - @@ -449,6 +449,11 @@ export default { // #endif }, onLoad(options) { + // #ifdef MP-WEIXIN + // 默认禁止小程序右上角的分享菜单 + // uni.hideShareMenu(); + // #endif + const id = options.id; this.activedType = options.activedType; this.activityId = options.activityId; @@ -498,17 +503,19 @@ export default { timer = null; }, onShareAppMessage(res) { + const queryStr = this.buildShareParams(); return { title: this.orderInfo.name || "商品分享", - path: `/pages/other_package/productInfo/productInfo?id=${this.id}`, - imageUrl: this.swiperList.length > 0 ? this.swiperList[0] : "", + path: `/pages/other_package/productInfo/productInfo?${queryStr}`, + imageUrl: (this.swiperList && this.swiperList.length > 0) ? this.swiperList[0] : (this.orderInfo.mainGraph || ""), }; }, onShareTimeline(res) { + const queryStr = this.buildShareParams(); return { title: this.orderInfo.name || "商品分享", - query: `id=${this.id}`, - imageUrl: this.swiperList.length > 0 ? this.swiperList[0] : "", + query: queryStr, + imageUrl: (this.swiperList && this.swiperList.length > 0) ? this.swiperList[0] : (this.orderInfo.mainGraph || ""), }; }, methods: { @@ -579,21 +586,43 @@ export default { url: `/pages/rwa_package/kefu/kefu?scene=product&goodsId=${this.id}`, }); }, - getValue, + buildShareParams() { + const params = []; + if (this.id) params.push(`id=${this.id}`); + if (this.activedType) params.push(`activedType=${this.activedType}`); + if (this.activityId) params.push(`activityId=${this.activityId}`); + if (this.isCoupon) params.push(`isPar=${this.isCoupon}`); + return params.join("&"); + }, // 微信小程序环境分享 onWxShare(index) { - console.log("分享", index); + console.log("微信小程序分享", index); if (index == 0) { - // 微信好友,通过button open-type="share"触发,这里只需要关闭弹窗 + // 微信好友:通过 button open-type="share" 触发,此处只需关闭分享弹窗 this.onClose(); - } else { - // 分享到微信朋友圈 - // 小程序不支持API直接唤起朋友圈分享,提示用户点击右上角 - uni.showModal({ - title: "提示", - content: "请点击右上角...分享到朋友圈", - showCancel: false, + } else if (index == 1) { + // 分享到微信朋友圈:开启右上角朋友圈分享菜单并引导用户点击右上角 [...] + // #ifdef MP-WEIXIN + uni.showShareMenu({ + withShareTicket: true, + menus: ["shareTimeline"], + success: () => { + uni.showModal({ + title: "提示", + content: "已为您开启朋友圈分享功能,请点击右上角 [...] 选择【分享到朋友圈】", + showCancel: false, + }); + }, + fail: () => { + uni.showModal({ + title: "提示", + content: "请点击右上角 [...] 分享到朋友圈", + showCancel: false, + }); + }, }); + // #endif + this.onClose(); } }, onShare(index) { @@ -885,12 +914,21 @@ export default { this.openShow = false; }, jumpLeft() { - if (this.isSplash == "true") { - uni.switchTab({ url: "/pages/home/home" }); + const pages = getCurrentPages(); + // 如果是从分享链接直接打开(页面栈数量 <= 1)或闪屏/引导打开,点击返回直接回到首页 + if (this.isSplash == "true" || pages.length <= 1) { + uni.switchTab({ + url: "/pages/home/home", + }); return; } uni.navigateBack({ - delta: 1, // 返回的页面数,默认为1,返回到上一级 + delta: 1, // 返回上一级页面 + fail: () => { + uni.switchTab({ + url: "/pages/home/home", + }); + }, }); }, jumpOther(type) {