<!-- 折扣卡组件 -->
<template>
	<view class="container" :style="{background:!isdiyPage?'#ffffff':isdiyPageStyle.bgColor,paddingBottom: '1upx'}">
		<view class="disCard1-box b-f dis-flex m-btm20 p-r" v-for="(cardItem,index) in disCardList" :key="index" @click="gourl(cardItem.sid,cardItem)" :class="!isdiyPage?'bor-radius-10upx':''"
		 :style="{padding:!isdiyPage?'20rpx':isdiyPageStyle.padding*2+'rpx',margin:!isdiyPage?'20rpx':isdiyPageStyle.margin*2+'rpx'}">
			<view class="disCard1-left m-right20">
				<view class="disCard-image" :style="{'background-image':'url('+cardItem['logo']+')'}"></view>
			</view>
			<view class="disCard1-right dis-flex flex-dir-column flex-x-between">
				<view>
					<view class="dis-flex flex-x-between flex-y-center" @click="navigateToShop(cardItem.is_link,cardItem['shop_url'])">
						<view class="f-26 disCard1-store onelist-hidden">{{cardItem['name']}}</view>
						<view class="f-24 col-9" v-if="!!cardItem['distance']">{{cardItem['distance']}}</view>
					</view>
					<view class="f-24 disCard-notice-use twolist-hidden">使用须知:{{cardItem['limit']}}</view>
					<view class="dis-flex f-24" style="position: relative;margin-top: 15upx;font-family: '黑体';" v-if="(userinfo.halfcardflag == 0 && platformInfor.newpayonline == 1) ||  !platformInfor.newpayonline">
						<view class="dis-il-block"
						style="background-color: #E8C977;
						height: 40upx;
						line-height: 40upx;
						padding-left: 20upx;
						border-radius: 60upx 0upx 0upx 60upx;
						color: #333333;
						padding: 0 3upx 0 15upx;
						letter-spacing:2upx;
						">
							会员
						</view>
						<view  style="position: relative;">
							<view class="dis-il-block"
							style="width: 0;
							height: 0;
							border-bottom: 40upx solid #E8C977;
							border-right: 8upx solid transparent;
							position: absolute;
							left: 0;">
							</view>
							<view class="dis-il-block" 
							style="width: 0;
							height: 0;
							border-top: 40upx solid #484743;
							border-left: 8upx solid transparent;
							position: absolute;
							left: 0;">
							</view>
						</view>
						<view class="dis-il-block" 
						style="background-color: #484743;
						margin-left: 4upx;
						height: 40upx;
						line-height: 40upx;
						padding-right: 10upx;
						border-radius: 0upx 60upx 60upx 0upx;
						color: #FFFFFF;
						letter-spacing: 2upx;
						padding-left: 4upx;">
							{{cardItem.lowtip==1?'最低立享':'立享'}}
							<text style="font-size: 24upx;">{{!platformInfor.newpayonline ?cardItem['discount']:cardItem.activediscount}}</text>
							折
						</view>
					</view>
				</view>
				<view class="disCard-discount f-36" v-if="platformInfor.newpayonline == 1 && userinfo.halfcardflag == 0 && token">{{cardItem['discount']}}<text class="f-24">折</text></view>
				<view class="disCard-discount f-36" v-if="platformInfor.newpayonline == 1 && userinfo.halfcardflag !== 0 && token">{{cardItem['discount']}}<text class="f-24">折</text></view>
				<!-- <view class="disCard-discount f-36" v-if="">{{cardItem['discount']}}<text class="f-24">折</text></view> -->
				<view class="disCard-discount f-36" v-if="(platformInfor.newpayonline == 1 && !token)">{{cardItem['discount']}}<text class="f-24">折</text></view>
				<view class="disCard-skip-btn col-f f-24 t-c p-r" style="background-color: #FF4444;" @click.stop="navigateTo(cardItem.is_link,cardItem['url'],cardItem)">去买单</view>
			</view>
		</view>
	</view>
</template>
<script>
	import App from '@/common/js/app.js'
	export default {
		data() {
			return {
				platformInfor:{},
				userinfo:{},
				token:''
			}
		},
		components: {

		},
		props: {
			disCardData: {
				type: Object,
				default: function() {
					return {}
				}
			},
			disCardData_two: {
				type: Array,
				default: function() {
					return []
				}
			},
			disCardType: {
				type: String,
				default: function() {
					return ''
				}
			},
			disType: {
				type: Number,
				default: function() {
					return 1
				}
			},
			isdiyPageStyle: {
				type: Object,
				default: function() {
					return {}
				}
			},
			isdiyPage: {
				type: Boolean,
				default: function() {
					return false
				}
			},
			isdiyPageParams: {
				type: Object,
				default: function() {
					return {}
				}
			}
		},
		computed: {
			disCardList() {
				return this.disType === 1 ? this.disCardData['data'] : this.disCardData_two
			}
		},
		onShow() {
			
		},
		mounted() {
			this.platformInfor = uni.getStorageSync('platformInfor');
			// this.platformInfor.newpayonline = 0;
			this.userinfo = uni.getStorageSync('userinfo');
			this.token = uni.getStorageSync('weliam_user_token');
		},
		methods: {
			gourl(sid,item){
				if(this.userinfo.halfcardflag == 0){
					App.showError('对不起，您不符合使用要求');
					return
				}
				if(!sid){
					App.navigationTo({
						url:item.url
					})
				}else{
					App.navigationTo({
							url:'pages/mainPages/store/index?sid=' + sid
					})
				}
				
			},
			navigateToShop(is_link, url) {
				// debugger
				if (is_link === "1") return
				App.navigationTo({
					url
				})
			},
			navigateTo(is_link, url, item) {
				
				if (is_link === "1") {
					if (item.payonline === "1") {
						if(this.platformInfor.newpayonline == 1){
							App.navigationTo({
								url: 'pages/subPages2/newBuyOrder/newBuyOrder?sid=' + item.sid
							});
						}else{
							App.navigationTo({
								url: 'pages/subPages2/newBuyOrder/buyOrder?sid=' + item.sid
							})
						}
					} else {
						App.navigationTo({
							url: 'pages/mainPages/memberCard/memberCard?id=' + item.id + '&type=' + item.type
						})
					}
				} else {
					if(this.userinfo.halfcardflag == 0){
						App.showError('对不起，您不符合使用要求');
						return
					}
					// if(url.indexOf('buyOrder') === -1){
						App.navigationTo({
							url
						})
					// }else{
						// App.navigationTo({
						// 	url: 'pages/subPages2/newBuyOrderOrder?sid=' + item.sid
						// });
					// }
					
				}
			}
		}
	}
</script>


<style lang="scss" scoped>
	.disCard1-box:last-child{
		// margin-bottom: 0 !important;
		// margin: 0 30upx 30upx;
	}
	.disCard1-left {
		.disCard-image {
			width: 200upx;
			height: 200upx;
			background-repeat: no-repeat;
			background-position: center;
			background-size: 200upx 200upx;
			flex-shrink: 0;
			border-radius: 10upx;
		}
	}

	.disCard1-right {
		flex: 1;

		.disCard1-store {
			width: 300upx;
		}

		.disCard-notice-use {
			color: #bdbdbd;
		}

		.disCard2-notice-use {
			width: 300upx;
		}

		.disCard-discount {
			color: #ff3f43;
		}

		.disCard-skip-btn {
			position: absolute;
			right: 20upx;
			bottom: 24upx;
			width: 130upx;
			height: 50upx;
			line-height: 50upx;
			border-radius: 10upx;
		}

		.disCard2-skip {
			position: absolute;
			right: 0;
			bottom: 20upx;
		}

		.disCard2-skip-btn {
			width: 70upx;
			border-radius: 50%;
			height: 70upx;
			background: #d83a3a;
			color: #FFF;
			padding: 10upx;
		}
	}
</style>
