当前位置:网站首页>Hongmeng OS development III

Hongmeng OS development III

2022-06-24 07:46:00 Calm!

Effect display

Bottom navigation bar

 Insert picture description here

Home page rotation chart

 Insert picture description here

Hot categories

 Insert picture description here

Boutique display

 Insert picture description here

Project structure

 Insert picture description here

Code implementation

Bottom navigation bar

<element name="category" src="./category/category"></element>
<element name="cookbook" src="./cookbook/cookbook"></element>
<element name="map" src="./map/map"></element>
<element name="more" src="./more/more"></element>

<div>
    <tabs class="tabs" index="0" vertical="false" on:change="change">
        <tab-content class="tab-content" scrollable="true">
            <cookbook></cookbook>
            <category></category>
            <map></map>
            <more></more>
        </tab-content>
        <tab-bar class="tab-bar" mode="fixed">
            <div class="tab-item" for="{
     {(index,tab) in tabs}}">
                <image src="{
     {currentSelected === index ? tab.tintIcon : tab.icon}}"></image>
                <text>
                    {
   {tab.title}}
                </text>
            </div>
        </tab-bar>
    </tabs>
</div>

.container {
    
    flex-direction:column;
    justify-content:flex-start;
    align-items:center;
}

.tabs {
    
    width:100%;
}

.tab-content {
    
    width:100%;
}

.tab-bar {
    
    height: 50px;
    border-top-width: 0.5px;
    border-top-color: #ccc;
    .tab-item {
    
        flex: 1;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        image {
    
            width:22px;
            height:22px;
        }
        text {
    
            font-size:12px;
            font_weight:100;
            color:#000;
        }
    }
}


export default {
    
    data: {
    
        tabs:[
            {
    
                id:'tab1',
                title:' Food collection ',
                icon:"/common/images/ Personal center 1.png",
                tintIcon:"/common/images/ Personal center .png",
                component:"cookbook"
            },
            {
    
                id:'tab2',
                title:' classification ',
                icon:"/common/images/ About us 1.png",
                tintIcon:"/common/images/ About us .png",
                component:"category"
            },
            {
    
                id:'tab3',
                title:' Map ',
                icon:"/common/images/ Information Center 1.png",
                tintIcon:"/common/images/ Information Center .png",
                component:"map"
            },
            {
    
                id:'tab4',
                title:' more ',
                icon:"/common/images/ home page 1.png",
                tintIcon:"/common/images/ home page .png",
                component:"more"
            },
        ],

        currentSelected:0
    },
    change:function(e) {
    
        console.log("Tab Index:"+e.index);
        this.currentSelected = e.index
    },
}

Home page blog round

<div class="cb-swiper-container">
    <swiper>
        <image for="{
     {list.slice(0,5)}}" src="{
     {$item.img}}"></image>
    </swiper>
</div>
.cb-swiper-container {
    
    height:240px;
    swiper {
    
        width:100%;
        image {
    
            width:100%;
            height:100%;
            object-fit:fill;
        }
    }
}
export default {
    
    props:{
    
        list:{
    
            type:Array
        }
    },
    onReady(){
    
        console.log(this.list)
    }
}

Hot categories

<div class="cb-hc-container">
    <div class="cb-hc-title">
        <text>
             People classify 
        </text>
    </div>
    <div class="cb-hc-list">
        <div class="cb-hc-item" for="list">
            <image src="{
     {$item.img}}"></image>
            <text>{
   {$item.title}}</text>
        </div>
    </div>
</div>
.cb-hc-container {
    
    flex-direction: column;
}

.cb-hc-title {
    
    border-bottom-width: 0.5px;
    border-bottom-color: #eee;
    height: 44px;
}

text {
    
    font-size: 12px;
    padding-left: 10px;
}

.cb-hc-list {
    
    flex-wrap: wrap;
    margin-top: 20px;
}

.cb-hc-item {
    
    width: 33.33333%;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

image {
    
    object-fit: cover;
    width: 70px;
    height: 70px;
    border-radius: 8px;
}

text {
    
    font-size: 14px;
    line-height: 30px;
}

// @ts-ignore
import list from '../../../../common/data/cookbook-hotcat.json';

export default {
    
    data:{
    
        list:[]
    },

    onReady() {
    
        this.list = list
    }
}

Boutique display

<div class="cb-top-container">
    <div class="cb-top-title">
        <text class="title-text">
             Excellent talent 
        </text>
    </div>
    <div class="cb-top-body">
        <div class="cb-top-item" for="{
     {list.slice(0,10)}}">
            <image src="{
     {$item.img}}"></image>
            <div class="cb-top-item-info">
                <text class="cb-top-item-title">
                    {
   {$item.name}}
                </text>
                <text class="cb-top-item-subtitle">
                    {
   {$item.all_click}} Browse {
   {$item.favorites}} Collection 
                </text>
            </div>
        </div>
    </div>
</div>
.cb-top-container {
    
    flex-direction: column;
    background-color: #f5f5f5;
}

.cb-title-title {
    
    height: 50px;
    padding-top: 5px;
    padding-left: 10px;
    color: #333;
}

text {
    
    font-size: 12px;
}

.title-text {
    
    font-size: 22px;
}

.cb-top-body {
    
    flex-wrap: wrap;
    padding-left: 10px;
    padding-right: 10px;
}

.cb-top-item {
    
    width: 50%;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: white;
    padding-bottom: 15px;
    margin-bottom: 10px;
    height: 160px;
}

image {
    
    width: 100%;
    flex: 1;
    object-fit: contain;
}

.cb-top-item-info {
    
    height: 50px;
    flex-direction: column;
    align-items: center;
}

.cb-top-item-title {
    
    font-size: 16px;
}

.cb-top-item-subtitle {
    
    font-size: 12px;
    color: #666;
    font-weight: 100;
}

export default {
    
    props: {
    
        list: {
    
            type:Array
        }
    }
}
原网站

版权声明
本文为[Calm!]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206240302172923.html