|
|
@@ -33,7 +33,7 @@ const defaultOptions: Required<ShareOptions> = {
|
|
|
shareType: 'INVITE',
|
|
|
showLoading: true,
|
|
|
imageSource: 'LOCAL',
|
|
|
- pathParamKey: 'shareRecordId',
|
|
|
+ pathParamKey: 'CCShareId',
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -43,9 +43,9 @@ const defaultOptions: Required<ShareOptions> = {
|
|
|
*/
|
|
|
export function useShare(initOptions: ShareOptions = {}) {
|
|
|
/**
|
|
|
- * 获取分享配置 - 可以直接在onShareAppMessage中调用
|
|
|
- * @returns 完整的分享配置
|
|
|
- */
|
|
|
+ * 获取分享配置 - 可以直接在onShareAppMessage中调用
|
|
|
+ * @returns 完整的分享配置
|
|
|
+ */
|
|
|
const getShareConfig = async (customOption?: ShareOptions, extraParams?): Promise<WechatMiniprogram.Page.ICustomShareContent | {}> => {
|
|
|
// 合并默认配置和自定义配置
|
|
|
const options = { ...defaultOptions, ...initOptions, ...customOption }
|
|
|
@@ -95,7 +95,9 @@ export function useShare(initOptions: ShareOptions = {}) {
|
|
|
|
|
|
if (res !== '' && res !== null && res !== 'null') {
|
|
|
// 拼接分享路径
|
|
|
- const sharePath = `${options.path}${options.path.includes('?') ? '&' : '?'}${options.pathParamKey}=${res}`
|
|
|
+ const scene = `${options.pathParamKey}=${res}`
|
|
|
+ const encodeScene = encodeURIComponent(scene)
|
|
|
+ const sharePath = `${options.path}${options.path.includes('?') ? '&' : '?'}scene=${encodeScene}`
|
|
|
let imageUrl = ''
|
|
|
if (options.imageSource === 'LOCAL') {
|
|
|
imageUrl = options.imageUrl
|
|
|
@@ -135,9 +137,9 @@ export function useShare(initOptions: ShareOptions = {}) {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取朋友圈分享配置 - 可以直接在onShareTimeline中调用
|
|
|
- * @returns 完整的朋友圈分享配置
|
|
|
- */
|
|
|
+ * 获取朋友圈分享配置 - 可以直接在onShareTimeline中调用
|
|
|
+ * @returns 完整的朋友圈分享配置
|
|
|
+ */
|
|
|
const getTimelineShareConfig = async (): Promise<WechatMiniprogram.Page.ICustomTimelineContent | {}> => {
|
|
|
const config = await getShareConfig() as WechatMiniprogram.Page.ICustomShareContent
|
|
|
return {
|