营销:装修模板,底部导航适配APP

pull/10/head
owen 2023-11-03 06:47:45 +08:00
parent 06943e821e
commit 8bd5f9f3cc
4 changed files with 40 additions and 16 deletions

View File

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

View File

@ -1,29 +1,29 @@
<template> <template>
<view class="u-page__item" v-if="tabbar?.list.length > 0"> <view class="u-page__item" v-if="tabbar?.items.length > 0">
<su-tabbar <su-tabbar
:value="path" :value="path"
:fixed="true" :fixed="true"
:placeholder="true" :placeholder="true"
:safeAreaInsetBottom="true" :safeAreaInsetBottom="true"
:inactiveColor="tabbar.inactiveColor" :inactiveColor="tabbar.style.color"
:activeColor="tabbar.activeColor" :activeColor="tabbar.style.activeColor"
:midTabBar="tabbar.mode === 2" :midTabBar="tabbar.mode === 2"
:customStyle="tabbarStyle" :customStyle="tabbarStyle"
> >
<su-tabbar-item <su-tabbar-item
v-for="(item, index) in tabbar.list" v-for="(item, index) in tabbar.items"
:key="item.text" :key="item.text"
:text="item.text" :text="item.text"
:name="item.url" :name="item.url"
:isCenter="getTabbarCenter(index)" :isCenter="getTabbarCenter(index)"
:centerImage="sheep.$url.cdn(item.inactiveIcon)" :centerImage="sheep.$url.cdn(item.iconUrl)"
@tap="sheep.$router.go(item.url)" @tap="sheep.$router.go(item.url)"
> >
<template v-slot:active-icon> <template v-slot:active-icon>
<image class="u-page__item__slot-icon" :src="sheep.$url.cdn(item.activeIcon)"></image> <image class="u-page__item__slot-icon" :src="sheep.$url.cdn(item.activeIconUrl)"></image>
</template> </template>
<template v-slot:inactive-icon> <template v-slot:inactive-icon>
<image class="u-page__item__slot-icon" :src="sheep.$url.cdn(item.inactiveIcon)"></image> <image class="u-page__item__slot-icon" :src="sheep.$url.cdn(item.iconUrl)"></image>
</template> </template>
</su-tabbar-item> </su-tabbar-item>
</su-tabbar> </su-tabbar>
@ -39,20 +39,22 @@
}); });
const tabbarStyle = computed(() => { const tabbarStyle = computed(() => {
const backgroundStyle = tabbar.value.background; const backgroundStyle = tabbar.value.style;
if (backgroundStyle.type == 'color') return { background: backgroundStyle.bgColor }; if (backgroundStyle.bgType === 'color') {
if (backgroundStyle.type == 'image') return { background: backgroundStyle.bgColor };
}
if (backgroundStyle.bgType === 'img')
return { return {
background: `url(${sheep.$url.cdn( background: `url(${sheep.$url.cdn(
backgroundStyle.bgImage, backgroundStyle.bgImg,
)}) no-repeat top center / 100% auto`, )}) no-repeat top center / 100% auto`,
}; };
}); });
const getTabbarCenter = (index) => { const getTabbarCenter = (index) => {
if (unref(tabbar).mode !== 2) return false; if (unref(tabbar).mode !== 2) return false;
return unref(tabbar).list % 2 > 0 return unref(tabbar).items % 2 > 0
? Math.ceil(unref(tabbar).list.length / 2) === index + 1 ? Math.ceil(unref(tabbar).items.length / 2) === index + 1
: false; : false;
}; };

View File

@ -1,4 +1,5 @@
import appApi from '@/sheep/api/app'; import appApi from '@/sheep/api/app';
import diyTemplateApi from '@/sheep/api/promotion/diy/template';
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import $platform from '@/sheep/platform'; import $platform from '@/sheep/platform';
import $router from '@/sheep/router'; import $router from '@/sheep/router';
@ -71,6 +72,17 @@ const app = defineStore({
} }
this.chat = res.data.chat; this.chat = res.data.chat;
const diyTemplate = await diyTemplateApi.getUsedDiyTemplate();
if (diyTemplate?.data?.property) {
const templateProperty = JSON.parse(diyTemplate?.data?.property)
this.template.basic.tabbar = templateProperty.tabBar
if (templateProperty?.tabBar.theme) {
this.template.basic.theme = templateProperty?.tabBar.theme;
}
} else {
$router.error('TemplateError');
}
// 加载主题 // 加载主题
const sysStore = sys(); const sysStore = sys();
sysStore.setTheme(); sysStore.setTheme();

View File

@ -8,7 +8,7 @@
<image <image
v-if="icon" v-if="icon"
:name="icon" :name="icon"
:color="isActive ? parentData.activeColor : parentData.inactiveColor" :color="isActive ? parentData.activeColor : parentData.color"
:size="20" :size="20"
></image> ></image>
<block v-else> <block v-else>
@ -29,7 +29,7 @@
<text <text
class="u-tabbar-item__text" class="u-tabbar-item__text"
:style="{ :style="{
color: isActive ? parentData.activeColor : parentData.inactiveColor, color: isActive ? parentData.activeColor : parentData.color,
}" }"
> >
{{ text }} {{ text }}
@ -120,7 +120,7 @@
parentData: { parentData: {
value: null, value: null,
activeColor: '', activeColor: '',
inactiveColor: '', color: '',
}, },
parent: {}, parent: {},
}; };