vue3实现饿了么商家筛选排序(二)

编程入门 行业动态 更新时间:2024-10-26 16:33:04

vue3实现<a href=https://www.elefans.com/category/jswz/34/1758949.html style=饿了么商家筛选排序(二)"/>

vue3实现饿了么商家筛选排序(二)

前言

  1. Vue3实现饿了么短信验证和高德定位(一)
  2. Vue3实现饿了么商家筛选排序(二)
  3. Vue3实现饿了么商品列表详情购物车评论(三)

效果展示

①完善了首页的内容,增加了广告轮播图、推荐美食栏和商家列表展示

②对商家不同的排序方式、筛选商家

③搜索关键词

具体实现

  • 广告轮播图与美食推荐
    这里引入了饿了么提供的mint-ui
import { Swipe, SwipeItem} from 'mint-ui';

mint-ui提供了多种样式的轮播图,这里用了每4s自动滑动和手动滑动的轮播图

<!-- 广告轮播图 --><mt-swipe :auto="4000" class="swiper"><mt-swipe-item v-for="(img,index) in swipeImgs" :key="index"></mt-swipe-item><mt-swipe-item>...</mt-swipe-item>...	</mt-swipe>
<!-- 美食推荐 --><mt-swipe :auto="0" class="entries"><mt-swipe-item v-for="(entry,i) in entries" :key="i" class="entry_wrap"></mt-swipe-item><mt-swipe-item>...</mt-swipe-item>...</mt-swipe>
  • 筛选排序条件
    这里用了switch的方法,以index作为key值。
switch(index){case 0:this.isSort = true;this.$emit("searchFixed",true); break;case 1:this.$emit("update",{condition:this.filterData.navTab[1].condition});            this.hideView();break;case 2:this.$emit("update",{condition:this.filterData.navTab[2].condition});            this.hideView();              break;case 3:this.isScreen = true;this.isSort = false;this.$emit("searchFixed",true); break;default:this.hideView();break;
}

每一种排序或筛选的方式包含有一个condition,利用update将condition传给this.data,再传参给拉取商家信息的axios请求,实现点击每个条件均能按condition重新加载一次商家信息

update(condition) {// console.log(condition);this.data = condition;this.loadData(); }
//拉取商家信息
this.$axios.post(`/api/profile/restaurants/${this.page}/${this.size}`,this.data).then(res =>{//})
  • 搜索关键字
    用keyword绑定输入的关键字,用keyword()监听并调用keyWordChange方法
watch:{keyword(){this.keyWordChange();}},

将keyword关键字传入axios请求

keyWordChange(){          this.$axios(`/api/profile/typeahead/${this.keyword}`).then(res =>{this.result = res.data;console.log(this.result);}).catch(err =>{this.result = null;})},

更多推荐

vue3实现饿了么商家筛选排序(二)

本文发布于:2024-03-08 21:08:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1722366.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:饿了   商家

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!