From 7f79fbf76ad7fdbd558a4c7ab10a311f23439dac Mon Sep 17 00:00:00 2001 From: owen Date: Thu, 7 Dec 2023 21:25:24 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E5=95=86=E5=9F=8E=E8=A3=85=E4=BF=AE?= =?UTF-8?q?=EF=BC=9A=E8=A3=85=E4=BF=AE=E6=A8=A1=E6=9D=BF=E9=A2=84=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- pages/index/index.vue | 30 +++++++++++++------------- sheep/api/promotion/diy/template.js | 22 +++++++++++++------ sheep/store/app.js | 33 ++++++++++++++++++----------- 4 files changed, 54 insertions(+), 34 deletions(-) diff --git a/.gitignore b/.gitignore index 7639e4bf..0670590a 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ deploy.sh .env yarn.lock package-lock.json -*.keystore \ No newline at end of file +*.keystore +pnpm-lock.yaml diff --git a/pages/index/index.vue b/pages/index/index.vue index 92546704..e568e081 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -28,26 +28,26 @@ const template = computed(() => sheep.$store('app').template?.home); // 在此处拦截改变一下首页轮播图 此处先写死后期复活 放到启动函数里 - (async function() { - console.log('原代码首页定制化数据',template) - let { - data - } = await index2Api.decorate(); - console.log('首页导航配置化过高无法兼容',JSON.parse(data[1].value)) + // (async function() { + // console.log('原代码首页定制化数据',template) + // let { + // data + // } = await index2Api.decorate(); + // console.log('首页导航配置化过高无法兼容',JSON.parse(data[1].value)) // 改变首页底部数据 但是没有通过数组id获取商品数据接口 // let { // data: datas // } = await index2Api.spids(); // template.value.data[9].data.goodsIds = datas.list.map(item => item.id); - template.value.data[0].data.list = JSON.parse(data[0].value).map(item => { - return { - src: item.picUrl, - url: item.url, - title: item.name, - type: "image" - } - }) - }()) + // template.value.data[0].data.list = JSON.parse(data[0].value).map(item => { + // return { + // src: item.picUrl, + // url: item.url, + // title: item.name, + // type: "image" + // } + // }) + // }()) onLoad((options) => { diff --git a/sheep/api/promotion/diy/template.js b/sheep/api/promotion/diy/template.js index 8c1312c3..054dffae 100644 --- a/sheep/api/promotion/diy/template.js +++ b/sheep/api/promotion/diy/template.js @@ -1,10 +1,20 @@ import request from '@/sheep/request'; -export default { + const DiyTemplateApi = { // TODO 芋艿:测试 - getUsedDiyTemplate: () => - request({ - url: '/app-api/promotion/diy-template/used', - method: 'GET', - }), + getUsedDiyTemplate: () => { + return request({ + url: '/app-api/promotion/diy-template/used', + method: 'GET', + }); + }, + getDiyTemplate: (id) => { + return request({ + url: '/app-api/promotion/diy-template/get', + method: 'GET', + params: { id } + }); + }, }; + +export default DiyTemplateApi; diff --git a/sheep/store/app.js b/sheep/store/app.js index 7ed6ac22..28598e3d 100644 --- a/sheep/store/app.js +++ b/sheep/store/app.js @@ -61,18 +61,18 @@ const app = defineStore({ $router.error('NetworkError'); } + await adaptTemplate(this.template, templateId) const res = await appApi.init(templateId); if (res.error === 0) { this.info = res.data.app; this.platform = res.data.platform; - this.template = res.data.template; - this.has_wechat_trade_managed = res.data.has_wechat_trade_managed; - if (!res.data.template) { - $router.error('TemplateError'); - } - this.chat = res.data.chat; - await adaptTemplate(this.template); + // this.template = res.data.template; + this.has_wechat_trade_managed = res.data.has_wechat_trade_managed; + // if (!res.data.template) { + // $router.error('TemplateError'); + // } + this.chat = res.data.chat; // 加载主题 const sysStore = sys(); @@ -100,17 +100,26 @@ const app = defineStore({ }); // todo: @owen 先做数据适配,后期重构 -const adaptTemplate = async (appTemplate) => { - const diyTemplate = await diyTemplateApi.getUsedDiyTemplate(); - const tabBar = diyTemplate?.data?.property?.tabBar; +const adaptTemplate = async (appTemplate, templateId) => { + const { data: diyTemplate } = templateId + // 查询指定模板,一般是预览时使用 + ? await diyTemplateApi.getDiyTemplate(templateId) + : await diyTemplateApi.getUsedDiyTemplate(); + // 模板不存在 + if (!diyTemplate) { + $router.error('TemplateError'); + return + } + + const tabBar = diyTemplate?.property?.tabBar; if (tabBar) { appTemplate.basic.tabbar = tabBar if (tabBar?.theme) { appTemplate.basic.theme = tabBar?.theme; } } - appTemplate.home = diyTemplate?.data?.home; - appTemplate.user = diyTemplate?.data?.user; + appTemplate.home = diyTemplate?.home; + appTemplate.user = diyTemplate?.user; } export default app; From d9b25ed14b3c81f32ba8f245b0604d509a6e40a0 Mon Sep 17 00:00:00 2001 From: owen Date: Sat, 9 Dec 2023 15:37:24 +0800 Subject: [PATCH 02/16] =?UTF-8?q?=E8=90=A5=E9=94=80=EF=BC=9A=E9=80=82?= =?UTF-8?q?=E9=85=8D=E5=95=86=E5=9F=8E=E8=A3=85=E4=BF=AE=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E3=80=90=E5=BC=B9=E7=AA=97=E5=B9=BF=E5=91=8A=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.vue | 4 +--- .../components/s-block-item/s-block-item.vue | 2 ++ .../s-popup-image/s-popup-image.vue | 22 ++++++++++++++----- sheep/hooks/useModal.js | 4 ++-- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index ac6e7cad..68a00bd8 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -5,8 +5,6 @@ - - @@ -89,4 +87,4 @@ onPageScroll(() => {}); - \ No newline at end of file + diff --git a/sheep/components/s-block-item/s-block-item.vue b/sheep/components/s-block-item/s-block-item.vue index a9c795b8..67a83912 100644 --- a/sheep/components/s-block-item/s-block-item.vue +++ b/sheep/components/s-block-item/s-block-item.vue @@ -10,6 +10,8 @@ + + diff --git a/sheep/components/s-popup-image/s-popup-image.vue b/sheep/components/s-popup-image/s-popup-image.vue index f2528a3b..b10f4777 100644 --- a/sheep/components/s-popup-image/s-popup-image.vue +++ b/sheep/components/s-popup-image/s-popup-image.vue @@ -1,6 +1,6 @@