hookehuyr

✨ feat: 微信分享功能优化导入

1 +/*
2 + * @Date: 2022-06-13 17:42:32
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2022-06-13 17:42:58
5 + * @FilePath: /tswj/src/composables/useShare.js
6 + * @Description: 文件描述
7 + */
8 +import wx from 'weixin-js-sdk'
9 +import { useRoute } from 'vue-router'
10 +
11 +export const sharePage = () => {
12 + const $route = useRoute();
13 + wx.updateAppMessageShareData({
14 + title: '童声无界', // 分享标题
15 + desc: $route.meta.title, // 分享描述
16 + link: location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
17 + imgUrl: location.origin + location.pathname + 'images/weixin_logo.png', // 分享图标
18 + success: function () {
19 + // 用户确认分享后执行的回调函数
20 + console.warn('分享成功');
21 + },
22 + cancel: function () {
23 + // 用户取消分享后执行的回调函数
24 + console.warn('分享已取消');
25 + }
26 + })
27 +}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
2 * @Author: hookehuyr hookehuyr@gmail.com 2 * @Author: hookehuyr hookehuyr@gmail.com
3 * @Date: 2022-05-21 09:35:14 3 * @Date: 2022-05-21 09:35:14
4 * @LastEditors: hookehuyr hookehuyr@gmail.com 4 * @LastEditors: hookehuyr hookehuyr@gmail.com
5 - * @LastEditTime: 2022-06-13 15:13:42 5 + * @LastEditTime: 2022-06-13 19:23:54
6 * @FilePath: /tswj/src/views/client/bookDetail.vue 6 * @FilePath: /tswj/src/views/client/bookDetail.vue
7 * @Description: 7 * @Description:
8 --> 8 -->
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
2 * @Author: hookehuyr hookehuyr@gmail.com 2 * @Author: hookehuyr hookehuyr@gmail.com
3 * @Date: 2022-04-21 11:21:39 3 * @Date: 2022-04-21 11:21:39
4 * @LastEditors: hookehuyr hookehuyr@gmail.com 4 * @LastEditors: hookehuyr hookehuyr@gmail.com
5 - * @LastEditTime: 2022-06-13 17:24:04 5 + * @LastEditTime: 2022-06-13 17:45:03
6 * @FilePath: /tswj/src/views/client/chooseSchool.vue 6 * @FilePath: /tswj/src/views/client/chooseSchool.vue
7 * @Description: 选择学校列表 7 * @Description: 选择学校列表
8 --> 8 -->
...@@ -22,30 +22,13 @@ import RankingItem from '@/components/RankingItem/index' ...@@ -22,30 +22,13 @@ import RankingItem from '@/components/RankingItem/index'
22 // import { useGo } from '@/hooks/useGo' 22 // import { useGo } from '@/hooks/useGo'
23 import { killPages } from '@/hooks/useKeepAlive' 23 import { killPages } from '@/hooks/useKeepAlive'
24 // import { onMounted } from 'vue'; 24 // import { onMounted } from 'vue';
25 -import wx from 'weixin-js-sdk' 25 +import { sharePage } from '@/composables/useShare.js'
26 -import { useRoute } from 'vue-router'
27 -
28 -// import { wxJsAPI } from '@/api/wx/config'
29 // const go = useGo() 26 // const go = useGo()
30 // 删除所有的 keep-alive 缓存 27 // 删除所有的 keep-alive 缓存
31 killPages(); 28 killPages();
32 29
33 // TAG:微信分享 30 // TAG:微信分享
34 -// const $route = useRoute(); 31 +sharePage();
35 -// wx.updateAppMessageShareData({
36 -// title: '童声无界', // 分享标题
37 -// desc: $route.meta.title, // 分享描述
38 -// link: location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
39 -// imgUrl: location.origin + location.pathname + 'images/weixin_logo.png', // 分享图标
40 -// success: function () {
41 -// // 用户确认分享后执行的回调函数
42 -// console.warn('分享成功');
43 -// },
44 -// cancel: function () {
45 -// // 用户取消分享后执行的回调函数
46 -// console.warn('分享已取消');
47 -// }
48 -// })
49 </script> 32 </script>
50 33
51 <script> 34 <script>
......