| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 | <template>	<view class="content">		<view class="top-content">			<view class="status_bar" :style="{height: statusBarHeight}"></view>			<!-- 这里是状态栏 -->			<view class="top-title">药品商城</view>			<!-- 搜索框 -->			<view class="search-cont">				<view class="inner">					<image class="icon-search" src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/icon_search.png" mode=""></image>					<input type="text" disabled   confirm-type="搜索" @click="toSearch" placeholder="输入药品名称" placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />				</view>			</view>		</view>		<view   class="medic-box">			<view class="cate-list" :style="{top: mescrollTop+'px',height:divHeight}" >				<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)">							<image :src="item.imageUrl" mode=""></image>						</swiper-item>					</swiper>				</view> -->				<!-- 药品列表 -->				<mescroll-body :top="mescrollTop+'px'" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">					<view style="padding-right: 16rpx;">						<medicineItem v-for="(item, index) in dataList" :key="index" :item="item"></medicineItem>						<!-- <medicineVerticalItem v-for="(item, index) in dataList" :key="index" :item="item"></medicineVerticalItem> -->					</view>				</mescroll-body>			</view>		</view>	</view></template><script>	import {getProductCate,getProducts} from '@/api/index.js'	import {getAdv} from '@/api/adv'	import medicineVerticalItem from "@/components/medicineVerticalItem";	import medicineItem from "@/components/medicineItem";	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";	export default {		mixins: [MescrollMixin], // 使用mixin		components: {			medicineVerticalItem,			medicineItem		},		data() {			return {				divHeight:'0px',				allCates:[],				cates:[],				subCates:[],				// 状态栏的高度				statusBarHeight: uni.getStorageSync('menuInfo').statusBarHeight,				// 选中药品分类				cateSelect: 0,				// 轮播图				advs: [],				mescroll:null,				downOption: {   //下拉刷新				 	use:true,					auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)				},				// 上拉加载的配置				upOption: {					onScroll:true,					use: true, // 是否启用上拉加载; 默认true					page: {						num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始						size: 10 // 每页数据的数量,默认10					},					noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示					empty: {						icon:'https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/empty_icon.png',						tip: '暂无数据'					},					textNoMore:"已经到底了",				},				// 列表数据				dataList: [],				form:{					defaultOrder:'desc',					newOrder:null,					priceOrder:null,					salesOrder:null,					productName:"",					storeId: "",					cateId:'',					pid:''				},				mescrollTop: 200			};		},		onLoad() {			uni.showShareMenu({				withShareTicket:true,				//小程序的原生菜单中显示分享按钮,才能够让发送给朋友与分享到朋友圈两个按钮可以点击				menus:["shareAppMessage","shareTimeline"] //不设置默认发送给朋友			})			this.getProductCate();		},		onShow() {			let that=this;			setTimeout(function(){				let info = uni.createSelectorQuery().select(".top-content");		     info.boundingClientRect(function(data) { //data - 各种参数					that.divHeight="calc(100vh - "+data.height+"px)"					that.mescrollTop = data.height		      }).exec()			},500);			this.getAdv();		},		methods:{			splitPrice(num) {			  const [intPart = '0', decPart = '00'] = String(num||0).split('.');			  return { intPart, decPart: decPart.padEnd(2, '0').slice(0, 2) };			},			toSearch() {				uni.navigateTo({					url: '/pages_shopping/home/productSearch'				})			},			handleAdvClick(item){				console.log(item);				if(item.showType==1){					uni.setStorageSync('url',item.advUrl);					uni.navigateTo({						url:"/pages_shopping/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:"/pages_shopping/home/content"					 })				}							},			getAdv(){				let data = {advType:2};				getAdv(data).then(					res => {						if(res.code==200){							this.advs=res.data;						}					},					rej => {}				);			},			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(this.cates!=null&&this.cates.length>0){								this.cateSelect=this.cates[0].cateId;								// this.getSubCate()								this.form.cateId = this.cates[0].cateId;								// this.form.pid = this.cates[0].pid;								this.mescroll.resetUpScroll()							}						}else{							uni.showToast({								icon:'none',								title: "请求失败",							});						}					},					rej => {}				);			},			// 药品分类选择			choseCate(item) {				this.cateSelect = item.cateId;				// this.getSubCate()				this.form.cateId = item.cateId;				// this.form.pid = item.pid;				this.mescroll.resetUpScroll()			},			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				});				 				console.log(this.subCates);			},			// 查看药品详情			showProductList(item) {				uni.navigateTo({					url: '/pages_shopping/productList?cateId='+item.cateId+"&pid="+item.pid				})			},			goSearch(e) {				if(e.detail.value!=null&&e.detail.value!=""){					this.$addHisSearch(e.detail.value);				}				uni.navigateTo({					url: '/pages_shopping/home/productList?searchValue=' + e.detail.value				})			},			mescrollInit(mescroll) {				this.mescroll = mescroll;			},			/*下拉刷新的回调 */			downCallback(mescroll) {				mescroll.resetUpScroll()			},			upCallback(page) {				//联网加载数据				var that = this;				this.form.page=page.num;				this.form.pageSize=page.size;				getProducts(this.form).then(res => {					if(res.code==200){						//设置列表数据						if (page.num == 1) {							that.dataList = res.data.list; 													} else {							that.dataList = that.dataList.concat(res.data.list);							 						}						that.mescroll.endBySize(res.data.list.length, res.data.total);											}else{						uni.showToast({							icon:'none',							title: "请求失败",						});						that.dataList = null;						that.mescroll.endErr();					}				});			},		}	}</script><style lang="scss">	page{		height: 100%;		background-color: #fff;	}		.content{		height: 100%;		display: flex;		flex-direction: column;		.top-content{			width: 100%;			z-index: 10;			position: fixed;			left: 0;			top: 0;			background-color: #FFFFFF;			.top-title{				height: 88upx;				line-height: 88upx;				font-size: 42upx;				font-family: Source Han Sans CN;				font-weight: bold;				color: #222222;				padding-left: 41upx;				background-color: #FFFFFF;			}			.search-cont{				padding: 16upx 30upx;				background-color: #FFFFFF;				.inner{					box-sizing: border-box;					width: 100%;					height: 72upx;					background: #F7F7F7;					border-radius: 36upx;					display: flex;					align-items: center;					padding: 0 30upx;					.icon-search{						width: 28upx;						height: 28upx;						margin-right: 20upx;					}					input{						height: 60upx;						line-height: 60upx;						flex: 1;					}				}			}		}		::v-deep{			.mescroll-body, .mescroll-body{				padding-left: 204rpx;			}		}		.medic-box{			.cate-list{				position: fixed;				left: 0;				z-index: 999;				box-sizing: border-box;				width: 180upx;				background: #F2F5F9;				display: flex;				flex-direction: column;				padding: 20upx 0;				overflow-y: scroll;				.item{					height: 100upx;					line-height: 100upx;					padding-left: 20upx;					font-size: 28upx;					font-family: PingFang SC;					font-weight: 500;					color: #333333;					position: relative;					&.active{						color: #2583EB;						&::after{							content: "";							width: 8upx;							height: 50upx;							background: #2583EB;							position: absolute;							top: 25upx;							left: 0;						}					}				}			}			.medic{				overflow: hidden;				box-sizing: border-box;				.banner-box{					margin-top: 30rpx;					width: 100%;					height: 160upx;					border-radius: 10upx;					overflow: hidden;					.swiper,					.swiper-item,					.swiper-item image{						width: 100%;						height: 100%;					}				}			}		}			}</style>
 |