Showing
4 changed files
with
19 additions
and
15 deletions
public/images/weixin_logo.jpg
0 → 100644
65.4 KB
public/images/weixin_logo.png
deleted
100644 → 0
3.08 KB
| ... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
| 2 | * @Author: hookehuyr hookehuyr@gmail.com | 2 | * @Author: hookehuyr hookehuyr@gmail.com |
| 3 | * @Date: 2022-05-26 23:52:36 | 3 | * @Date: 2022-05-26 23:52:36 |
| 4 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 4 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 5 | - * @LastEditTime: 2022-06-13 15:22:35 | 5 | + * @LastEditTime: 2022-06-14 11:46:39 |
| 6 | * @FilePath: /tswj/src/App.vue | 6 | * @FilePath: /tswj/src/App.vue |
| 7 | * @Description: | 7 | * @Description: |
| 8 | --> | 8 | --> |
| ... | @@ -27,6 +27,7 @@ import vConsole from '@/utils/vconsole' | ... | @@ -27,6 +27,7 @@ import vConsole from '@/utils/vconsole' |
| 27 | import wx from 'weixin-js-sdk' | 27 | import wx from 'weixin-js-sdk' |
| 28 | import { wxJsAPI } from '@/api/wx/config' | 28 | import { wxJsAPI } from '@/api/wx/config' |
| 29 | import { apiList } from '@/api/wx/jsApiList.js' | 29 | import { apiList } from '@/api/wx/jsApiList.js' |
| 30 | + | ||
| 30 | // 使用 include + pinia 状态管理动态缓存页面 | 31 | // 使用 include + pinia 状态管理动态缓存页面 |
| 31 | const store = mainStore() | 32 | const store = mainStore() |
| 32 | const keepPages = computed(() => store.getKeepPages) | 33 | const keepPages = computed(() => store.getKeepPages) |
| ... | @@ -46,11 +47,9 @@ Toast.setDefaultOptions({ | ... | @@ -46,11 +47,9 @@ Toast.setDefaultOptions({ |
| 46 | onMounted(async () => { | 47 | onMounted(async () => { |
| 47 | const { data } = await wxJsAPI(); | 48 | const { data } = await wxJsAPI(); |
| 48 | data.jsApiList = apiList; | 49 | data.jsApiList = apiList; |
| 49 | - console.warn(data); | ||
| 50 | wx.config(data); | 50 | wx.config(data); |
| 51 | - wx.ready((res) => { | 51 | + wx.ready(() => { |
| 52 | - wx.showAllNonBaseMenuItem() | 52 | + wx.showAllNonBaseMenuItem(); |
| 53 | - console.warn(res); | ||
| 54 | }); | 53 | }); |
| 55 | wx.error((err) => { | 54 | wx.error((err) => { |
| 56 | console.warn(err); | 55 | console.warn(err); | ... | ... |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2022-06-13 17:42:32 | 2 | * @Date: 2022-06-13 17:42:32 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-06-13 17:42:58 | 4 | + * @LastEditTime: 2022-06-14 11:43:19 |
| 5 | * @FilePath: /tswj/src/composables/useShare.js | 5 | * @FilePath: /tswj/src/composables/useShare.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| 8 | -import wx from 'weixin-js-sdk' | 8 | +import wx from 'weixin-js-sdk'; |
| 9 | -import { useRoute } from 'vue-router' | ||
| 10 | 9 | ||
| 11 | -export const sharePage = () => { | 10 | +const shareData = { |
| 12 | - const $route = useRoute(); | ||
| 13 | - wx.updateAppMessageShareData({ | ||
| 14 | title: '童声无界', // 分享标题 | 11 | title: '童声无界', // 分享标题 |
| 15 | - desc: $route.meta.title, // 分享描述 | 12 | + desc: '共读一本书,传递一份爱。', // 分享描述 |
| 16 | - link: location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致 | 13 | + link: location.origin + location.pathname + location.hash, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致 |
| 17 | - imgUrl: location.origin + location.pathname + 'images/weixin_logo.png', // 分享图标 | 14 | + imgUrl: 'http://voice.onwall.cn/f/voice/images/weixin_logo.jpg', // 分享图标 |
| 18 | success: function () { | 15 | success: function () { |
| 19 | // 用户确认分享后执行的回调函数 | 16 | // 用户确认分享后执行的回调函数 |
| 20 | console.warn('分享成功'); | 17 | console.warn('分享成功'); |
| ... | @@ -23,5 +20,13 @@ export const sharePage = () => { | ... | @@ -23,5 +20,13 @@ export const sharePage = () => { |
| 23 | // 用户取消分享后执行的回调函数 | 20 | // 用户取消分享后执行的回调函数 |
| 24 | console.warn('分享已取消'); | 21 | console.warn('分享已取消'); |
| 25 | } | 22 | } |
| 26 | - }) | 23 | +} |
| 24 | + | ||
| 25 | +export const sharePage = () => { | ||
| 26 | + // 分享好友(微信好友或qq好友) | ||
| 27 | + wx.updateAppMessageShareData(shareData); | ||
| 28 | + // 分享到朋友圈或qq空间 | ||
| 29 | + wx.updateTimelineShareData(shareData); | ||
| 30 | + // 分享到腾讯微博 | ||
| 31 | + wx.onMenuShareWeibo(shareData); | ||
| 27 | } | 32 | } | ... | ... |
-
Please register or login to post a comment