<template>
	<view class="">
		<customNav :shownav="true" :title="title" titledetl=""></customNav>
		<view class="contentColumnC" style="margin-top: 16rpx;">
			<view class="item_content" v-for="(item,index) in mendianList" @click="mendianxuanze(item.id)">
				<view class="contentInRowS">
					<netImage width="130" height="130" bradius="65" :mysrc="item.logo" mymode="scaleToFill"></netImage>
					<view class="contentColumn" style="width:520rpx ;">
						<text class="text2row" style="font-size: 30rpx;">{{item.posName}}</text>
						<view class="contentInRowS">
							<text v-if="item.pingf" style="font-size: 26rpx;color: brown;">{{item.pingf}}分</text>
							<text v-if="item.ddsl" style="font-size: 26rpx;color: green;">月售{{item.ddsl}}+</text>
						</view>
						<view class="contentInRowS">
							<text style="font-size: 26rpx;color:dimgrey;">{{item.posPrice}}起送</text>
							<text v-if="item.juli" style="font-size: 26rpx;">距离{{item.juli}}Km</text>
						</view>
						<view class="contentInRowL">
							<text class="notTextA" style="font-size: 28rpx;">新客优惠</text>
							<text class="notTextA" style="font-size: 28rpx;">超好吃</text>
						</view>
					</view>
				</view>
				<view class="">
					<scroll-view scroll-view  scroll-x="true" >
						<view class="item_list">
							<view v-for="(item1, index) in item.foodList">
								<view class="itemA_content">
									<netImage width="130" height="130" :mysrc="item1.image" mymode="scaleToFill"></netImage>
									<view class="contentColumnC title">
										<text class="text2row" >{{item1.name}}</text>
										<text>{{item1.price}}</text>
									</view>
								</view>
							</view>
						</view>
					</scroll-view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>

	import api from "@/pages/api/api.js"
	export default {
		components: {},
		data() {
			return {
				title:'',
				formData: {
					status: 'loading', // 加载状态
				},
				tipShow: false ,// 是否显示顶部提示框
				mendianList:{},
				status:'more',
				loading:true,
				listType:'',
				clickable:true,
				page:1
			};
		},
		onLoad(option) {
			console.log('option',option);
			this.listType=option.listType;
			if(this.listType==1){
				this.title = this.$t('user.wodeshouc');
			}
			else if(this.listType==2){
				this.title = this.$t('user.wodezuji')
			}
		},
		onShow(){
			if(this.listType==1){
				this.page=1;
				this.getcollectlist(1);
			}
			else if(this.listType==2){
				this.page=1;
				this.getuserfootlist(1);
			}
			this.status = 'more';
			this.formData.status = 'loading'
		},
		methods: {
			
			gotoDetail(e){
				console.log(e);
				uni.navigateTo({
					url:'/pages/shanpinxungou/shangjia/merchantdetail?id='+e
				})
			},
			getuserfootlist(page){
				this.tipShow = true;
				var data={
					page:page,
					size:10
				};
				api('getuserfootlist',data,
				r=>{
					console.log('getuserfootlist：',r);
					if(this.page==1){
						this.mendianList=r.data.data.records;
					}
					else{
						if(r.data.data.records.length>0){
							var temp = this.mendianList;
							for(var i=0;i<r.data.data.records.length;i++){
								temp.push(r.data.data.records[i]);
							}
							this.mendianList=temp;
						}
						else{
							this.status = 'noMore';
						}
					}
					uni.stopPullDownRefresh()
					this.tipShow = false
				},failc=>{
					uni.stopPullDownRefresh()
					this.tipShow = false
				})
			},
			getcollectlist(page){
				this.tipShow = true;
				var data={
					page:page,
					size:10
				};
				api('getcollectlist',data,
				r=>{
					console.log('getcollectlist：',r);
					if(this.page==1){
						this.mendianList=r.data.data.records;
					}
					else{
						if(r.data.data.records.length>0){
							var temp = this.mendianList;
							for(var i=0;i<r.data.data.records.length;i++){
								temp.push(r.data.data.records[i]);
							}
							this.mendianList=temp;
						}
						else{
							this.status = 'noMore';
						}
					}
					uni.stopPullDownRefresh()
					this.tipShow = false
				},failc=>{
					uni.stopPullDownRefresh()
					this.tipShow = false
				})
			},
			
		},
		/**
		 * 下拉刷新回调函数
		 */
		onPullDownRefresh() {
			if(this.listType==1){
				this.page=1;
				this.getcollectlist(1);
				this.status = 'more';
			}
			else if(this.listType==2){
				this.page=1;
				this.getuserfootlist(1);
				this.status = 'more';
			}
			this.formData.status = 'loading'
		},
		/**
		 * 上拉加载回调函数
		 */
		onReachBottom() {
			this.page = this.page+1;
			if(this.listType==1){
				this.getcollectlist(this.page);
				//this.status = 'more';
			}
			else if(this.listType==2){
				this.getuserfootlist(this.page);
				//this.status = 'more';
			}
			
		},
	};
</script>

<style lang="scss">
	@import '@/common/uni-ui.scss';

	page {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		background-color: #efeff4;
		min-height: 100%;
		height: auto;
	}
.item_content{
  	background: white;
  	width: 660rpx;
	margin-bottom: 30rpx;
	padding: 16rpx;
	border-radius: 16rpx;
  }
  .item_list{
  	padding-left: 40rpx;
  	display: flex;
  	flex-direction: row;
  	justify-content: flex-start;
  }
  
  .itemA_content{
  	width: 150rpx;
  	height: 220rpx;
  	margin: 16rpx 0;
  	padding: 14rpx;
  	box-sizing: border-box;
  	image{
  		width: 130rpx;
  		height:130rpx;
  		background-color:whitesmoke;
  		display: block;
  	}
  	
  	.title{
  		width: 100%;
  		text-align: center;
  		font-size: 24rpx;
  		line-height: 30rpx;
  		padding-top: 4rpx;
  	}
  }	
</style>