|
@@ -3,71 +3,93 @@
|
|
|
<view class="top-content">
|
|
|
<view class="status_bar" :style="{height: statusBarHeight}"></view>
|
|
|
<!-- 这里是状态栏 -->
|
|
|
- <view class="top-title">健康商城</view>
|
|
|
+ <!-- <view class="top-title">健康商城</view> -->
|
|
|
<!-- 搜索框 -->
|
|
|
<view class="search-cont">
|
|
|
<view class="inner">
|
|
|
<image class="icon-search" src="../../static/images/search.png" mode=""></image>
|
|
|
- <input type="text" disabled confirm-type="搜索" @click="toSearch" placeholder="输入药品名称" placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />
|
|
|
+ <input type="text" disabled confirm-type="搜索" @click="toSearch" placeholder="输入药品名称"
|
|
|
+ placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view :style="{height: divHeight}" class="medic-box">
|
|
|
+ <view :style="{height: divHeight}" class="medic-box">
|
|
|
<view class="cate-list">
|
|
|
- <view
|
|
|
- v-for="(item,index) in cates"
|
|
|
- :key="index"
|
|
|
- :class="cateSelect == item.cateId?'item active':'item'"
|
|
|
- @click="choseCate(item)"
|
|
|
- >{{item.cateName }}</view>
|
|
|
+ <view v-for="(item,index) in cates" :key="index" :class="cateSelect == item.cateId?'item active':'item'"
|
|
|
+ @click="choseCate(item)">{{item.cateName }}</view>
|
|
|
</view>
|
|
|
<view class="medic">
|
|
|
<!-- 轮播图 -->
|
|
|
<view class="banner-box">
|
|
|
- <swiper
|
|
|
- class="swiper"
|
|
|
- :indicator-dots="true"
|
|
|
- :circular="true"
|
|
|
- :autoplay="true"
|
|
|
- :interval="3000"
|
|
|
- :duration="1000"
|
|
|
- indicator-color="rgba(255, 255, 255, 0.6)"
|
|
|
- indicator-active-color="#ffffff"
|
|
|
- >
|
|
|
- <swiper-item class="swiper-item" v-for="(item,index) in advs" :key="index" @click="handleAdvClick(item)">
|
|
|
+ <swiper class="swiper" :indicator-dots="true" :circular="true" :autoplay="true" :interval="3000"
|
|
|
+ :duration="1000" indicator-color="rgba(255, 255, 255, 0.6)" indicator-active-color="#ffffff">
|
|
|
+ <swiper-item class="swiper-item" v-for="(item,index) in advs" :key="index"
|
|
|
+ @click="handleAdvClick(item)">
|
|
|
<image :src="item.imageUrl" mode=""></image>
|
|
|
</swiper-item>
|
|
|
</swiper>
|
|
|
</view>
|
|
|
<!-- 药品列表 -->
|
|
|
<view class="medic-list">
|
|
|
- <!-- <view class="item" v-for="(item,index) in subCates" :key="index">
|
|
|
+ <!-- <view class="item" v-for="(item,index) in subCates" :key="index">
|
|
|
<view class="title">{{item.cateName}}</view> -->
|
|
|
- <view class="inner-list">
|
|
|
- <view class="definite"v-for="(subItem,index) in subCates" @click="showProductList(subItem)">
|
|
|
+ <view class="inner-list">
|
|
|
+ <!-- <view class="definite"v-for="(subItem,index) in subCates" @click="showProductList(subItem)">
|
|
|
<view class="img-box">
|
|
|
<image :src="subItem.pic" mode="aspectFit"></image>
|
|
|
</view>
|
|
|
<view class="name ellipsis">{{subItem.cateName}}</view>
|
|
|
+ </view> -->
|
|
|
+ <view class="definite" v-for="(subItem,index) in subCates"
|
|
|
+ @click="showProductList(subItem, index)">
|
|
|
+ <view class="name ellipsis" :class="{ 'select-name': activeIndex === index }">
|
|
|
+ {{subItem.cateName}}
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="line"></view>
|
|
|
+ <view class="product-list">
|
|
|
+ <text class="product-title"> {{ activeIndex >= 0 ? subCates[activeIndex].cateName : '' }}</text>
|
|
|
+ <view class="">
|
|
|
+ <view class="">
|
|
|
+ <image src=""></image>
|
|
|
+ <view class="">
|
|
|
+ <text>云南白药气雾剂每瓶重50g保险液每瓶...</text>
|
|
|
+ <view class="">
|
|
|
+ <view class="">9.5折</view>
|
|
|
+ <view class="">限购1份</view>
|
|
|
+ </view>
|
|
|
+ <view class="">
|
|
|
+ <text><text>57</text>.48</text>
|
|
|
+ <text>¥60.50</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
<!-- </view> -->
|
|
|
</view>
|
|
|
+
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import {getProductCate} from '@/api/product'
|
|
|
- import {getAdv} from '@/api/adv'
|
|
|
+ import {
|
|
|
+ getProductCate
|
|
|
+ } from '@/api/product'
|
|
|
+ import {
|
|
|
+ getAdv
|
|
|
+ } from '@/api/adv'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- divHeight:'0px',
|
|
|
- allCates:[],
|
|
|
- cates:[],
|
|
|
- subCates:[],
|
|
|
+ activeIndex: 0,
|
|
|
+ divHeight: '0px',
|
|
|
+ allCates: [],
|
|
|
+ cates: [],
|
|
|
+ subCates: [],
|
|
|
// 状态栏的高度
|
|
|
statusBarHeight: uni.getStorageSync('menuInfo').statusBarHeight,
|
|
|
// 选中药品分类
|
|
@@ -78,25 +100,25 @@
|
|
|
},
|
|
|
onLoad() {
|
|
|
uni.showShareMenu({
|
|
|
- withShareTicket:true,
|
|
|
+ withShareTicket: true,
|
|
|
//小程序的原生菜单中显示分享按钮,才能够让发送给朋友与分享到朋友圈两个按钮可以点击
|
|
|
- menus:["shareAppMessage","shareTimeline"] //不设置默认发送给朋友
|
|
|
+ menus: ["shareAppMessage", "shareTimeline"] //不设置默认发送给朋友
|
|
|
})
|
|
|
this.getProductCate();
|
|
|
},
|
|
|
onShow() {
|
|
|
- var that=this;
|
|
|
- setTimeout(function(){
|
|
|
+ var that = this;
|
|
|
+ setTimeout(function() {
|
|
|
let info = uni.createSelectorQuery().select(".top-content");
|
|
|
- info.boundingClientRect(function(data) { //data - 各种参数
|
|
|
- console.log(data.height) // 获取元素宽度
|
|
|
+ info.boundingClientRect(function(data) { //data - 各种参数
|
|
|
+ console.log(data.height) // 获取元素宽度
|
|
|
// console.log(uni.upx2px(10))
|
|
|
- that.divHeight="calc(100% - "+data.height+"px)"
|
|
|
- }).exec()
|
|
|
- },500);
|
|
|
+ that.divHeight = "calc(100% - " + data.height + "px)"
|
|
|
+ }).exec()
|
|
|
+ }, 500);
|
|
|
this.getAdv();
|
|
|
},
|
|
|
- methods:{
|
|
|
+ methods: {
|
|
|
// divHeight(){
|
|
|
// return 'height:calc(100% - ${this.top}px);'
|
|
|
// },
|
|
@@ -105,54 +127,54 @@
|
|
|
url: '../home/productSearch'
|
|
|
})
|
|
|
},
|
|
|
- handleAdvClick(item){
|
|
|
+ handleAdvClick(item) {
|
|
|
console.log(item);
|
|
|
- if(item.showType==1){
|
|
|
- uni.setStorageSync('url',item.advUrl);
|
|
|
+ if (item.showType == 1) {
|
|
|
+ uni.setStorageSync('url', item.advUrl);
|
|
|
uni.navigateTo({
|
|
|
- url:"../home/h5"
|
|
|
+ url: "../home/h5"
|
|
|
+ })
|
|
|
+ } else if (item.showType == 2) {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: item.advUrl
|
|
|
+ })
|
|
|
+ } else if (item.showType == 3) {
|
|
|
+ uni.setStorageSync('content', item.content);
|
|
|
+ uni.navigateTo({
|
|
|
+ url: "../home/content"
|
|
|
})
|
|
|
}
|
|
|
- else if(item.showType==2){
|
|
|
- uni.navigateTo({
|
|
|
- url:item.advUrl
|
|
|
- })
|
|
|
- }
|
|
|
- else if(item.showType==3){
|
|
|
- uni.setStorageSync('content',item.content);
|
|
|
- uni.navigateTo({
|
|
|
- url:"../home/content"
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
- getAdv(){
|
|
|
- let data = {advType:2};
|
|
|
+ getAdv() {
|
|
|
+ let data = {
|
|
|
+ advType: 2
|
|
|
+ };
|
|
|
getAdv(data).then(
|
|
|
res => {
|
|
|
- if(res.code==200){
|
|
|
- this.advs=res.data;
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.advs = res.data;
|
|
|
}
|
|
|
},
|
|
|
rej => {}
|
|
|
);
|
|
|
},
|
|
|
- getProductCate(){
|
|
|
+ getProductCate() {
|
|
|
let data = {};
|
|
|
getProductCate(data).then(
|
|
|
res => {
|
|
|
- if(res.code==200){
|
|
|
- this.allCates=res.data;
|
|
|
- this.cates = this.allCates.filter(function (item) {
|
|
|
- return item.pid==0
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.allCates = res.data;
|
|
|
+ this.cates = this.allCates.filter(function(item) {
|
|
|
+ return item.pid == 0
|
|
|
});
|
|
|
- if(this.cates!=null&&this.cates.length>0){
|
|
|
- this.cateSelect=this.cates[0].cateId;
|
|
|
+ if (this.cates != null && this.cates.length > 0) {
|
|
|
+ this.cateSelect = this.cates[0].cateId;
|
|
|
this.getSubCate()
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
uni.showToast({
|
|
|
- icon:'none',
|
|
|
+ icon: 'none',
|
|
|
title: "请求失败",
|
|
|
});
|
|
|
}
|
|
@@ -164,29 +186,32 @@
|
|
|
choseCate(item) {
|
|
|
this.cateSelect = item.cateId;
|
|
|
this.getSubCate()
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
- getSubCate(){
|
|
|
- var that=this;
|
|
|
- this.subCates = this.allCates.filter(function (item) {
|
|
|
+ getSubCate() {
|
|
|
+ var that = this;
|
|
|
+ this.subCates = this.allCates.filter(function(item) {
|
|
|
// let subList = that.allCates.filter(child => {
|
|
|
// //返回每一项的子级数组
|
|
|
// return child.pid === item.cateId
|
|
|
// });
|
|
|
// subList.length > 0 ? item.children = subList : [];
|
|
|
- return item.pid==that.cateSelect
|
|
|
+ return item.pid == that.cateSelect
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
console.log(this.subCates);
|
|
|
},
|
|
|
// 查看药品详情
|
|
|
- showProductList(item) {
|
|
|
- uni.navigateTo({
|
|
|
- url: './productList?cateId='+item.cateId+"&pid="+item.pid
|
|
|
- })
|
|
|
+ showProductList(item, index) {
|
|
|
+ // console.log("item>>>>>", item)
|
|
|
+ this.activeIndex = index;
|
|
|
+
|
|
|
+ // uni.navigateTo({
|
|
|
+ // url: './productList?cateId='+item.cateId+"&pid="+item.pid
|
|
|
+ // })
|
|
|
},
|
|
|
goSearch(e) {
|
|
|
- if(e.detail.value!=null&&e.detail.value!=""){
|
|
|
+ if (e.detail.value != null && e.detail.value != "") {
|
|
|
this.utils.addHisSearch(e.detail.value);
|
|
|
}
|
|
|
uni.navigateTo({
|
|
@@ -198,19 +223,21 @@
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
|
- page{
|
|
|
+ page {
|
|
|
height: 100%;
|
|
|
background-color: #fff;
|
|
|
}
|
|
|
-
|
|
|
- .content{
|
|
|
+
|
|
|
+ .content {
|
|
|
height: 100%;
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
|
- .top-content{
|
|
|
+
|
|
|
+ .top-content {
|
|
|
width: 100%;
|
|
|
z-index: 10;
|
|
|
- .top-title{
|
|
|
+
|
|
|
+ .top-title {
|
|
|
height: 88upx;
|
|
|
line-height: 88upx;
|
|
|
font-size: 42upx;
|
|
@@ -220,10 +247,12 @@
|
|
|
padding-left: 41upx;
|
|
|
background-color: #FFFFFF;
|
|
|
}
|
|
|
- .search-cont{
|
|
|
+
|
|
|
+ .search-cont {
|
|
|
padding: 16upx 30upx;
|
|
|
background-color: #FFFFFF;
|
|
|
- .inner{
|
|
|
+
|
|
|
+ .inner {
|
|
|
box-sizing: border-box;
|
|
|
width: 100%;
|
|
|
height: 72upx;
|
|
@@ -232,12 +261,14 @@
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
padding: 0 30upx;
|
|
|
- .icon-search{
|
|
|
+
|
|
|
+ .icon-search {
|
|
|
width: 28upx;
|
|
|
height: 28upx;
|
|
|
margin-right: 20upx;
|
|
|
}
|
|
|
- input{
|
|
|
+
|
|
|
+ input {
|
|
|
height: 60upx;
|
|
|
line-height: 60upx;
|
|
|
flex: 1;
|
|
@@ -245,9 +276,11 @@
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- .medic-box{
|
|
|
+
|
|
|
+ .medic-box {
|
|
|
display: flex;
|
|
|
- .cate-list{
|
|
|
+
|
|
|
+ .cate-list {
|
|
|
box-sizing: border-box;
|
|
|
width: 200upx;
|
|
|
background: #F2F5F9;
|
|
@@ -255,7 +288,8 @@
|
|
|
flex-direction: column;
|
|
|
padding: 20upx 0;
|
|
|
overflow-y: scroll;
|
|
|
- .item{
|
|
|
+
|
|
|
+ .item {
|
|
|
height: 100upx;
|
|
|
line-height: 100upx;
|
|
|
padding-left: 30upx;
|
|
@@ -264,39 +298,47 @@
|
|
|
font-weight: 500;
|
|
|
color: #333333;
|
|
|
position: relative;
|
|
|
- &.active{
|
|
|
- color: #0bb3f2;
|
|
|
- &::after{
|
|
|
+
|
|
|
+ &.active {
|
|
|
+ background: #FFFFFF;
|
|
|
+ font-weight: 600;
|
|
|
+
|
|
|
+ &::after {
|
|
|
content: "";
|
|
|
- width: 8upx;
|
|
|
- height: 50upx;
|
|
|
+ width: 6upx;
|
|
|
+ height: 28upx;
|
|
|
background: #0bb3f2;
|
|
|
position: absolute;
|
|
|
- top: 25upx;
|
|
|
+ top: 50%;
|
|
|
left: 0;
|
|
|
+ transform: translateY(-50%);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- .medic{
|
|
|
+
|
|
|
+ .medic {
|
|
|
box-sizing: border-box;
|
|
|
width: calc(100% - 200upx);
|
|
|
height: 100%;
|
|
|
padding: 0 30upx;
|
|
|
- .banner-box{
|
|
|
+
|
|
|
+ .banner-box {
|
|
|
margin-top: 30rpx;
|
|
|
width: 100%;
|
|
|
height: 160upx;
|
|
|
border-radius: 10upx;
|
|
|
overflow: hidden;
|
|
|
+
|
|
|
.swiper,
|
|
|
.swiper-item,
|
|
|
- .swiper-item image{
|
|
|
+ .swiper-item image {
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
}
|
|
|
}
|
|
|
- .medic-list{
|
|
|
+
|
|
|
+ .medic-list {
|
|
|
box-sizing: border-box;
|
|
|
padding: 30upx 0;
|
|
|
overflow-y: auto;
|
|
@@ -311,16 +353,18 @@
|
|
|
// padding-top: 20upx;
|
|
|
// margin-bottom: 30upx;
|
|
|
// }
|
|
|
-
|
|
|
+
|
|
|
// }
|
|
|
- .inner-list{
|
|
|
+ .inner-list {
|
|
|
display: flex;
|
|
|
flex-wrap: wrap;
|
|
|
- .definite{
|
|
|
+
|
|
|
+ .definite {
|
|
|
width: calc(33% - 20upx);
|
|
|
margin-right: 30upx;
|
|
|
margin-bottom: 30upx;
|
|
|
- .img-box{
|
|
|
+
|
|
|
+ .img-box {
|
|
|
width: 100%;
|
|
|
height: 144upx;
|
|
|
background: #F5F5F5;
|
|
@@ -328,11 +372,13 @@
|
|
|
overflow: hidden;
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
- image{
|
|
|
+
|
|
|
+ image {
|
|
|
max-width: 100%;
|
|
|
}
|
|
|
}
|
|
|
- .name{
|
|
|
+
|
|
|
+ .name {
|
|
|
width: 100%;
|
|
|
margin-top: 20upx;
|
|
|
font-size: 24upx;
|
|
@@ -340,16 +386,37 @@
|
|
|
font-weight: 500;
|
|
|
color: #666666;
|
|
|
text-align: center;
|
|
|
+ padding: 6rpx 16rpx;
|
|
|
+ }
|
|
|
+
|
|
|
+ .select-name {
|
|
|
+ background: #EFF3F7;
|
|
|
+ color: #222426;
|
|
|
}
|
|
|
+
|
|
|
&:nth-child(3n) {
|
|
|
margin-right: 0;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ .line {
|
|
|
+ width: 100%;
|
|
|
+ height: 0rpx;
|
|
|
+ border: 1rpx solid #ECECEC;
|
|
|
+ }
|
|
|
+
|
|
|
+ .product-list {
|
|
|
+ padding: 32rpx 0 0;
|
|
|
+ .product-title {
|
|
|
+ font-weight: 500;
|
|
|
+ font-size: 28rpx;
|
|
|
+ color: #222426;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
-</style>
|
|
|
+</style>
|