284 lines
9.9 KiB
Vue
284 lines
9.9 KiB
Vue
<template>
|
||
<view>
|
||
<!-- 状态栏 -->
|
||
<status-nav :titleVal="'商城'" :statusBack="false" :statusTitle="true"></status-nav>
|
||
<!-- 搜索输入框 -->
|
||
<view class="search-input-box bacf poszy shop-nav-box" :style="{top: statusHNH+'px'}">
|
||
<view class="disac pad-zy30 mar-s20">
|
||
<!-- 输入框 -->
|
||
<input @focus="focusEv" class="width100 fon34 radius10" type="text" @confirm="searchEv" v-model="searchVal" placeholder="请输入商品名称"/>
|
||
<!-- 搜索 -->
|
||
<view class="flexs mar-z30 radius10 pad-zy40 fon34 colf" @tap="searchEv" :style="{background:publicColor}">搜索</view>
|
||
</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>
|
||
<view v-for="(item,indexx) in shaiList" :key="indexx">{{item}} <view class="mar-z10" @tap="deleteSX(indexx)">×</view></view>
|
||
</view>
|
||
<view v-if="isXiao">
|
||
<view class="pad-zy30">
|
||
<view class="mar-s50 mar-x20 fon28 bold">{{cateTitle}}</view>
|
||
<view class="disac fw">
|
||
<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>
|
||
</view>
|
||
<view v-if="activeIndex==1">
|
||
<view class="fon28 bold mar-sx40">医生选择</view>
|
||
<input type="text" class="mar-x40" value="" placeholder="请输入医生姓名并选择" />
|
||
</view>
|
||
</view>
|
||
<!-- 重置、筛选 -->
|
||
<view class="disjbac pad-zy20 mar-s50 mar-x30 pad-s20">
|
||
<view @tap="chongz">重置</view>
|
||
<view @tap="shaix">筛选</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view v-if="isXiao" @tap="isXiao=false" class="moban"></view>
|
||
<!-- 数据列表 -->
|
||
<view v-if="loading" :style="{marginTop:statusHNH+titleHeight+'px'}">
|
||
<shopList :dataList="dataList" v-if="dataList.length!=0"></shopList>
|
||
<nothing-page v-if="dataList.length==0" :content="`暂无更多${searchVal}商品`"></nothing-page>
|
||
</view>
|
||
<!-- 底部tab -->
|
||
<foot-tab :titleList="titleList" :imgList="imgList" :newcurrent='3'></foot-tab>
|
||
<!-- 购物车 -->
|
||
<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" v-if="cartNum!=0"><view>{{cartNum}}</view></view>
|
||
</view>
|
||
</view>
|
||
</navigator>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import shopList from '@/components/shop-list.vue';
|
||
import {cartNum} from '@/jsFile/publicAPI.js';
|
||
export default {
|
||
components:{
|
||
shopList
|
||
},
|
||
data() {
|
||
return {
|
||
titleList:[],
|
||
imgList:[],
|
||
statusHNH:uni.getStorageSync('statusHNH'),
|
||
publicColor:uni.getStorageSync('publicColor'),
|
||
activeIndex:'-1',
|
||
shopCate:['全部病种','全部医生','全部活动'],
|
||
cateTitle:'',
|
||
bingzList:[],//小分类列表
|
||
zanBingArr:[],//暂存小分类
|
||
isXiao:false,//
|
||
titleHeight:'',//标题高度
|
||
shaiList:[],//筛选后的结果列表
|
||
isClick:false,//是否点击了筛选
|
||
dataList:[],
|
||
searchVal:'',//关键词
|
||
doctor_role:'',//医生从职位标识 从商品筛选条件接口获取 目前为doctor=医生 design=设计师
|
||
doctor_name:'',//医生姓名 模糊搜索
|
||
activity:'',//活动类型 不填为普通商品+活动商品 normal=普通商品;group_make=拼团;group_buy=团购;limit_time=限时促销
|
||
disease_id:'',//病种ID
|
||
loading:false,
|
||
cartNum:0
|
||
}
|
||
},
|
||
onShow() {
|
||
this.$toolAll.tools.isLogin();
|
||
this.cartNumEv();//查询购物车数量
|
||
},
|
||
onLoad() {
|
||
this.titleList = uni.getStorageSync('footTitle')
|
||
this.imgList = uni.getStorageSync('footimg')
|
||
// 缓存状态栏+标题栏的高度
|
||
const query = wx.createSelectorQuery()
|
||
query.select('.search-input-box').boundingClientRect((rect) => {
|
||
// console.log('状态栏+标题栏:',rect.height);
|
||
this.titleHeight = rect.height
|
||
}).exec()
|
||
this.checkSX();
|
||
},
|
||
methods: {
|
||
cartNumEv(){//购物车数量
|
||
this.$requst.post('order/shopping-cart-count',{type:'spu'}).then(res=>{
|
||
if(res.code==0){
|
||
this.cartNum = res.data.count;
|
||
}
|
||
})
|
||
},
|
||
async checkSX(){//商品筛选条件
|
||
this.$requst.get('spu/condition').then(res=>{
|
||
if(res.code==0){
|
||
this.zanBingArr = res.data;
|
||
}
|
||
})
|
||
await this.checkShopList();
|
||
},
|
||
chooseShopCate(index){//大分类选择事件
|
||
if(this.activeIndex==index && this.isXiao) {
|
||
this.isXiao = false;
|
||
} else this.isXiao = true;
|
||
this.bingzList = [];
|
||
this.isClick = false;
|
||
this.activeIndex = index;
|
||
let arr = [];
|
||
let obj = {};
|
||
if(this.activeIndex==0) {
|
||
this.cateTitle = '病种选择';
|
||
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: ''});
|
||
}
|
||
if(this.activeIndex==1) {
|
||
this.cateTitle = '职位选择';
|
||
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});
|
||
}
|
||
if(this.activeIndex==2) {
|
||
this.cateTitle = '活动选择';
|
||
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:2000,
|
||
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
|
||
}
|
||
uni.request({
|
||
url:'https://hengmei.scdxtc.cn/api/spu/list',
|
||
data:params,
|
||
method:'post',
|
||
header:{
|
||
'Content-Type': 'application/json; charset=UTF-8',
|
||
'Authorization': 'Bearer '+uni.getStorageSync('token') || ''
|
||
},
|
||
success: (res) => {
|
||
if(res.data.code==0){
|
||
this.dataList = [];
|
||
if(res.data.data.list.length!=0){
|
||
res.data.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
|
||
reponseTime:res.header.Date,//接口响应时间
|
||
activity_end_at:item.activity_end_at,//限时结束时间
|
||
activity_group_cover:group_cover,//参团人的头像
|
||
activity_group_num:item.activity_group_num,//已经参团人数
|
||
}
|
||
this.dataList.push(obj)
|
||
})
|
||
this.loading = true;
|
||
}
|
||
}
|
||
}
|
||
})
|
||
},
|
||
chooseBing(index){//小分类选择事件
|
||
this.bingzList.forEach(item=>{
|
||
item.isActive = false;
|
||
})
|
||
this.bingzList[index].isActive = true;
|
||
this.shaiList[this.activeIndex] = this.bingzList[index].title;
|
||
console.log(this.shaiList);
|
||
},
|
||
chongz(){//重置
|
||
this.isClick = false;
|
||
this.shaiList = []
|
||
},
|
||
shaix(){//筛选
|
||
this.isXiao = false
|
||
this.isClick = true;
|
||
this.checkShopList();
|
||
},
|
||
deleteSX(index){//删除筛选
|
||
this.shaiList.splice(index,1);
|
||
if(this.shaiList.length==0){
|
||
this.isClick = false;
|
||
}
|
||
},
|
||
focusEv(){
|
||
uni.navigateTo({
|
||
url:'/pagesB/shopSearch/shopSearch'
|
||
})
|
||
},
|
||
searchEv(){//搜索事件
|
||
// uni.navigateTo({
|
||
// url:'/pagesB/shopSearch/shopSearch'
|
||
// })
|
||
// this.checkShopList();
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style>
|
||
page{background: #F5F5F5;}
|
||
.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;}
|
||
</style>
|