| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 | 
							- <template>
 
- 	<view>
 
- 		<view class="top-content">
 
- 			<!-- 搜索框 -->
 
- 			<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" v-model="keyword" placeholder="输入关键字搜索" confirm-type="search" @confirm="doSearch" placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />
 
- 				</view>
 
- 			</view>
 
- 			<view class="cate-list">
 
- 				<!-- 关键字列表 -->
 
- 				<scroll-view   scroll-x="true" >
 
- 					<view class="inner">
 
- 						<view v-for="(item,index) in foodOptions" :key="index" :class="food == item.dictLabel?'item active':'item'" @click="choseFood(item)">
 
- 							{{ item.dictLabel }}
 
- 						</view>
 
- 					</view>
 
- 				</scroll-view>
 
- 				<scroll-view   scroll-x="true" >
 
- 					<view class="inner">
 
- 						<view v-for="(item,index) in actionOptions" :key="index" :class="action == item.dictLabel?'item active':'item'" @click="choseAction(item)">
 
- 							{{ item.dictLabel }}
 
- 						</view>
 
- 					</view>
 
- 				</scroll-view>
 
- 				<scroll-view   scroll-x="true" >
 
- 					<view class="inner">
 
- 						<view v-for="(item,index) in indicationOptions" :key="index" :class="indications == item.dictLabel?'item active':'item'" @click="choseIndications(item)">
 
- 							{{ item.dictLabel }}
 
- 						</view>
 
- 					</view>
 
- 				</scroll-view>
 
- 			</view>
 
- 		</view>
 
- 		<mescroll-body  top="376rpx"  ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
 
- 			<view class="article-list">
 
- 				<view class="item" v-for="(item,index) in dataList" :key="index" @click="showDetail(item)">
 
- 					<view class="top">
 
- 						<image :src="item.imgUrl" mode="aspectFill"></image>
 
- 					</view>
 
- 					<view class="title ellipsis">{{ item.foodName }}</view>
 
- 					<view class="desc ellipsis">{{ item.actionTitle }}</view>
 
- 				</view>
 
- 			</view>
 
- 		</mescroll-body>
 
- 		
 
- 	</view>
 
- </template>
 
- <script>
 
- 	import {getDictByKey} from '@/api/common.js'
 
- 	import {getMedicatedFoodList} from '@/api/index.js'
 
- 	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
 
- 	export default {
 
- 		mixins: [MescrollMixin], 
 
- 		data() {
 
- 			return {
 
- 				foodOptions:[],
 
- 				actionOptions:[],
 
- 				indicationOptions:[],
 
- 				action:"",
 
- 				food:"",
 
- 				indications:"",
 
- 				keyword: '',
 
- 				mescroll:null,
 
- 				downOption: {   //下拉刷新
 
- 				 	use:true,
 
- 					auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
 
- 				},
 
- 				upOption: {
 
- 					onScroll:false,
 
- 					use: true, // 是否启用上拉加载; 默认true
 
- 					page: {
 
- 						pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
 
- 						size: 10 // 每页数据的数量,默认10
 
- 					},
 
- 					noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
 
- 					textNoMore:"已经到底了",
 
- 					empty: {
 
- 						icon:'https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/empty_icon.png',
 
- 						tip: '暂无数据'
 
- 					}
 
- 				},
 
- 				dataList: []
 
- 			};
 
- 		},
 
- 		onShow() {
 
- 			this.getDictByKey("sys_medicated_food");
 
- 			this.getDictByKey("sys_medicated_food_action");
 
- 			this.getDictByKey("sys_indication");
 
- 			
 
- 		},
 
- 		methods:{
 
- 			getDictByKey(key){
 
- 				var data={key:key}
 
- 				getDictByKey(data).then(
 
- 					res => {
 
- 						if(res.code==200){
 
- 							if(key=="sys_medicated_food"){
 
- 								this.foodOptions=res.data;
 
- 							}
 
- 							if(key=="sys_medicated_food_action"){
 
- 								this.actionOptions=res.data;
 
- 								 
 
- 							}
 
- 							if(key=="sys_indication"){
 
- 								this.indicationOptions=res.data;
 
- 								 
 
- 							}
 
- 						}
 
- 					},
 
- 					err => {
 
- 					}
 
- 				);
 
- 				
 
- 			},
 
- 			doSearch(){
 
- 				this.mescroll.resetUpScroll()
 
- 			},
 
- 			mescrollInit(mescroll) {
 
- 				this.mescroll = mescroll;
 
- 			},
 
- 			/*下拉刷新的回调 */
 
- 			downCallback(mescroll) {
 
- 				mescroll.resetUpScroll()
 
- 			},
 
- 			upCallback(page) {
 
- 				//联网加载数据
 
- 				var that = this;
 
- 				var data = {
 
- 					food:this.food,
 
- 					action:this.action,
 
- 					indications:this.indications,
 
- 					keyword:this.keyword,
 
- 					pageNum: page.num,
 
- 					pageSize: page.size
 
- 				};
 
- 				getMedicatedFoodList(data).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();
 
- 					}
 
- 				});
 
- 			},
 
- 			choseAction(item) {
 
- 				this.action = item.dictLabel;
 
- 				this.mescroll.resetUpScroll()
 
- 			},
 
- 			choseFood(item) {
 
- 				this.food = item.dictLabel;
 
- 				this.mescroll.resetUpScroll()
 
- 			},
 
- 			choseIndications(item) {
 
- 				this.indications = item.dictLabel;
 
- 				this.mescroll.resetUpScroll()
 
- 			},
 
- 			// 查看详情
 
- 			showDetail(item) {
 
- 				uni.navigateTo({
 
- 					url: './medicatedFoodDetails?id=' + item.id
 
- 				})
 
- 			}
 
- 		}
 
- 	}
 
- </script>
 
- <style lang="scss">
 
- 	.top-content{
 
- 		width: 100%;
 
- 		position: fixed;
 
- 		top: 0;
 
- 		left: 0;
 
- 		z-index: 10;
 
- 	}
 
- 	.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;
 
- 			}
 
- 		}
 
- 	}
 
- 	.cate-list{
 
- 		box-sizing: border-box;
 
- 		background: #fff;
 
- 		padding: 10upx 27upx;
 
- 		.inner{
 
- 			display: flex;
 
- 		}
 
- 		.item{
 
- 			flex-shrink: 0;
 
- 			padding: 0 24upx;
 
- 			height: 64upx;
 
- 			line-height: 64upx;
 
- 			font-size: 28upx;
 
- 			font-family: PingFang SC;
 
- 			font-weight: 500;
 
- 			color: #2583EB;
 
- 			background: #ffffff;
 
- 			border: 1px solid #2EDAD4;
 
- 			border-radius: 32upx;
 
- 			margin: 0 20upx 20upx 0;
 
- 			&.active{
 
- 				color: #FFFFFF;
 
- 				background: #2EDAD4;
 
- 				border: 1px solid #2EDAD4;
 
- 			}
 
- 		}
 
- 	}
 
- 	.article-list{
 
- 		padding: 0 10upx;
 
- 		display: flex;
 
- 		align-items: center;
 
- 		justify-content: center;
 
- 		flex-wrap: wrap;
 
- 		.item{
 
- 			width: 50%;
 
- 			box-sizing: border-box;
 
- 			padding: 15upx;
 
- 			display: flex;
 
- 			flex-direction: column;
 
- 			align-items: center;
 
- 			justify-content: space-between;
 
- 			margin-bottom: 20upx;
 
- 			.top{
 
- 				width: 100%;
 
- 				height: 240upx;
 
- 				image{
 
- 					border-radius: 20upx;
 
- 					width: 100%;
 
- 					height: 100%;
 
- 				}
 
- 			}
 
- 			.title{
 
- 				text-align: center;
 
- 				width: 100%;
 
- 				margin-top: 15rpx;
 
- 				font-size: 32upx;
 
- 				font-family: PingFang SC;
 
- 				font-weight: 500;
 
- 				color: #111111;
 
- 			}
 
- 			.desc{
 
- 				text-align: center;
 
- 				width: 100%;
 
- 				margin-top: 15rpx;
 
- 				font-size: 28upx;
 
- 				font-family: PingFang SC;
 
- 				font-weight: 500;
 
- 				color: #999999;
 
- 			}
 
- 			
 
- 		}
 
- 	}
 
- </style>
 
 
  |