点餐页增加轮播图点击图片进入具体页面,点击分享正常分享,在对应的页面增加分享弹窗组件

This commit is contained in:
2026-01-28 18:09:47 +08:00
parent 93d3f9196c
commit 37fe706d6a
19 changed files with 1913 additions and 1227 deletions

View File

@@ -2,6 +2,10 @@ import {
autoBindInviteUser,
autoGetInviteCode
} from '@/common/api/market/distribution.js'
import {
shareClaim
} from '@/common/api/market/share.js'
import {
APIshopUserInfo,
APIusershopInfodetail
@@ -10,8 +14,17 @@ import {
productStore
} from '@/stores/user.js';
const accountStore = productStore();
// #ifdef MP-WEIXIN
const accountInfo = wx.getAccountInfoSync();
export const envVersion = accountInfo.miniProgram.envVersion;
// #endif
// #ifdef H5
const accountInfo = {};
export const envVersion = 'release'
// #endif
let type = 3;
if (envVersion === 'trial') {
console.log('当前环境是体验版');
@@ -24,39 +37,78 @@ if (envVersion === 'trial') {
console.log('当前环境是开发版或其他');
}
export const pageTags = {
'/userPackage/index/index': 'pp-list', //套餐推广列表页
'/userPackage/goodsDetail/goodsDetail': 'pp-detail', //套餐推广商品详情页
'/groupBuying/index/index': 'gb-list', //商品拼团列表页
'/groupBuying/goodsDetail/goodsDetail': 'gb-detail', //商品拼团详情页
'/distribution/shop-detail/index': 'dis', //全民股东页面
'/pages/index/index': 'index', //店铺首页
'/pages/product/index': 'eat', //点餐页
'/pages/product/index?pTag=eat-detail': 'eat-detail', //点餐商品详情弹窗页
'/scoreShop/index/index':'point' ,//积分商品
'/scoreShop/detail/index':'point-detail' ,//积分商品详情
}
export function returnPageTags(page) {
for (let key in pageTags) {
if (page.includes(key)) {
if (page.includes('/pages/product/index')) {
if (page.includes('showGoodsId=')||page.includes('goodsId=')) {
return 'eat-detail'
} else {
return 'eat'
}
} else {
return pageTags[key]
}
}
}
return ''
}
/**
* 绑定用户邀请关系(核心函数)
* 功能说明:校验邀请码有效性,有效则调用自动绑定接口完成邀请关系绑定
* @param {Object} args - 绑定邀请关系的入参对象
* @param {number} [args.shopUserId] - 需要绑定邀请人的用户IDinteger <int64>可选
* @param {number} [args.shopId] - 店铺IDinteger <int64>可选
* @param {string} args.inviteCode - 邀请人的邀请码(必填,非空校验通过后才会执行绑定逻辑)
* @param {number} args.fromUserId - 需要绑定邀请人的用户IDinteger <int64>必填
* @param {number} args.shopId - 店铺IDinteger <int64>必填
* @param {string} args.pTag - 来源页面类型
* @returns {void} 无返回值
*/
export async function bindInvite(args) {
// 解构入参对象,获取需要的核心参数
const {
shopUserId,
fromUserId,
shopId,
inviteCode
pTag,
} = args;
// 校验邀请码有效性若邀请码为空、null、undefined则直接返回不执行后续绑定逻辑
if (!inviteCode || inviteCode === null || inviteCode === undefined) {
console.log('bindInvite',args);
if (!fromUserId || !shopId) {
return;
}
const shopUserInfo = uni.cache.get('shopUserInfo')
// 邀请码有效,调用自动绑定邀请人接口,传递绑定所需参数
return await autoBindInviteUser({
id: shopUserInfo.id,
return await shareClaim({
tagType: pTag || '',
shopId,
inviteCode
fromUserId: fromUserId,
toUserId: shopUserInfo.id
});
}
export function wxShare(par) {
const path = par.path
const pTag = returnPageTags(path)
if (pTag) {
par.path += '&pTag=' + pTag
par.query += '&pTag=' + pTag
}
console.log('pTag', pTag);
console.log('wxShare', {
...par,
type
});
return {
...par,
type
@@ -67,15 +119,15 @@ export async function returnCommonQuery() {
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 inviteCode = await autoGetInviteCode({
// shopId: shopId,
// fromUserId: shopUserInfo.id
// })
const queryJson = {
inviteCode: (inviteCode && inviteCode !== true) ? inviteCode : null,
// inviteCode: (inviteCode && inviteCode !== true) ? inviteCode : null,
shopId,
shopUserId: shopUserInfo.id,
fromUserId: shopUserInfo.id,
}
return Promise.resolve(queryJson)
}
@@ -104,10 +156,10 @@ export async function returnQuery(query, showkeys) {
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 inviteCode = await autoGetInviteCode({
// shopId: shopId,
// fromUserId: shopUserInfo.id
// })
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
@@ -117,9 +169,9 @@ export async function returnQuery(query, showkeys) {
let sharePath = `/${currentPath}`;
const queryJson = {
inviteCode: (inviteCode && inviteCode !== true) ? inviteCode : null,
// inviteCode: (inviteCode && inviteCode !== true) ? inviteCode : null,
shopId,
shopUserId: shopUserInfo.id,
fromUserId: shopUserInfo.id,
...query
}
for (const key in currentOptions) {
@@ -132,8 +184,8 @@ export async function returnQuery(query, showkeys) {
}
}
queryJson.shopId = shopId
queryJson.inviteCode = (inviteCode && inviteCode !== true) ? inviteCode : null
queryJson.shopUserId = shopUserInfo.id
// queryJson.inviteCode = (inviteCode && inviteCode !== true) ? inviteCode : null
queryJson.fromUserId = shopUserInfo.id
let result = ''
for (let key in queryJson) {
@@ -178,14 +230,8 @@ export async function handleMixinOnLoad(opt, vm) {
await accountStore.pageOnload()
}
uni.setStorageSync('loadFinsh', true)
// 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
// })
if (options.inviteCode) {
if (options.shopId) {
return await bindInvite(options)
}
}
@@ -220,36 +266,7 @@ export function returnIndexBg() {
// utils/share.js
export const shareMixin = {
// async onLoad(opt) {
// console.log('onLoad');
// const options = {}
// if (opt.q) {
// const q = decodeURIComponent(opt.q);
// const params = parseQueryString(q.split("?")[1]);
// Object.assign(options, params);
// } else {
// Object.assign(options, opt);
// }
// console.log('options', options);
// if (options.shopId) {
// uni.cache.set('shopId', options.shopId)
// }
// 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
// })
// uni.setStorageSync('loadFinsh',true)
// if (options.inviteCode) {
// bindInvite(options)
// }
// },
async onShareAppMessage(res) {
const shopInfo = uni.cache.get('shopInfo')
@@ -261,10 +278,11 @@ export const shareMixin = {
let sharePath = `/${currentPath}`;
const query = await returnQuery()
let query = await returnQuery()
const indexBg = returnIndexBg()
console.log('indexBg', indexBg);
const imageUrl = indexBg || shopInfo.logo
// 全局默认配置(可被页面覆盖)
const defaultShareConfig = {
title: shopInfo.shopName,
@@ -311,9 +329,11 @@ export const shareMixin = {
let sharePath = `/${currentPath}`;
const query = await returnQuery()
let query = await returnQuery()
const indexBg = returnIndexBg()
const imageUrl = indexBg || shopInfo.logo
const defaultTimelineConfig = {
title: shopInfo.shopName,
path: sharePath + '?' + query,