From 531323cc2e587a90bb904734ec0fe8709df7c446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E6=96=87=E6=9D=B0?= Date: Thu, 15 Jan 2026 10:56:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=87=AA=E5=AE=9A=E4=B9=89=E6=B5=B7?= =?UTF-8?q?=E6=8A=A5=E4=BB=A3=E7=A0=81=E8=A1=A5=E5=85=85=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.vue | 2 ++ .../s-share-modal/canvas-poster/poster/goods.js | 3 ++- .../s-share-modal/canvas-poster/poster/groupon.js | 4 ++-- .../s-share-modal/canvas-poster/poster/user.js | 3 ++- sheep/index.js | 2 ++ sheep/store/app.js | 15 +++++++++++++-- 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index 63a324ca..b494dd18 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -96,6 +96,8 @@ // 下拉刷新 onPullDownRefresh(() => { sheep.$store('app').init(); + // 获取业务配置入口,目前只有海报设置,可以自定义后续扩展 + sheep.$store('app').initBusinessConfig(); setTimeout(function () { uni.stopPullDownRefresh(); }, 800); diff --git a/sheep/components/s-share-modal/canvas-poster/poster/goods.js b/sheep/components/s-share-modal/canvas-poster/poster/goods.js index 883e4be7..0437f345 100644 --- a/sheep/components/s-share-modal/canvas-poster/poster/goods.js +++ b/sheep/components/s-share-modal/canvas-poster/poster/goods.js @@ -5,10 +5,11 @@ const goods = async (poster) => { const width = poster.width; const userInfo = sheep.$store('user').userInfo; const wxa_qrcode = await getWxaQrcode(poster.shareInfo.path, poster.shareInfo.query); + const goods_bg_config = sheep.$store('app').brokeragePosterUrls[1] || ''; return [ { type: 'image', - src: formatImageUrlProtocol(sheep.$url.cdn(sheep.$store('app').platform.share.posterInfo.goods_bg)), + src: goods_bg_config || formatImageUrlProtocol(sheep.$url.cdn(sheep.$store('app').platform.share.posterInfo.goods_bg)), css: { width, position: 'fixed', diff --git a/sheep/components/s-share-modal/canvas-poster/poster/groupon.js b/sheep/components/s-share-modal/canvas-poster/poster/groupon.js index c182d3fe..7cb67bf4 100644 --- a/sheep/components/s-share-modal/canvas-poster/poster/groupon.js +++ b/sheep/components/s-share-modal/canvas-poster/poster/groupon.js @@ -2,14 +2,14 @@ import sheep from '@/sheep'; import { formatImageUrlProtocol, getWxaQrcode } from './index'; const groupon = async (poster) => { - debugger; const width = poster.width; const userInfo = sheep.$store('user').userInfo; const wxa_qrcode = await getWxaQrcode(poster.shareInfo.path, poster.shareInfo.query); + const groupon_bg_config = sheep.$store('app').brokeragePosterUrls[2] || ''; return [ { type: 'image', - src: formatImageUrlProtocol( + src: groupon_bg_config || formatImageUrlProtocol( sheep.$url.cdn(sheep.$store('app').platform.share.posterInfo.groupon_bg), ), css: { diff --git a/sheep/components/s-share-modal/canvas-poster/poster/user.js b/sheep/components/s-share-modal/canvas-poster/poster/user.js index aa73922e..bb7321b5 100644 --- a/sheep/components/s-share-modal/canvas-poster/poster/user.js +++ b/sheep/components/s-share-modal/canvas-poster/poster/user.js @@ -6,10 +6,11 @@ const user = async (poster) => { const userInfo = sheep.$store('user').userInfo; const wxa_qrcode = await getWxaQrcode(poster.shareInfo.path, poster.shareInfo.query); const widthNickName = measureTextWidth(userInfo.nickname, 14); // 使用新方法 + const user_bg_config = sheep.$store('app').brokeragePosterUrls[0] || ''; return [ { type: 'image', - src: formatImageUrlProtocol(sheep.$url.cdn(sheep.$store('app').platform.share.posterInfo.user_bg)), + src: user_bg_config || formatImageUrlProtocol(sheep.$url.cdn(sheep.$store('app').platform.share.posterInfo.user_bg)), css: { width, position: 'fixed', diff --git a/sheep/index.js b/sheep/index.js index c135334f..00b9c98b 100644 --- a/sheep/index.js +++ b/sheep/index.js @@ -28,6 +28,8 @@ const sheep = { export async function ShoproInit() { // 应用初始化 await $store('app').init(); + // 获取业务配置 这里不用await,考虑的是业务配置不是初始化的必要条件,可以异步加载,提高加载速度,如果是前置的配置注意不能放到这里 + sheep.$store('app').initBusinessConfig(); // 平台初始化加载(各平台provider提供不同的加载流程) $platform.load(); diff --git a/sheep/store/app.js b/sheep/store/app.js index efd06876..4fde712f 100644 --- a/sheep/store/app.js +++ b/sheep/store/app.js @@ -7,6 +7,7 @@ import $router from '@/sheep/router'; import user from './user'; import sys from './sys'; import { baseUrl, h5Url } from '@/sheep/config'; +import TradeConfigApi from '@/sheep/api/trade/config'; const app = defineStore({ id: 'app', @@ -32,6 +33,7 @@ const app = defineStore({ }, bind_mobile: 0, // 登陆后绑定手机号提醒 (弱提醒,可手动关闭) }, + brokeragePosterUrls: [], // 分销海报背景图列表,从第一张到第三张分别是个人、商品、拼团海报背景图 template: { // 店铺装修模板 basic: {}, // 基本信息 @@ -114,13 +116,22 @@ const app = defineStore({ $router.error('InitError', res.msg || '加载失败'); } }, - // 设置 paramsForTabbar + async initBusinessConfig() { + let { code, data } = await TradeConfigApi.getTradeConfig(); + if (code !== 0) { + return; + } + if (data) { + this.brokeragePosterUrls = data.brokeragePosterUrls || []; + } + }, + // 设置paramsForTabbar setParamsForTabbar(params = {}) { this.paramsForTabbar = params; }, clearParamsForTabbar() { this.paramsForTabbar = {}; - }, + } }, persist: { enabled: true,