123456789101112131415161718192021222324252627282930313233343536373839 |
- import { WxConfig } from './wxConfig'
- function funWxShare (ShareTitle = '', ShareText = '', ShareImageUrl = '', link = '') {
- const { desc, imgUrl, title } = {
- title: ShareTitle,
- imgUrl: ShareImageUrl,
- desc: ShareText
- }
- // 低版本微信兼容
- const appMessage = {
- title: title, // 分享标题
- desc: desc, // 分享描述
- link: link, // 分享链接
- imgUrl: imgUrl, // 分享图标
- success: function () {
- },
- cancel: function () {
- }
- }
- const timeline = {
- title: desc, // 分享标题
- link: link, // 分享链接
- imgUrl: imgUrl, // 分享图标
- success: function () {
- },
- cancel: function () {
- }
- }
- WxConfig().then(result => {
- result.ready(() => {
- // 分享给朋友
- result.updateAppMessageShareData ? result.updateAppMessageShareData(appMessage) : result.onMenuShareAppMessage(appMessage)
- // 分享到朋友圈
- result.updateTimelineShareData ? result.updateTimelineShareData(timeline) : result.onMenuShareTimeline(timeline)
- })
- })
- }
- export default funWxShare
|