修复分享问题
This commit is contained in:
@@ -144,7 +144,7 @@ export async function returnQuery(query, showkeys) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return Promise.resolve(result)
|
||||
return Promise.resolve(result)
|
||||
}
|
||||
|
||||
function parseQueryString(queryString) {
|
||||
@@ -189,6 +189,34 @@ export async function handleMixinOnLoad(opt, vm) {
|
||||
bindInvite(options)
|
||||
}
|
||||
}
|
||||
|
||||
import {
|
||||
isJsonArrayString
|
||||
} from '@/utils/util.js';
|
||||
|
||||
|
||||
/**
|
||||
* 返回店铺首页图片
|
||||
*/
|
||||
export function returnIndexBg() {
|
||||
try {
|
||||
const orderVIP = uni.cache.get('orderVIP')
|
||||
if (!orderVIP || !orderVIP.shopExtendList) {
|
||||
return ''
|
||||
}
|
||||
if (!isJsonArrayString(orderVIP.shopExtendList[0].value)) {
|
||||
return ''
|
||||
}
|
||||
return JSON.parse(orderVIP.shopExtendList[0].value)[0]
|
||||
} catch (error) {
|
||||
console.error('orderVIP.shopExtendList[0].value 格式不正确')
|
||||
return ''
|
||||
//TODO handle the exception
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// utils/share.js
|
||||
export const shareMixin = {
|
||||
|
||||
@@ -223,41 +251,25 @@ export const shareMixin = {
|
||||
// }
|
||||
// },
|
||||
async onShareAppMessage(res) {
|
||||
// const shopId = uni.cache.get('shopId')
|
||||
// const shopUserInfo = uni.cache.get('shopUserInfo')
|
||||
|
||||
const shopInfo = uni.cache.get('shopInfo')
|
||||
// const inviteCode = await autoGetInviteCode({
|
||||
// shopId: shopId,
|
||||
// shopUserId: shopUserInfo.id
|
||||
// })
|
||||
const pages = getCurrentPages();
|
||||
const currentPage = pages[pages.length - 1];
|
||||
const currentPath = currentPage.route;
|
||||
const currentOptions = currentPage.options;
|
||||
|
||||
let sharePath = `/${currentPath}`;
|
||||
// const queryJson = {
|
||||
// inviteCode: (inviteCode && inviteCode !== true) ? inviteCode : null,
|
||||
// shopId,
|
||||
// shopUserId: shopUserInfo.id,
|
||||
// }
|
||||
// for (const key in currentOptions) {
|
||||
// if (currentOptions.hasOwnProperty(key)) {
|
||||
// queryJson[key] = encodeURIComponent(currentOptions[key])
|
||||
// }
|
||||
// }
|
||||
// queryJson.shopId = shopId
|
||||
// queryJson.inviteCode = (inviteCode && inviteCode !== true) ? inviteCode : null
|
||||
// queryJson.shopUserId = shopUserInfo.id
|
||||
|
||||
const query =await returnQuery()
|
||||
|
||||
|
||||
const query = await returnQuery()
|
||||
const indexBg = returnIndexBg()
|
||||
console.log('indexBg', indexBg);
|
||||
const imageUrl = indexBg || shopInfo.logo
|
||||
// 全局默认配置(可被页面覆盖)
|
||||
const defaultShareConfig = {
|
||||
title: shopInfo.shopName,
|
||||
path: sharePath + '?' + query,
|
||||
imageUrl: shopInfo.logo,
|
||||
imageUrl: imageUrl,
|
||||
query,
|
||||
// desc: '描述',
|
||||
success: (res) => {
|
||||
@@ -270,9 +282,6 @@ export const shareMixin = {
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 页面自定义配置覆盖全局
|
||||
const pageShareConfig = this.$options.shareConfig || {};
|
||||
console.log('mixIn onShareAppMessage', {
|
||||
@@ -286,16 +295,12 @@ export const shareMixin = {
|
||||
},
|
||||
|
||||
|
||||
|
||||
async onShareTimeline() {
|
||||
|
||||
|
||||
// const shopId = uni.cache.get('shopId')
|
||||
// const shopUserInfo = uni.cache.get('shopUserInfo')
|
||||
|
||||
const shopInfo = uni.cache.get('shopInfo')
|
||||
// const inviteCode = await autoGetInviteCode({
|
||||
// shopId: shopId,
|
||||
// shopUserId: shopUserInfo.id
|
||||
// })
|
||||
|
||||
const pages = getCurrentPages();
|
||||
const currentPage = pages[pages.length - 1];
|
||||
@@ -304,26 +309,15 @@ export const shareMixin = {
|
||||
|
||||
|
||||
let sharePath = `/${currentPath}`;
|
||||
// const queryJson = {
|
||||
// inviteCode: (inviteCode && inviteCode !== true) ? inviteCode : null,
|
||||
// shopId,
|
||||
// shopUserId: shopUserInfo.id,
|
||||
// }
|
||||
// for (const key in currentOptions) {
|
||||
// if (currentOptions.hasOwnProperty(key)) {
|
||||
// queryJson[key] = encodeURIComponent(currentOptions[key])
|
||||
// }
|
||||
// }
|
||||
// queryJson.shopId = shopId
|
||||
// queryJson.inviteCode = (inviteCode && inviteCode !== true) ? inviteCode : null
|
||||
// queryJson.shopUserId = shopUserInfo.id
|
||||
|
||||
|
||||
const query = await returnQuery()
|
||||
|
||||
const indexBg = returnIndexBg()
|
||||
const imageUrl = indexBg || shopInfo.logo
|
||||
const defaultTimelineConfig = {
|
||||
title: shopInfo.shopName,
|
||||
path: sharePath + '?' + query,
|
||||
imageUrl: shopInfo.logo,
|
||||
imageUrl: imageUrl,
|
||||
query,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user