<template>
	<view >
		<customNav  :shownav="true" showfanhui="1" :title="$t('index.wodemendian')" titledetl="" addBT='1' v-on:Enavbarsel="addmendian"></customNav>
		<view style="margin-top: 50rpx;background-color:bisque;" v-for="(item,index) in mendianList">
			<view class="buyct" @click="gotomendian(item.id)">
				<netImage width="120" height="120" bradius="60" :mysrc="item.logo" mymode="scaleToFill"></netImage>
				<view class="msText">
					<text class="dianpuming">{{item.posName}}</text>
					<view class="buyBT">
						<image class="xingxing" src="/static/images/xingxing@3x.png" mode="aspectFit"></image>
						<text class="pingfentext">4.9</text>
						<text class="mainyuntishi">{{$t('index.manX')}} {{$formPr(item.posPrice)}}{{$t('locale.huobidw')}}</text>
					</view>
					<view class="buyBT">
						<text class="shijiantishi">{{$t('mend.waisongsj')}}</text>
					</view>
				</view>
			</view>
			<view @click="gotomendian(item.id)">
				<imageconver :isremen="true" :isyouhui="false" :youhuinote="''" class="mainimage" :imagSrc="item.image"></imageconver>
			</view>
			
		</view>
	</view>
</template>

<script>

	import api from "@/pages/api/api.js"
	export default {
		components: {},
		data() {
			return {
				// 数据表名
				//collection: 'opendb-mall-goods',
				// 查询字段，多个字段用 , 分割
				//field: 'goods_thumb,name,goods_tip,tag,goods_price,comment_count,month_sell_count,shop_name',
				formData: {
					status: 'loading', // 加载状态
				},
				tipShow: false ,// 是否显示顶部提示框
				data:[],
				mendianList:{},
				status:'noMore',
				loading:true,
				latitude:0,
				longitude:0,
				typeID:'',
				clickable:true,
				isLogin:false
			};
		},
		onShow() {
			
			var token = uni.getStorageSync("token");
			
			if(token == '' || token == undefined || token == null){
				// uni.navigateTo({
				// 	url:'/pages/UserCenter/LoginView'
				// })
				this.mendianList=[];
				this.isLogin=false;
				return;
			}
			else{
				this.isLogin=true;
			}
			
			this.getMymendianlist();
			this.formData.status = 'loading'
		},
		methods: {
			addmendian(){
				if(!this.isLogin){
					uni.navigateTo({
						url:'/pages/UserCenter/LoginView'
					})
					return;
				}
				uni.navigateTo({
					url:'/pages/UserCenter/mendian/addmendian'
				})
			},
			gotomendian(e){
				
				uni.navigateTo({
					url:'/pages/shanpinxungou/shangjia/merchantdetail?id='+e
				})
			},
			getMymendianlist(){
				//this.formData.status = 'more'
				this.tipShow = true
				
				api('getMymendianlist',{
				},
				r=>{
					console.log(r);
					this.mendianList=r.data.data;
					console.log(this.mendianList);
					uni.stopPullDownRefresh()
					this.tipShow = false
				},failc=>{
					//console.log('getadvertis----',failc)
					uni.stopPullDownRefresh()
					this.tipShow = false
				});
			},
			// changeState(medObj){
			// 	var strMsg='';
			// 	var state=0;
			// 	if(medObj.state==1){
			// 		strMsg=this.$t('mend.kaishiyy');
			// 		state=0;
			// 	}
			// 	else{
			// 		strMsg=this.$t('mend.dayang');
			// 		state=1;
			// 	}
			// 	var that = this;
			// 	uni.showModal({
			// 	    title: this.$t('api.message'),
			// 	    content: strMsg,
			// 		cancelText: that.$t('order.quxiao'), // 取消按钮的文字
			// 		confirmText: that.$t('comp.queren'), // 确认按钮的文字 
			// 	    success: function (res) {
			// 			if (res.confirm) { //这里是点击了确定以后
			// 				that.$http.post(`${addmendian}`, {
			// 					"id":medObj.id,
			// 					"state":state
			// 				},false)
			// 				.then(r => {
			// 					console.log(r)
			// 					that.getMymendianlist();
			// 				})
			// 				.catch(err => {
			// 					console.log(err)
			// 				})
			// 			} else { //这里是点击了取消以后
			// 			  console.log('用户点击取消')
			// 			}
						
			// 	    }
			// 	})
			// },
		},
		/**
		 * 下拉刷新回调函数
		 */
		onPullDownRefresh() {
			this.getmendianlist(1);
			this.$refs.udb.loadData({
				clear: true
			}, () => {
				this.tipShow = true
				clearTimeout(this.timer)
				this.timer = setTimeout(()=>{
					this.tipShow  = false
				},1000)
				uni.stopPullDownRefresh()
			})
		},
	};
</script>

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

.buyct{
	margin-top: 20rpx;
	height: 140rpx;
	padding: 14rpx;
	display: flex;
	flex-direction: row;
	background-color:white;
}
.msText{
	width: 530rpx;
	padding-left: 10rpx;
	font-size: 22rpx;
	line-height: 32rpx;
}
.dianpuming{
	font-size: 30rpx;
	line-height: 32rpx;
	font-weight: bold;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}
.xingxing{
	width: 40rpx;
	height: 40rpx;
}
.pingfentext{
	font-size: 26rpx;
	line-height: 40rpx;
	height: 40rpx;
	color:sandybrown;
}
.mainyuntishi{
	margin-left: 30rpx;
	padding-left: 8rpx;
	padding-right: 8rpx;
	font-size: 26rpx;
	line-height: 40rpx;
	height: 40rpx;
	color: dimgray;
	background-color: burlywood;
	border-radius: 4rpx;
}
.shijiantishi{
	margin-left: 30rpx;
	font-size: 26rpx;
	line-height: 40rpx;
	height: 40rpx;
	color: dimgray;
}
.mainimage{
	width: 100%;
	height: 330rpx;
	display: block;
	border-radius: 0rpx;
}
		
</style>


