hengmei-two/pages/tabbar/shop/shop.vue

256 lines
9.0 KiB
Vue
Raw Normal View History

2021-08-19 06:40:59 +00:00
<template>
<view>
<!-- 状态栏 -->
2021-10-11 10:21:06 +00:00
<status-nav :titleVal="'商城'" :statusBack="false" :statusTitle="true"></status-nav>
<!-- 搜索输入框 -->
2021-10-22 03:07:32 +00:00
<view class="search-input-box bacf poszy shop-nav-box" :style="{top: statusHNH+'px'}">
2021-10-11 10:21:06 +00:00
<view class="disac pad-zy30 mar-s20">
<!-- 输入框 -->
2021-10-22 03:07:32 +00:00
<input class="width100 fon34 radius10" type="text" @confirm="searchEv" v-model="searchVal" placeholder="请输入商品名称"/>
2021-10-11 10:21:06 +00:00
<!-- 搜索 -->
2021-10-22 03:07:32 +00:00
<view class="flexs mar-z30 radius10 pad-zy40 fon34 colf" @tap="searchEv" :style="{background:publicColor}">搜索</view>
2021-10-11 10:21:06 +00:00
</view>
<!-- 分类标题 -->
<view style="background: #FFFFFF;font-size: 24rpx;" class="disjbac pad-zy20 pad-s20">
<view v-for="(item,index) in shopCate" @tap="chooseShopCate(index)" :class="activeIndex==index?'activecate':'shopMo'" :style="{background:activeIndex==index?publicColor:'#F2F2F2'}" :key="index"><span>{{item}}</span></view>
</view>
<!-- 筛选结果 -->
<view v-if="isClick" class="pad-zy50 disac fw pad-x20">
<view class="col3 fon28 mar-s30">筛选</view>
2021-10-22 03:07:32 +00:00
<view v-for="(item,indexx) in shaiList" :key="indexx">{{item}} <view class="mar-z10" @tap="deleteSX(indexx)">×</view></view>
2021-10-11 10:21:06 +00:00
</view>
<view v-if="isXiao">
<view class="pad-zy30">
<view class="mar-s50 mar-x20 fon28 bold">{{cateTitle}}</view>
<view class="disac fw">
2021-10-22 03:07:32 +00:00
<view @tap="chooseBing(indexb)" v-for="(itemb,indexb) in bingzList" class="mar-y30 fon26 mar-s30" :key="indexb" :class="itemb.isActive?'activebcate':'shopBMo'" :style="{background:itemb.isActive?publicColor:'#F2F2F2'}">{{itemb.title}}</view>
2021-10-11 10:21:06 +00:00
</view>
<view v-if="activeIndex==1">
<view class="fon28 bold mar-sx40">医生选择</view>
2021-10-22 03:07:32 +00:00
<input type="text" class="mar-x40" value="" placeholder="请输入医生姓名并选择" />
2021-10-11 10:21:06 +00:00
</view>
</view>
<!-- 重置筛选 -->
<view class="disjbac pad-zy20 mar-s50 mar-x30 pad-s20">
2021-10-22 03:07:32 +00:00
<view @tap="chongz"></view>
<view @tap="shaix"></view>
2021-10-11 10:21:06 +00:00
</view>
</view>
</view>
2021-10-22 03:07:32 +00:00
<view v-if="isXiao" @tap="isXiao=false" class="moban"></view>
2021-10-11 10:21:06 +00:00
<!-- 数据列表 -->
<view :style="{marginTop:statusHNH+titleHeight+'px'}">
2021-10-22 03:07:32 +00:00
<shopList :dataList="dataList" v-if="dataList.length!=0"></shopList>
<nothing-page v-if="dataList.length==0" :content="`暂无更多${searchVal}商品`"></nothing-page>
2021-10-11 10:21:06 +00:00
</view>
2021-08-19 06:40:59 +00:00
<!-- 底部tab -->
2021-08-19 09:27:37 +00:00
<foot-tab :titleList="titleList" :imgList="imgList" :newcurrent='3'></foot-tab>
2021-10-11 10:21:06 +00:00
<!-- 购物车 -->
2021-10-22 03:07:32 +00:00
<navigator url="/pagesA/shopCart/shopCart?isScore=false" hover-class="none">
<view class="cart-box">
<view class="posir">
<image src="/static/public/cart.png" mode="aspectFill"></image>
<view class="posia"><view>99</view></view>
2021-10-11 10:21:06 +00:00
</view>
</view>
</navigator>
2021-08-19 06:40:59 +00:00
</view>
</template>
<script>
2021-10-11 10:21:06 +00:00
import shopList from '@/components/shop-list.vue';
2021-08-19 06:40:59 +00:00
export default {
2021-10-11 10:21:06 +00:00
components:{
shopList
},
2021-08-19 06:40:59 +00:00
data() {
return {
2021-08-19 09:27:37 +00:00
titleList:[],
2021-10-11 10:21:06 +00:00
imgList:[],
statusHNH:uni.getStorageSync('statusHNH'),
publicColor:uni.getStorageSync('publicColor'),
activeIndex:'-1',
shopCate:['全部病种','全部医生','全部活动'],
cateTitle:'',
bingzList:[],//小分类列表
2021-10-22 03:07:32 +00:00
zanBingArr:[],//暂存小分类
2021-10-11 10:21:06 +00:00
isXiao:false,//
titleHeight:'',//标题高度
shaiList:[],//筛选后的结果列表
isClick:false,//是否点击了筛选
2021-10-22 03:07:32 +00:00
dataList:[],
searchVal:'',//关键词
doctor_role:'',//医生从职位标识 从商品筛选条件接口获取 目前为doctor=医生 design=设计师
doctor_name:'',//医生姓名 模糊搜索
activity:'',//活动类型 不填为普通商品+活动商品 normal=普通商品group_make=拼团group_buy=团购;limit_time=限时促销
disease_id:'',//病种ID
2021-08-19 06:40:59 +00:00
}
},
2021-08-22 08:53:12 +00:00
onShow() {
this.$toolAll.tools.isLogin()
},
2021-08-19 09:27:37 +00:00
onLoad() {
this.titleList = uni.getStorageSync('footTitle')
this.imgList = uni.getStorageSync('footimg')
2021-10-11 10:21:06 +00:00
// 缓存状态栏+标题栏的高度
const query = wx.createSelectorQuery()
query.select('.search-input-box').boundingClientRect((rect) => {
// console.log('状态栏+标题栏:',rect.height);
this.titleHeight = rect.height
}).exec()
2021-10-22 03:07:32 +00:00
this.checkSX();
2021-08-19 09:27:37 +00:00
},
2021-08-19 06:40:59 +00:00
methods: {
2021-10-22 03:07:32 +00:00
async checkSX(){//商品筛选条件
this.$requst.get('spu/condition').then(res=>{
if(res.code==0){
this.zanBingArr = res.data;
}
})
await this.checkShopList();
},
2021-10-11 10:21:06 +00:00
chooseShopCate(index){//大分类选择事件
2021-10-22 03:07:32 +00:00
if(this.activeIndex==index && this.isXiao) {
this.isXiao = false;
} else this.isXiao = true;
this.shaiList = []
this.bingzList = [];
2021-10-11 10:21:06 +00:00
this.isClick = false;
2021-10-22 03:07:32 +00:00
this.activeIndex = index;
let arr = [];
let obj = {};
2021-10-11 10:21:06 +00:00
if(this.activeIndex==0) {
this.cateTitle = '病种选择';
2021-10-22 03:07:32 +00:00
this.zanBingArr.disease.forEach(item=>{
obj = {
pid: item.pid,
title: item.name,
id: item.id,
sort: item.sort,
isActive:false
}
arr.push(obj);
})
this.bingzList = arr;
this.bingzList.unshift({pid: '', title: "全部", id: '', sort: '',isActive:true});
this.bingzList.push({pid: '', title: "其他", id: '', sort: ''});
2021-10-11 10:21:06 +00:00
}
if(this.activeIndex==1) {
this.cateTitle = '职位选择';
2021-10-22 03:07:32 +00:00
this.zanBingArr.doctor_roles.forEach(item=>{
obj = {
id: item.id,
name: item.name,
title: item.title,
pid: item.pid,
is_group: item.is_group,
isActive:false
}
arr.push(obj);
})
this.bingzList = arr;
this.bingzList.unshift({id: '', name: '', title: "全部", pid: '', is_group: '',isActive:true});
2021-10-11 10:21:06 +00:00
}
if(this.activeIndex==2) {
this.cateTitle = '活动选择';
2021-10-22 03:07:32 +00:00
this.zanBingArr.activity.forEach(item=>{
obj = {
name: item.name,
title: item.title,
isActive:false
}
arr.push(obj);
})
this.bingzList = arr;
this.bingzList.unshift({name: '', title: "全部",isActive:true});
}
},
checkShopList(){
let params = {
keyword:this.searchVal,//商品关键字 支持模糊搜索
page:1,
size:10,
doctor_role:this.doctor_role,//医生从职位标识 从商品筛选条件接口获取 目前为doctor=医生 design=设计师
doctor_name:this.doctor_name,//医生姓名 模糊搜索
activity:this.activity,//活动类型 不填为普通商品+活动商品 normal=普通商品group_make=拼团group_buy=团购;limit_time=限时促销
disease_id:this.disease_id//病种ID
2021-10-11 10:21:06 +00:00
}
2021-10-22 03:07:32 +00:00
this.$requst.post('spu/list',params).then(res=>{
if(res.code==0){
this.dataList = [];
if(res.data.list.length!=0){
res.data.list.forEach(item=>{
let tuan = false,ping = false,xian = false,integral = false;
if(item.activity_type=='group_make') ping = true;
if(item.activity_type=='group_buy') tuan = true;
if(item.activity_type=='limit_time') xian = true;
let group_cover = [];
if(item.activity_group_cover.length!=0) {
item.activity_group_cover.forEach(item=>{
group_cover.push(this.$http + item)
})
}
let obj = {
id:item.id,
imgSrc: this.$http + item.cover,
title: item.name,
zhePrice:item.price/100,
yuanPrice:item.original_price/100,
integral:'',
isTuan:tuan,
isPing:ping,
isXian:xian,
isIntegral:integral,
grade:'',
disease_name:item.disease_name,//病种名称
disease_id:item.disease_id,//病种ID
activity_end_at:item.activity_end_at,//限时结束时间
activity_group_cover:group_cover,//参团人的头像
activity_group_num:item.activity_group_num//已经参团人数
}
this.dataList.push(obj)
})
}
}
})
2021-10-11 10:21:06 +00:00
},
chooseBing(index){//小分类选择事件
2021-10-22 03:07:32 +00:00
this.bingzList[index].isActive = !this.bingzList[index].isActive;
let cun = this.shaiList.indexOf(this.bingzList[index].id);
2021-10-11 10:21:06 +00:00
if(cun==-1){
2021-10-22 03:07:32 +00:00
this.shaiList.push(this.bingzList[index].title);
2021-10-11 10:21:06 +00:00
}
2021-10-22 03:07:32 +00:00
this.searchVal = this.shaiList.join(',');
console.log(this.searchVal);
2021-10-11 10:21:06 +00:00
},
chongz(){//重置
this.isClick = false;
this.shaiList = []
},
shaix(){//筛选
this.isXiao = false
this.isClick = true;
2021-10-22 03:07:32 +00:00
this.checkShopList();
2021-10-11 10:21:06 +00:00
},
deleteSX(index){//删除筛选
this.shaiList.splice(index,1);
if(this.shaiList.length==0){
this.isClick = false;
}
2021-10-22 03:07:32 +00:00
},
searchEv(){//搜索事件
this.checkShopList();
2021-10-11 10:21:06 +00:00
}
2021-08-19 06:40:59 +00:00
}
}
</script>
<style>
2021-10-11 10:21:06 +00:00
page{background: #F5F5F5;}
2021-10-22 03:07:32 +00:00
.activecate,.shopMo{width: 216rpx;height: 65rpx;border-radius: 20rpx;line-height: 65rpx;text-align: center;background-color: #f2f2f2;color: #333333;}
.activecate{color: #FFFFFF;}
.shopMo span::after,.activecate span::after{display: inline-block;content: '';width: 16rpx;height: 13rpx;margin-left: 6rpx;}
.shopMo span::after{background: url(/static/public/shopSJ.png) no-repeat;background-size: 100% 90%;}
.activecate span::after{background: url(/static/public/shopSJ-active.png) no-repeat;background-size: 100% 90%;transform: rotate(180deg);background-position: 0 2rpx;}
2021-08-19 06:40:59 +00:00
</style>