flat:语音功能优化
This commit is contained in:
@@ -1,81 +0,0 @@
|
||||
import config from "@/config.js"
|
||||
import {
|
||||
$api
|
||||
} from '../common/globalFunction';
|
||||
|
||||
export function setupWechatShare({
|
||||
title,
|
||||
desc,
|
||||
link,
|
||||
imgUrl
|
||||
}) {
|
||||
// 通过后端接口获取签名(必须)
|
||||
$api.createRequest('/app/job/getWechatUrl', {
|
||||
imgUrl: location.href.split('#')[0]
|
||||
}, 'POST').then((resData) => {
|
||||
const {
|
||||
appId,
|
||||
timestamp,
|
||||
nonceStr,
|
||||
signature
|
||||
} = resData.data
|
||||
|
||||
wx.config({
|
||||
debug: false,
|
||||
appId,
|
||||
timestamp,
|
||||
nonceStr,
|
||||
signature,
|
||||
jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData']
|
||||
})
|
||||
wx.ready(() => {
|
||||
// 分享给好友
|
||||
wx.updateAppMessageShareData({
|
||||
title,
|
||||
desc,
|
||||
link,
|
||||
imgUrl,
|
||||
success: () => {
|
||||
$api.msg('分享配置成功')
|
||||
}
|
||||
})
|
||||
// 分享到朋友圈
|
||||
wx.updateTimelineShareData({
|
||||
title,
|
||||
link,
|
||||
imgUrl,
|
||||
success: () => {
|
||||
$api.msg('朋友圈分享配置成功')
|
||||
}
|
||||
})
|
||||
}).catch((err) => {
|
||||
$api.msg('获取微信签名失败')
|
||||
console.error('获取微信签名失败:', err);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
export function updateWechatShare({
|
||||
title,
|
||||
desc,
|
||||
link,
|
||||
imgUrl
|
||||
}) {
|
||||
if (!window.wx) return;
|
||||
wx.updateAppMessageShareData({
|
||||
title,
|
||||
desc,
|
||||
link,
|
||||
imgUrl,
|
||||
success: () => console.log('分享配置成功'),
|
||||
fail: (err) => console.warn('分享配置失败', err)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// tools
|
||||
export function generateShareLink(jobId) {
|
||||
const base = location.origin + '/app/static/share.html';
|
||||
const query = jobId ? `?jobId=${jobId}&_t=${Date.now()}` : `?_t=${Date.now()}`;
|
||||
return `${base}${query}`;
|
||||
}
|
Reference in New Issue
Block a user