|
|
@ -2,8 +2,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
import { /** useState, */ useEffect, useRef } from 'react';
|
|
|
|
import { /** useState, */ useEffect, useRef } from 'react';
|
|
|
|
|
|
|
|
|
|
|
|
import wx from 'weixin-js-sdk';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// import ImageWithBasePath from '@/components/ImageWithBasePath';
|
|
|
|
// import ImageWithBasePath from '@/components/ImageWithBasePath';
|
|
|
|
|
|
|
|
|
|
|
|
import { APPID } from '@/const';
|
|
|
|
import { APPID } from '@/const';
|
|
|
@ -29,7 +27,8 @@ export default function WXShareBtn() {
|
|
|
|
// };
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
if (!inWX) return;
|
|
|
|
const wx = window.wx;
|
|
|
|
|
|
|
|
if (!inWX || !wx) return;
|
|
|
|
|
|
|
|
|
|
|
|
const { origin, pathname, searchParams } = new URL(window.location.href);
|
|
|
|
const { origin, pathname, searchParams } = new URL(window.location.href);
|
|
|
|
const code = searchParams.get('code');
|
|
|
|
const code = searchParams.get('code');
|
|
|
@ -56,7 +55,12 @@ export default function WXShareBtn() {
|
|
|
|
timestamp, // 必填,生成签名的时间戳
|
|
|
|
timestamp, // 必填,生成签名的时间戳
|
|
|
|
nonceStr, // 必填,生成签名的随机串
|
|
|
|
nonceStr, // 必填,生成签名的随机串
|
|
|
|
signature, // 必填,签名
|
|
|
|
signature, // 必填,签名
|
|
|
|
jsApiList: ['updateAppMessageShareData', 'onMenuShareAppMessage', 'onMenuShareTimeline'], // 必填,需要使用的JS接口列表
|
|
|
|
jsApiList: [
|
|
|
|
|
|
|
|
'updateAppMessageShareData',
|
|
|
|
|
|
|
|
'updateTimelineShareData',
|
|
|
|
|
|
|
|
'onMenuShareAppMessage',
|
|
|
|
|
|
|
|
'onMenuShareTimeline',
|
|
|
|
|
|
|
|
], // 必填,需要使用的JS接口列表
|
|
|
|
});
|
|
|
|
});
|
|
|
|
wx.ready(function () {
|
|
|
|
wx.ready(function () {
|
|
|
|
// setWxPrepared(true);
|
|
|
|
// setWxPrepared(true);
|
|
|
@ -70,11 +74,12 @@ export default function WXShareBtn() {
|
|
|
|
title: '雀乐', // 分享标题
|
|
|
|
title: '雀乐', // 分享标题
|
|
|
|
link: `${origin}${pathname}${queryArr.length > 0 ? `?${queryArr.join('&')}` : ''}`, // 分享链接
|
|
|
|
link: `${origin}${pathname}${queryArr.length > 0 ? `?${queryArr.join('&')}` : ''}`, // 分享链接
|
|
|
|
desc: '一起记录独立音乐', // 分享描述
|
|
|
|
desc: '一起记录独立音乐', // 分享描述
|
|
|
|
imgUrl: 'https://indie.s3.bitiful.net/share.png', // 分享图标
|
|
|
|
imgUrl: 'https://m.indie.cn/img/share.png', // 分享图标
|
|
|
|
success() {},
|
|
|
|
success() {},
|
|
|
|
cancel() {},
|
|
|
|
cancel() {},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
wx.updateAppMessageShareData(shareParam);
|
|
|
|
wx.updateAppMessageShareData(shareParam);
|
|
|
|
|
|
|
|
wx.updateTimelineShareData(shareParam);
|
|
|
|
wx.onMenuShareAppMessage(shareParam);
|
|
|
|
wx.onMenuShareAppMessage(shareParam);
|
|
|
|
wx.onMenuShareTimeline(shareParam);
|
|
|
|
wx.onMenuShareTimeline(shareParam);
|
|
|
|
});
|
|
|
|
});
|
|
|
|