饿了么顶部栏

这是一个关于Vue.js的组件示例,用于创建一个带有店铺信息的顶部导航栏。组件中包含了店铺的头像、名称、描述、送达时间、优惠信息和公告。数据通过axios获取,并使用Vuex进行状态管理。样式使用了Less进行编写,实现了背景模糊效果和滚动公告功能。
摘要由CSDN通过智能技术生成

 navbar  顶部栏

<template>

  <nav :style="'background-image:url(' + sell.avatar + ' )'">

    <div class="background">

      <img class="img" :src="sell.avatar" alt="" />

      <div class="info">

        <img class="type" src="@/assets/img/brand@2x.png" alt="" />

        <p class="name">{{ sell.name }}</p>

        <p class="time">

          <span>{{ sell.description }} </span> /

          <span>{{ sell.deliveryTime }}分钟送达 </span>

        </p>

        <div class="discount">

          <img src="@/assets/img/decrease_1@2x.png" alt="" />

          <p class="ing">

            {{ sell.supports ? sell.supports[0].description : "" }}

          </p>

        </div>

        <p class="more">5个 ></p>

      </div>

      <div class="notice">

        <span>公告</span>

        <span class="goods">{{ sell.bulletin }} </span>

        <span>></span>

      </div>

    </div>

  </nav>

</template>

<script>

import axios from "axios";

import { getSellData } from "@/axios/index.js";

import bus from "@/eventBus.js";

export default {

  data() {

    return {

      sell: [],

    };

  },

  watch: {

    sell() {

       this.sendSell();

      this.$store.commit("changeSell", this.sell);

    },

  },

  methods: {

    sendSell() {

      bus.$emit("shareSell", this.sell);

    },

  },

  created() {

    getSellData().then(

      (res) => {

        this.sell = res.data.data;

      },

      (err) => {

        console.log(err);

      }

    );

  },

};

</script>

<style lang="less" scoped>

nav {

  height: 180px;

  width: 100%;

  position: fixed;

  background-repeat: no-repeat;

  background: rgba(7, 17, 27, 0.5);

  background-size: cover;

  overflow: hidden;

  color: #fff;

  .background {

    position: absolute;

    top: 0;

    left: 0;

    width: 100%;

    height: 100%;

    z-index: 30;

    background: rgba(7, 17, 27, 0.5);

    backdrop-filter: blur(10px);

  }

  .img {

    width: 80px;

    height: 80px;

    float: left;

    margin-top: 30px;

    margin-left: 24px;

  }

  .info {

    float: left;

    width: 250px;

    position: relative;

    .type {

      width: 36px;

      margin-top: 30px;

      margin-left: 16px;

      float: left;

    }

    .name {

      font-size: 16px;

      font-weight: bold;

      margin-left: 65px;

      margin-top: 30px;

    }

    .time {

      margin-left: 16px;

      font-size: 14px;

      margin-top: 15px;

    }

    .discount {

      margin-left: 16px;

      margin-top: -5px;

      img {

        margin-top: -3px;

        width: 20px;

        float: left;

      }

      .ing {

        margin-top: 20px;

        font-size: 12px;

        margin-left: 30px;

      }

    }

    .more {

      float: right;

      margin-top: -25px;

      margin-right: -30px;

      width: 60px;

      height: 40px;

      background-color: rgba(0, 0, 0, 0.2);

      border-radius: 20px;

      text-align: center;

      line-height: 40px;

      font-size: 12px;

    }

  }

  .notice {

    width: 100%;

    height: 35px;

    position: absolute;

    line-height: 35px;

    bottom: 0;

    background-color: rgba(7, 17, 27, 0.2);

    overflow: hidden;

    span:nth-of-type(1) {

      margin-left: 30px;

      font-size: 12px;

      position: absolute;

      left: -20px;

      background-color: #fff;

      color: black;

      height: 20px;

      display: inline-block;

      font-weight: 700;

      line-height: 20px;

      margin-top: 7px;

    }

    .goods {

      white-space: nowrap;

      width: 80%;

      display: inline-block;

      overflow: hidden;

      text-overflow: ellipsis;

      margin-left: 40px;

      font-size: 12px;

    }

    span:nth-of-type(3) {

      position: absolute;

      right: 5px;

    }

  }

}

</style>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值