feat: 自定义海报代码补充开发

pull/176/head
沈文杰 2026-01-15 10:56:15 +08:00
parent a5aae8480b
commit 531323cc2e
6 changed files with 23 additions and 6 deletions

View File

@ -96,6 +96,8 @@
//
onPullDownRefresh(() => {
sheep.$store('app').init();
// ,
sheep.$store('app').initBusinessConfig();
setTimeout(function () {
uni.stopPullDownRefresh();
}, 800);

View File

@ -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',

View File

@ -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: {

View File

@ -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',

View File

@ -28,6 +28,8 @@ const sheep = {
export async function ShoproInit() {
// 应用初始化
await $store('app').init();
// 获取业务配置 这里不用await考虑的是业务配置不是初始化的必要条件可以异步加载提高加载速度如果是前置的配置注意不能放到这里
sheep.$store('app').initBusinessConfig();
// 平台初始化加载(各平台provider提供不同的加载流程)
$platform.load();

View File

@ -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,