<style lang="scss" scoped>
	.title{ padding:30rpx 20rpx; border-bottom:1px solid #f1f1f1; display:flex; align-items: center;
	   image{width:40rpx; height:40rpx; margin-right:15rpx;}
				view{ color:$main-color; font-weight: bold; label{ font-weight: normal; font-size:28rpx; color:#bfbfbf; padding-left:12rpx;}}
	}
	.banner{height:400rpx;
	  .swiper-item{ height:400rpx; display:flex;}
	}
	.line{ height:15rpx; background:#f1f1f1;}
	.pdbox{ padding:30rpx 20rpx; line-height:40rpx; rich-text{ margin-bottom:15rpx; line-height:1.8em; color:#666;}
			.price{color:red; padding-top:10rpx;}
			.tit{ font-weight: bold; font-size:35rpx;}
	}
	.dbbuy{ position:fixed; height:80rpx; width:100%; left:0; bottom:0; z-index:22; background:#fff; display:flex;
	  view{ flex:1; height:80rpx; line-height:80rpx; text-align: center; color:#fff;}
			.fl{ background-image: linear-gradient(45deg, #0d93f0, #1fc2f8); }
			.fr{ background-image: linear-gradient(45deg, #fc7e52, #fb2e0c); }
	}
</style>
<template>
	 <view>
			 <swiper class="banner" autoplay indicator-dots=true  indicator-active-color="#01adec">
			 	<block v-for="(item, index) in image" :key="index">
			 		<swiper-item >
			 			<view class="swiper-item"><image :src="item" /></view>
			 		</swiper-item>
			 	</block>
			 </swiper>
				<view class="pdbox">
					 <view class="tit">{{info.title}}</view>
						<view class="price" v-if="info.price==null">价格：0.00</view>
						<view class="price" v-else>价格：{{info.price}}</view>
				</view>
				<view class="line"></view>
				<view class="title"><view>详细描述</view></view>
				<view class="pdbox">
					 <rich-text :nodes="info.content"></rich-text>
				</view>
				<view style="height:90rpx;"></view>
				<view class="dbbuy">
					 <view class="fl" @tap="gohome">返回首页</view>
						<view class="fr" @tap="buy">立即购买</view>
				</view>
		</view>
</template>

<script>
	export default{
		  data(){
					  return{
									 id:'',
								  image:[],
										info:{},
							}
				},
				onLoad(e){
					 this.id = e.id;
						this.getOne();
				},
				methods:{
					  async getOne(){
					  	  const json = await this.api.getOne({q:{id:this.id}})
					  			if(json.data.code==0){						  
					  					this.info = json.data.data;
												this.image = this.info.image;
					  			}
					  },
							
							gohome(){
								uni.switchTab({url:'/pages/index/index'})
							},
							
							async buy(){
								 let info = await uni.getStorage({key:'userInfo'});
									if (typeof(info[1]) == 'undefined') {
										 this.util.goLogin();
									} else {
								   this.api.go('/pages/product/confirm?id='+this.info.id);
									}
							}
							
				}
	}
</script>

<style>
</style>
