<template>
	<view class="contentbg">
		<customNav :shownav="true" :title="$t('index.pinglun')" titledetl=""></customNav>
		<view class="xuanxing">
			<image class="buyimage" src="/static/logo.png" mode="aspectFit"></image>
			<label class="xuanxingtext">{{$t('index.zonghepf')}}</label>
			<uni-rate class="rateV" allow-half v-model="rateValue" @change="onChange" />
		</view>
		<textarea class="pinglun"  :value="pinglunnr" :placeholder="$t('index.qingshuru')" @input="sumfontnum"></textarea>
		<view class="text2">
			<text class="">{{fontNum}}/150</text>
		</view>
		<checkbox-group class="radio" @change="checkSelect" >
		    <checkbox :checked="checkTrue"></checkbox>
		        <text>{{$t('index.nimingpj')}}</text>
		</checkbox-group>
		<view class="updata" @click="updata()">{{$t('order.fabiaopinglun')}}</view>

		
	</view>
</template>

<script>

	import api from "@/pages/api/api.js"
	export default {
		data() {
			return {
				fontNum:0,
				rateValue: 3.5,
				checkTrue: false, //全选选中
				pinglunnr:'',
				mendid:'',
				ddId:''
			}
		},
		onLoad(option) {
			this.mendid=option.mendid;
			this.ddId=option.ddId;
		},
		methods: {
			// 限制文本框字数
			sumfontnum(e) {
				console.log(e)
				this.fontNum = e.detail.value.length
				this.pinglunnr = e.detail.value;
				console.log(this.pinglunnr)
			},
			onChange(e) {
				this.rateValue=e.value;
				console.log(this.rateValue);
			},
			checkSelect(e){
				
			},
			updata(){
				//发表评论
				this.addrevew();
			},
			
			addrevew(){
				api('addrevew',{
					"ddId": this.ddId,
					"mdId": this.mendid, 
					"score": this.rateValue, 
					"content":this.pinglunnr, 
					"anonymous": 1 
				},res=>{
					console.log('getHours',res)
					uni.navigateBack();
				},failc=>{
					//console.log('getadvertis----',failc)
				})
			},

		}
	}
</script>

<style>
	.contentbg{
		
	}
	.xuanxing{
		margin: 16rpx;
		display: flex;
		flex-direction: row;
	}
	.buyimage{
		width: 100rpx;
		height: 100rpx;
	}
	.xuanxingtext{
		padding-left:10rpx;
		height: 100rpx;
		line-height: 100rpx;
	}
	.rateV{
		padding-top:25rpx;
		padding-left:10rpx;
	}
	
	
	.pinglun{
		margin: 16rpx;
		padding: 10rpx;
		width: 91%;
		height: 200rpx;
		border-radius: 15rpx;
		border: 2rpx solid darkgray;
	}
	.text2{
		height: 30rpx;
		line-height: 30rpx;
	    color: #000000;
		font-size: 20rpx;
		margin-right: 30rpx;
		display: flex;
		justify-content:flex-end;
	}
	
	.updata{
		background-color: green;
		color: white;
		text-align: center;
		height: 80rpx;
		line-height: 80rpx;
		width: 80%;
		margin-left: 10%;
		border-radius: 15rpx;
	}
	
	.radio{
		margin: 16rpx;
		display: flex;
		flex-direction: row;
	}
	

</style>
