Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
tswj
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2022-06-14 18:19:48 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d49bef80aa67a17f4472207a517e8e32ad2e79ec
d49bef80
1 parent
2dc125e0
✨ feat(微信分享): 自定义分享内容测试
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
24 additions
and
44 deletions
src/api/wx/config.js
src/composables/useShare.js
src/views/client/chooseBook.vue
src/views/client/chooseSchool.vue
src/views/client/donateCertificate.vue
src/views/client/personIndex.vue
src/views/client/videoDetail.vue
src/views/client/videoDetailComment.vue
src/api/wx/config.js
View file @
d49bef8
...
...
@@ -2,7 +2,7 @@
* @Author: hookehuyr hookehuyr@gmail.com
* @Date: 2022-06-09 13:32:44
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-06-1
3 15:51:52
* @LastEditTime: 2022-06-1
4 14:47:01
* @FilePath: /tswj/src/api/wx/config.js
* @Description:
*/
...
...
@@ -18,4 +18,3 @@ const Api = {
* @returns {*} cfg
*/
export
const
wxJsAPI
=
(
params
)
=>
fn
(
fetch
.
get
(
Api
.
WX_JSAPI
,
params
));
// export const wxJsAPI = () => fn(fetch.get(Api.WX_JSAPI, { url: 'http://voice.onwall.cn/f/voice/#' }));
...
...
src/composables/useShare.js
View file @
d49bef8
/*
* @Date: 2022-06-13 17:42:32
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-06-14 1
4:30:13
* @LastEditTime: 2022-06-14 1
7:55:36
* @FilePath: /tswj/src/composables/useShare.js
* @Description: 文件描述
*/
import
wx
from
'weixin-js-sdk'
;
export
const
sharePage
=
(
title
=
'童声无界'
,
desc
=
'共读一本书,传递一份爱。'
)
=>
{
// 分享好友(微信好友或qq好友)
wx
.
updateAppMessageShareData
(
{
export
const
sharePage
=
(
{
title
=
'童声无界'
,
desc
=
'共读一本书,传递一份爱。'
,
imgUrl
=
'http://voice.onwall.cn/f/voice/images/weixin_logo.jpg'
}
)
=>
{
console
.
warn
(
imgUrl
);
const
shareData
=
{
title
,
// 分享标题
desc
,
// 分享描述
link
:
location
.
origin
+
location
.
pathname
+
location
.
hash
,
// 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
imgUrl
:
'http://voice.onwall.cn/f/voice/images/weixin_logo.jpg'
,
// 分享图标
imgUrl
,
// 分享图标
success
:
function
()
{
// 用户确认分享后执行的回调函数
console
.
warn
(
'分享成功'
);
...
...
@@ -22,35 +22,11 @@ export const sharePage = (title = '童声无界', desc = '共读一本书,传
// 用户取消分享后执行的回调函数
console
.
warn
(
'分享已取消'
);
}
});
}
// 分享好友(微信好友或qq好友)
wx
.
updateAppMessageShareData
(
shareData
);
// 分享到朋友圈或qq空间
wx
.
updateTimelineShareData
({
title
,
// 分享标题
desc
,
// 分享描述
link
:
location
.
origin
+
location
.
pathname
+
location
.
hash
,
// 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
imgUrl
:
'http://voice.onwall.cn/f/voice/images/weixin_logo.jpg'
,
// 分享图标
success
:
function
()
{
// 用户确认分享后执行的回调函数
console
.
warn
(
'分享成功'
);
},
cancel
:
function
()
{
// 用户取消分享后执行的回调函数
console
.
warn
(
'分享已取消'
);
}
});
wx
.
updateTimelineShareData
(
shareData
);
// 分享到腾讯微博
wx
.
onMenuShareWeibo
({
title
,
// 分享标题
desc
,
// 分享描述
link
:
location
.
origin
+
location
.
pathname
+
location
.
hash
,
// 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
imgUrl
:
'http://voice.onwall.cn/f/voice/images/weixin_logo.jpg'
,
// 分享图标
success
:
function
()
{
// 用户确认分享后执行的回调函数
console
.
warn
(
'分享成功'
);
},
cancel
:
function
()
{
// 用户取消分享后执行的回调函数
console
.
warn
(
'分享已取消'
);
}
});
wx
.
onMenuShareWeibo
(
shareData
);
}
...
...
src/views/client/chooseBook.vue
View file @
d49bef8
...
...
@@ -110,8 +110,13 @@ watch(
)
/**************************************************/
// TAG:微信分享
sharePage();
setTimeout(() => {
// TAG:微信分享
sharePage();
// 测试自定义分享内容
// const title = kgInfo.value.multi_name ? `${kgInfo.value.multi_name[0]} ${kgInfo.value.multi_name[1]}` : kgInfo.value.name
// sharePage({ title, imgUrl: kgInfo.value.logo });
}, 500)
</script>
<style lang="less" scoped>
...
...
src/views/client/chooseSchool.vue
View file @
d49bef8
...
...
@@ -2,7 +2,7 @@
* @Author: hookehuyr hookehuyr@gmail.com
* @Date: 2022-04-21 11:21:39
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-06-14 1
4:31:39
* @LastEditTime: 2022-06-14 1
7:43:46
* @FilePath: /tswj/src/views/client/chooseSchool.vue
* @Description: 选择学校列表
-->
...
...
@@ -32,7 +32,7 @@ killPages();
onMounted(() => {
const $route = useRoute();
// TAG:微信分享
sharePage();
sharePage(
{}
);
})
</script>
...
...
src/views/client/donateCertificate.vue
View file @
d49bef8
...
...
@@ -23,7 +23,7 @@ import { oneCertAPI } from '@/api/C/donate'
import { sharePage } from '@/composables/useShare.js'
// TAG:微信分享
sharePage();
sharePage(
{}
);
const $route = useRoute();
// 捐款成功后,查询生成捐赠证书
...
...
src/views/client/personIndex.vue
View file @
d49bef8
...
...
@@ -80,7 +80,7 @@ import { prepareDonateAPI } from '@/api/C/donate.js'
import { sharePage } from '@/composables/useShare.js'
// TAG:微信分享
sharePage();
sharePage(
{}
);
const { resetScrollTop } = useScrollTop(); // 页面滚动恢复
resetScrollTop('scrollTopPerson');
...
...
src/views/client/videoDetail.vue
View file @
d49bef8
...
...
@@ -52,7 +52,7 @@ import { prodInfoAPI } from '@/api/C/prod.js'
import { sharePage } from '@/composables/useShare.js'
// TAG:微信分享
sharePage();
sharePage(
{}
);
const $route = useRoute();
const $router = useRouter();
...
...
src/views/client/videoDetailComment.vue
View file @
d49bef8
...
...
@@ -82,7 +82,7 @@ import { useDefaultPerf } from '@/composables';
import { sharePage } from '@/composables/useShare.js'
// TAG:微信分享
sharePage();
sharePage(
{}
);
const $route = useRoute();
const $router = useRouter();
...
...
Please
register
or
login
to post a comment