!24 商城装修

Merge pull request !24 from 疯狂的世界/master-vue3
pull/25/head
芋道源码 2023-12-09 03:40:58 +00:00 committed by Gitee
commit 2192ec3508
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 54 additions and 34 deletions

3
.gitignore vendored
View File

@ -8,4 +8,5 @@ deploy.sh
.env .env
yarn.lock yarn.lock
package-lock.json package-lock.json
*.keystore *.keystore
pnpm-lock.yaml

View File

@ -28,26 +28,26 @@
const template = computed(() => sheep.$store('app').template?.home); const template = computed(() => sheep.$store('app').template?.home);
// //
(async function() { // (async function() {
console.log('原代码首页定制化数据',template) // console.log('',template)
let { // let {
data // data
} = await index2Api.decorate(); // } = await index2Api.decorate();
console.log('首页导航配置化过高无法兼容',JSON.parse(data[1].value)) // console.log('',JSON.parse(data[1].value))
// id // id
// let { // let {
// data: datas // data: datas
// } = await index2Api.spids(); // } = await index2Api.spids();
// template.value.data[9].data.goodsIds = datas.list.map(item => item.id); // 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 => { // template.value.data[0].data.list = JSON.parse(data[0].value).map(item => {
return { // return {
src: item.picUrl, // src: item.picUrl,
url: item.url, // url: item.url,
title: item.name, // title: item.name,
type: "image" // type: "image"
} // }
}) // })
}()) // }())
onLoad((options) => { onLoad((options) => {

View File

@ -1,10 +1,20 @@
import request from '@/sheep/request'; import request from '@/sheep/request';
export default { const DiyTemplateApi = {
// TODO 芋艿:测试 // TODO 芋艿:测试
getUsedDiyTemplate: () => getUsedDiyTemplate: () => {
request({ return request({
url: '/app-api/promotion/diy-template/used', url: '/app-api/promotion/diy-template/used',
method: 'GET', method: 'GET',
}), });
},
getDiyTemplate: (id) => {
return request({
url: '/app-api/promotion/diy-template/get',
method: 'GET',
params: { id }
});
},
}; };
export default DiyTemplateApi;

View File

@ -61,18 +61,18 @@ const app = defineStore({
$router.error('NetworkError'); $router.error('NetworkError');
} }
await adaptTemplate(this.template, templateId)
const res = await appApi.init(templateId); const res = await appApi.init(templateId);
if (res.error === 0) { if (res.error === 0) {
this.info = res.data.app; this.info = res.data.app;
this.platform = res.data.platform; 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(); const sysStore = sys();
@ -100,17 +100,26 @@ const app = defineStore({
}); });
// todo: @owen 先做数据适配,后期重构 // todo: @owen 先做数据适配,后期重构
const adaptTemplate = async (appTemplate) => { const adaptTemplate = async (appTemplate, templateId) => {
const diyTemplate = await diyTemplateApi.getUsedDiyTemplate(); const { data: diyTemplate } = templateId
const tabBar = diyTemplate?.data?.property?.tabBar; // 查询指定模板,一般是预览时使用
? await diyTemplateApi.getDiyTemplate(templateId)
: await diyTemplateApi.getUsedDiyTemplate();
// 模板不存在
if (!diyTemplate) {
$router.error('TemplateError');
return
}
const tabBar = diyTemplate?.property?.tabBar;
if (tabBar) { if (tabBar) {
appTemplate.basic.tabbar = tabBar appTemplate.basic.tabbar = tabBar
if (tabBar?.theme) { if (tabBar?.theme) {
appTemplate.basic.theme = tabBar?.theme; appTemplate.basic.theme = tabBar?.theme;
} }
} }
appTemplate.home = diyTemplate?.data?.home; appTemplate.home = diyTemplate?.home;
appTemplate.user = diyTemplate?.data?.user; appTemplate.user = diyTemplate?.user;
} }
export default app; export default app;