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