訂單界面實(shí)現(xiàn)

訂單部分代碼

(1)訂單界面整體代碼OrderV.vue

<template>
    <div class="wrapper">
        <div class="title">我的訂單</div>
        <div class="orders">
            <div 
                class="order" 
                v-for="(item,index) in list" 
                :key="index"
            >
                <div class="order_title">
                    {{item.shopName}}
                    <span class="order__status">{{item.isCancled ? '已取消' : '已下單'}}</span>
                </div>
                <div class="order__content">
                    <div class="order__content__imgs">
                        <template 
                            v-for="(innerItem,innerIndex) in item.products"
                            :key="innerIndex"
            rderV.vue            >
                            <img 
                                class="order__content__img" 
                                :src="innerItem.product.img" 
                                v-if="innerIndex<=3"
                            />
                        </template>
                        
                    </div>
                    <div class="order__content__info">
                        <div class="order__content__price">¥{{item.totalPrice}}</div>
                        <div class="order__content__count">共 {{item.totalNumber}} 件</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <DockerV :currentIndex="2" />
</template>

<script>
import { reactive, toRefs } from '@vue/reactivity';
import DockerV from '../../components/DockerV.vue';
import { get } from '../../utils/request';
//處理訂單列表邏輯
const useOrderListEffect = ()=>{
    const data = reactive({list:[]})
    const getOrderList = async ()=>{
        const result = await get('/api/order')
        if(result?.errno === 0 && result?.data?.length){
            const ordertList = result.data
            ordertList.forEach((order) => {
                const products = order.products ||{}
                let totalPrice = 0
                let totalNumber = 0
                products.forEach((productItem)=>{
                    totalNumber += (productItem?.orderSales || 0)
                    totalPrice+=((productItem?.product?.price*productItem?.orderSales) || 0)
                })
                order.totalPrice= totalPrice
                order.totalNumber = totalNumber
            });
            data.list = result.data;
        }
    }
    getOrderList()
    const {list} = toRefs(data)
    return {list}
}
export default {
    name:'OrderList',
    components:{DockerV},
    setup() {
        const {list} = useOrderListEffect()
        return {list}
    },
}
</script>

<style lang="scss" scoped>
@import "../../style/viriables.scss";
.wrapper{
  overflow-y: auto;
  position: absolute;
  left: 0;
  top: 0;
  bottom: .5rem;
  right: 0;
  background: rgb(248,248,248);
}
.title{
    line-height: .44rem;
    background: $bgColor;
    font-size: .16rem;
    color: $content-fontcolor;
    text-align: center;
}
.order{
    margin: .16rem .18rem;
    padding: .16rem;
    background: $bgColor;
    &__title{
        margin-bottom: .16rem;
        line-height: .22rem;
        font-size: .16rem;
        color: $content-fontcolor;
    }
    &__status{
        float: right;
        font-size: .14rem;
        color: $light-fontColor;
    }
    &__content{
        display: flex;
        &__imgs{
            flex: 1;
        }
        &__img{
            width: .4rem;
            height: .4rem;
            margin-right: .12rem;
        }
        &__info{
            width: .7rem;
        }
        &__price{
            margin-bottom: .04rem;
            line-height: .2rem;
            font-size: .14rem;
            color: $highlight-fontColor;
            text-align: right;
        }
        &__count{
            font-size: .12rem;
            color: $content-fontcolor;
            text-align: right;
            line-height: .14rem;
        }
    }
}
</style>

(2)底部DockerV.vue

<template>
 <div class="docker">
    <!--BEM block element Modifier
    block__element--Modifier -->
    <div 
    v-for="(item,index) in dockerList"
    :class="{'docker__item':true,'docker__item--active':index===currentIndex}"
    class="docker__item "
    :key="item.icon"
    >
      <router-link :to="item.to">
        <div class="iconfont" v-html="item.icon" />
        <div class="docker__title">{{item.text}}</div>
      </router-link>
      
    </div>
</div>
</template>
<script>
export default {
    name:'DockerV',
    props:['currentIndex'],
    setup(){
      const dockerList = [
        {icon:'&#xe867;',text:'首頁',to:{name:'Home'}},
        {icon:'&#xe6bc;',text:'購物車',to:{name:'CartList'}},
        {icon:'&#xe7b3',text:'訂單',to:{name:'OrderList'}},
        {icon:'&#xe78b',text:'我的',to:{name:'Home'}}
      ];
      return {dockerList}
    }
}
</script>
<style lang="scss" scoped>
@import '../style/viriables.scss';
@import '../style/mixins.scss';
.docker{
  display: flex;
  box-sizing: border-box;
  position: absolute;
  padding: 0 .18rem;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 0.49rem;
  border-top:.01rem solid $content-bgcolor ;
  
  &__item{
    flex: 1;
    text-align: center;
    a{
      color: $content-fontcolor;
      text-decoration: none;
    }
    .iconfont{
      margin: .07rem 0 .02rem 0;
      font-size: .18rem;
    }
    &--active{
      a{
        color: #1FA4FC;
      }
    }
  }
  &__title{
    font-size: .2rem;
    transform: scale(0.5, 0.5);
    transform-origin: center top;
  }
}
</style>

實(shí)現(xiàn)界面

訂單.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末坎炼,一起剝皮案震驚了整個(gè)濱河市秧饮,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌框沟,老刑警劉巖,帶你破解...
    沈念sama閱讀 219,539評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件枕屉,死亡現(xiàn)場離奇詭異啤咽,居然都是意外死亡序攘,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,594評(píng)論 3 396
  • 文/潘曉璐 我一進(jìn)店門存皂,熙熙樓的掌柜王于貴愁眉苦臉地迎上來晌坤,“玉大人,你說我怎么就攤上這事∨菡蹋” “怎么了埋虹?”我有些...
    開封第一講書人閱讀 165,871評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長娩怎。 經(jīng)常有香客問我搔课,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,963評(píng)論 1 295
  • 正文 為了忘掉前任丹锹,我火速辦了婚禮童番,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘袍啡。我一直安慰自己,他們只是感情好却桶,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,984評(píng)論 6 393
  • 文/花漫 我一把揭開白布境输。 她就那樣靜靜地躺著,像睡著了一般颖系。 火紅的嫁衣襯著肌膚如雪嗅剖。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,763評(píng)論 1 307
  • 那天嘁扼,我揣著相機(jī)與錄音信粮,去河邊找鬼。 笑死趁啸,一個(gè)胖子當(dāng)著我的面吹牛强缘,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播不傅,決...
    沈念sama閱讀 40,468評(píng)論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼旅掂,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了访娶?” 一聲冷哼從身側(cè)響起辞友,我...
    開封第一講書人閱讀 39,357評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎震肮,沒想到半個(gè)月后称龙,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,850評(píng)論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡戳晌,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,002評(píng)論 3 338
  • 正文 我和宋清朗相戀三年鲫尊,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片沦偎。...
    茶點(diǎn)故事閱讀 40,144評(píng)論 1 351
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡疫向,死狀恐怖咳蔚,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情搔驼,我是刑警寧澤谈火,帶...
    沈念sama閱讀 35,823評(píng)論 5 346
  • 正文 年R本政府宣布,位于F島的核電站舌涨,受9級(jí)特大地震影響糯耍,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜囊嘉,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,483評(píng)論 3 331
  • 文/蒙蒙 一温技、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧扭粱,春花似錦舵鳞、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,026評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至博其,卻和暖如春套才,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背贺奠。 一陣腳步聲響...
    開封第一講書人閱讀 33,150評(píng)論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留错忱,地道東北人儡率。 一個(gè)月前我還...
    沈念sama閱讀 48,415評(píng)論 3 373
  • 正文 我出身青樓,卻偏偏與公主長得像以清,于是被迫代替她去往敵國和親儿普。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,092評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容