diff --git a/App.vue b/App.vue index fdda864..edd67f6 100644 --- a/App.vue +++ b/App.vue @@ -1,3 +1,4 @@ + + + diff --git a/components/ymf-components/ymf-share-popup.vue b/components/ymf-components/ymf-share-popup.vue new file mode 100644 index 0000000..b33d2d1 --- /dev/null +++ b/components/ymf-components/ymf-share-popup.vue @@ -0,0 +1,220 @@ + + + + + \ No newline at end of file diff --git a/components/ymf-components/ymf-share.vue b/components/ymf-components/ymf-share.vue index 62b7bf2..472b966 100644 --- a/components/ymf-components/ymf-share.vue +++ b/components/ymf-components/ymf-share.vue @@ -3,7 +3,7 @@ - + diff --git a/distribution/shop-detail/index.vue b/distribution/shop-detail/index.vue index 3da5184..e1cb053 100644 --- a/distribution/shop-detail/index.vue +++ b/distribution/shop-detail/index.vue @@ -26,12 +26,15 @@ {{ state.distributionUser.level }}级 {{ state.distributionUser.levelName }} - + - + 距离下一级还差: {{ juNextLvMoney }} - {{ config.upgradeType == 'cost' ? '元' : '人' }} + {{ config.upgradeType == 'cost' ? '元' : '人' }} + + + + .btn { + padding: 22rpx; + border-radius: 200rpx; + font-size: 32rpx; + color: #fff; + width: 556rpx; + text-align: center; + background-color: #e8ad7b; + border: 1px solid transparent; + + &.gray { + background: #fff; + color: #e8ad7b; + border-color: #e8ad7b; + } + } + } + + .waring { + background-color: rgba(255, 204, 0, 0.09); + padding: 32rpx 24rpx; + color: #ff8d28; + } + + .popup-content { + font-size: 28rpx; + min-height: 300px; + + .popup-content-top { + padding: 32rpx 28rpx; + border-bottom: 1px solid #ededed; + } + + .goods-info { + padding: 32rpx 28rpx; + border-bottom: 1px solid #ededed; + + .cover { + width: 184rpx; + height: 184rpx; + border-radius: 16rpx; + background: #d9d9d9; + + &.bg-fff { + background-color: #fff; + } + } + + .price { + font-size: 32rpx; + font-weight: 700; + color: #ed5a2e; + line-height: 46rpx; + } + + .old-price { + font-size: 32rpx; + color: #999; + text-decoration-line: line-through; + line-height: 48rpx; + } + + .limitBuyNum { + color: #666; + line-height: 42rpx; + } + } + + .bottom { + padding: 20rpx; + border-bottom: 1px solid #ededed; + + .price { + color: #ed5a2e; + font-size: 32rpx; + font-weight: 700; + } + } + + .btn { + display: flex; + padding: 22rpx 214rpx; + align-items: flex-start; + gap: 20rpx; + border-radius: 66rpx; + background: #e8ad7b; + font-size: 32rpx; + color: #fff; + font-size: 700; + } + } + + .w-full { + width: 100%; + } + + .groups { + padding: 28rpx 22rpx; + background-color: #fff; + + .item { + padding: 28rpx 0; + border-bottom: 2rpx solid #ededed; + + &:last-child { + border-bottom: none; + } + + .main-color { + color: #ed5a2e; + } + + .btn { + padding: 8rpx 26rpx; + border-radius: 36rpx; + background: #e8ad7b; + font-weight: 700; + color: #fff; + } + } + } + + .share-box { + top: 0; + position: absolute; + right: 0; + padding: 4rpx 30rpx; + border-radius: 0 0 0 24rpx; + color: #ed5a2e; + font-weight: 700; + background: #fff; + overflow: hidden; + + .share { + position: absolute; + left: 0; + right: 0; + top: 0; + bottom: 0; + opacity: 0; + } + } + + .goods-group { + padding: 32rpx 46rpx; + background-color: #fff; + + .name { + font-weight: 700; + font-size: 32rpx; + } + + .rotate { + transform: rotate(-90deg); + } + } + + .desc { + padding: 32rpx 46rpx; + background-color: #fff; + margin-top: 32rpx; + + .name { + font-weight: 700; + font-size: 32rpx; + } + + .table { + border: 2rpx solid #ededed; + border-radius: 8rpx; + margin: 0 52rpx; + + .header { + background: #f8f8f88f; + } + + .row { + border-top: 2rpx solid #ededed; + + &:first-child { + border-top: none; + } + } + } + + .rotate { + transform: rotate(-90deg); + } + } + + .guodu { + transition: all 0.3s; + } + \ No newline at end of file diff --git a/userPackage/index/index.vue b/userPackage/index/index.vue index 4b0c684..264ea2f 100644 --- a/userPackage/index/index.vue +++ b/userPackage/index/index.vue @@ -167,6 +167,7 @@ + @@ -513,9 +514,9 @@ }) }) - onLoad(() => { + onLoad((opt) => { APIusershopInfodetail({ - shopId: uni.cache.get('shopId') + shopId: uni.cache.get('shopId')||opt.shopId }).then(res => { console.log(res); shopInfo.value = res.shopInfo diff --git a/userPackage/order/detail.vue b/userPackage/order/detail.vue index c5023bc..7ac6ade 100644 --- a/userPackage/order/detail.vue +++ b/userPackage/order/detail.vue @@ -538,7 +538,7 @@ onShareAppMessage(async () => { query }; console.log('onShareAppMessage===', options); - return options; + return wxShare(options); }); onLoad(async (opt) => { diff --git a/utils/share.js b/utils/share.js index 8666384..335c2bb 100644 --- a/utils/share.js +++ b/utils/share.js @@ -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] - 需要绑定邀请人的用户ID(integer ,可选) - * @param {number} [args.shopId] - 店铺ID(integer ,可选) - * @param {string} args.inviteCode - 邀请人的邀请码(必填,非空校验通过后才会执行绑定逻辑) + * @param {number} args.fromUserId - 需要绑定邀请人的用户ID(integer ,必填) + * @param {number} args.shopId - 店铺ID(integer ,必填) + * @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,