From 6dfd04bb87073bb0404739c814924843e5e648da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=93=E6=B4=81?= <209192278@qq.com> Date: Sun, 5 Feb 2023 17:10:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E4=BA=AB=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.json | 13 +++++++++++-- pages/index/index.vue | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index d6a5f62..be8d37c 100644 --- a/manifest.json +++ b/manifest.json @@ -17,7 +17,9 @@ "delay": 0 }, /* 模块配置 */ - "modules": {}, + "modules": { + "Share": {} + }, /* 应用发布信息 */ "distribute": { /* android打包配置 */ @@ -43,7 +45,14 @@ /* ios打包配置 */ "ios": {}, /* SDK配置 */ - "sdkConfigs": {} + "sdkConfigs": { + "share": { + "weixin": { + "appid": "wx8da30ba464a770ba", + "UniversalLinks": "" + } + } + } } }, /* 快应用特有相关 */ diff --git a/pages/index/index.vue b/pages/index/index.vue index 1dfb68d..780ca4b 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -80,8 +80,41 @@ this.getBanner() this.getImgUrl() this.imgUrl = uni.getStorageSync('img_url') + wx.showShareMenu({ + withShareTicket: true, + //设置下方的Menus菜单,才能够让发送给朋友与分享到朋友圈两个按钮可以点击 + menus: ["shareAppMessage", "shareTimeline"] + }) }, methods: { + //分享到微信好友 + onShareAppMessage(res) { + // 此处的distSource为分享者的部分信息,需要传递给其他人 + let distSource = uni.getStorageSync('distSource'); + if (distSource) { + return { + title: '食瞳', + type: 0, + path: '/pages/index/index?id=' + distSource, + summary: "", + imageUrl: "https://pupil.hchyun.com/uploads/product/zhanwei02.png" + } + } + }, + //分享到朋友圈 + onShareTimeline(res) { + let distSource = uni.getStorageSync('distSource'); + if (distSource) { + return { + title: '食瞳', + type: 0, + query: 'id=' + distSource, + summary: "", + imageUrl: "https://pupil.hchyun.com/uploads/product/zhanwei02.png" + } + } + }, + //获取按上架时间排列的产品列表length getTimeLength(e) { this.reachBottomLength = e