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-14 11:46:39 5 + * @LastEditTime: 2022-06-14 14:20:03
6 * @FilePath: /tswj/src/App.vue 6 * @FilePath: /tswj/src/App.vue
7 * @Description: 7 * @Description:
8 --> 8 -->
......
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-14 13:46:20 4 + * @LastEditTime: 2022-06-14 14:30:13
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 9
10 -export const sharePage = () => { 10 +export const sharePage = (title = '童声无界', desc = '共读一本书,传递一份爱。') => {
11 // 分享好友(微信好友或qq好友) 11 // 分享好友(微信好友或qq好友)
12 wx.updateAppMessageShareData({ 12 wx.updateAppMessageShareData({
13 - title: '童声无界', // 分享标题 13 + title, // 分享标题
14 - desc: '共读一本书,传递一份爱。', // 分享描述 14 + desc, // 分享描述
15 link: location.origin + location.pathname + location.hash, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致 15 link: location.origin + location.pathname + location.hash, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
16 imgUrl: 'http://voice.onwall.cn/f/voice/images/weixin_logo.jpg', // 分享图标 16 imgUrl: 'http://voice.onwall.cn/f/voice/images/weixin_logo.jpg', // 分享图标
17 success: function () { 17 success: function () {
...@@ -25,8 +25,8 @@ export const sharePage = () => { ...@@ -25,8 +25,8 @@ export const sharePage = () => {
25 }); 25 });
26 // 分享到朋友圈或qq空间 26 // 分享到朋友圈或qq空间
27 wx.updateTimelineShareData({ 27 wx.updateTimelineShareData({
28 - title: '童声无界', // 分享标题 28 + title, // 分享标题
29 - desc: '共读一本书,传递一份爱。', // 分享描述 29 + desc, // 分享描述
30 link: location.origin + location.pathname + location.hash, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致 30 link: location.origin + location.pathname + location.hash, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
31 imgUrl: 'http://voice.onwall.cn/f/voice/images/weixin_logo.jpg', // 分享图标 31 imgUrl: 'http://voice.onwall.cn/f/voice/images/weixin_logo.jpg', // 分享图标
32 success: function () { 32 success: function () {
...@@ -40,8 +40,8 @@ export const sharePage = () => { ...@@ -40,8 +40,8 @@ export const sharePage = () => {
40 }); 40 });
41 // 分享到腾讯微博 41 // 分享到腾讯微博
42 wx.onMenuShareWeibo({ 42 wx.onMenuShareWeibo({
43 - title: '童声无界', // 分享标题 43 + title, // 分享标题
44 - desc: '共读一本书,传递一份爱。', // 分享描述 44 + desc, // 分享描述
45 link: location.origin + location.pathname + location.hash, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致 45 link: location.origin + location.pathname + location.hash, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
46 imgUrl: 'http://voice.onwall.cn/f/voice/images/weixin_logo.jpg', // 分享图标 46 imgUrl: 'http://voice.onwall.cn/f/voice/images/weixin_logo.jpg', // 分享图标
47 success: function () { 47 success: function () {
......
...@@ -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-14 13:46:36 5 + * @LastEditTime: 2022-06-14 14:31:39
6 * @FilePath: /tswj/src/views/client/chooseSchool.vue 6 * @FilePath: /tswj/src/views/client/chooseSchool.vue
7 * @Description: 选择学校列表 7 * @Description: 选择学校列表
8 --> 8 -->
...@@ -23,11 +23,14 @@ import RankingItem from '@/components/RankingItem/index' ...@@ -23,11 +23,14 @@ import RankingItem from '@/components/RankingItem/index'
23 import { killPages } from '@/hooks/useKeepAlive' 23 import { killPages } from '@/hooks/useKeepAlive'
24 import { onMounted } from 'vue'; 24 import { onMounted } from 'vue';
25 import { sharePage } from '@/composables/useShare.js' 25 import { sharePage } from '@/composables/useShare.js'
26 +import { useRoute } from 'vue-router'
27 +
26 // const go = useGo() 28 // const go = useGo()
27 // 删除所有的 keep-alive 缓存 29 // 删除所有的 keep-alive 缓存
28 killPages(); 30 killPages();
29 31
30 onMounted(() => { 32 onMounted(() => {
33 + const $route = useRoute();
31 // TAG:微信分享 34 // TAG:微信分享
32 sharePage(); 35 sharePage();
33 }) 36 })
......