feat: 微信分享
This commit is contained in:
@@ -334,8 +334,8 @@
|
||||
<view class="popup_but" @click="addressOk"> 确认 </view>
|
||||
</view>
|
||||
</up-popup>
|
||||
<SharePopup ref="share" v-if="shareOpen" :show="shareShow" @close="onClose" @share="onShare" :id="id"
|
||||
:text="orderInfo.name ? orderInfo.name : ''" :price="orderInfo.minPrice ? orderInfo.minPrice : ''"
|
||||
<SharePopup ref="share" v-if="shareOpen" :show="shareShow" @close="onClose" @wxShare="onWxShare" @share="onShare"
|
||||
:id="id" :text="orderInfo.name ? orderInfo.name : ''" :price="orderInfo.minPrice ? orderInfo.minPrice : ''"
|
||||
:tu="swiperList.length && swiperList[0]"></SharePopup>
|
||||
<EvaluateDialog ref="evaluateDialog" v-if="evaluateDialogShow" :show="evaluateDialogShow"
|
||||
@close="evaluateDialogShow = false" :evalId="id" :mainGraph="orderInfo.mainGraph" :name="orderInfo.name">
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user