hookehuyr

✨ feat(微信分享功能模块):完善

...@@ -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' 9 +
10 +const shareData = {
11 + title: '童声无界', // 分享标题
12 + desc: '共读一本书,传递一份爱。', // 分享描述
13 + link: location.origin + location.pathname + location.hash, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
14 + imgUrl: 'http://voice.onwall.cn/f/voice/images/weixin_logo.jpg', // 分享图标
15 + success: function () {
16 + // 用户确认分享后执行的回调函数
17 + console.warn('分享成功');
18 + },
19 + cancel: function () {
20 + // 用户取消分享后执行的回调函数
21 + console.warn('分享已取消');
22 + }
23 +}
10 24
11 export const sharePage = () => { 25 export const sharePage = () => {
12 - const $route = useRoute(); 26 + // 分享好友(微信好友或qq好友)
13 - wx.updateAppMessageShareData({ 27 + wx.updateAppMessageShareData(shareData);
14 - title: '童声无界', // 分享标题 28 + // 分享到朋友圈或qq空间
15 - desc: $route.meta.title, // 分享描述 29 + wx.updateTimelineShareData(shareData);
16 - link: location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致 30 + // 分享到腾讯微博
17 - imgUrl: location.origin + location.pathname + 'images/weixin_logo.png', // 分享图标 31 + wx.onMenuShareWeibo(shareData);
18 - success: function () {
19 - // 用户确认分享后执行的回调函数
20 - console.warn('分享成功');
21 - },
22 - cancel: function () {
23 - // 用户取消分享后执行的回调函数
24 - console.warn('分享已取消');
25 - }
26 - })
27 } 32 }
......