<template>
	<view>
		<view class="hm-header-xian"></view>
		<view v-if="order" class="hm-p-20 hm-text-center hm-bg-f">
			<view>{{order.shop.shop_name}}</view> 
			<view class="hm-font-24 hm-col-tips">{{order.create_time}}</view>
		</view>
		<view class="hm-p-lr-20 hm-m-t-20">
			<view class="hm-p-20 hm-br-8 hm-bg-f">
				<view class="hm-p-b-20 hm-border-b">
					服务
					<view class="hm-dis-block-inline hm-m-l-10">
						<u-rate :value="serve" size="26" activeColor="#FF9900" inactiveColor="#909399" allowHalf></u-rate>
					</view>
					<view class="hm-col-tips hm-font-24 hm-p-t-20">小主觉得商家的整体服务怎样？</view>
				</view>
				<view class="hm-p-tb-20 hm-border-b">
					速度
					<view class="hm-dis-block-inline hm-m-l-10">
						<u-rate :value="speed" size="26" activeColor="#FF9900" inactiveColor="#909399" allowHalf></u-rate>
					</view>
					<view class="hm-col-tips hm-font-24 hm-p-t-20">整体的起菜或配送速度如何呢？</view>
				</view>
				<view class="hm-p-tb-20 hm-border-b">
					口味
					<view class="hm-dis-block-inline hm-m-l-10">
						<u-rate :value="flavor" size="26" activeColor="#FF9900" inactiveColor="#909399" allowHalf></u-rate>
					</view>
					<view class="hm-col-tips hm-font-24 hm-p-t-20">我们大厨的手艺还可以吗？</view>
				</view>
				<view class="hm-p-tb-20 hm-border-b">
					卫生
					<view class="hm-dis-block-inline hm-m-l-10">
						<u-rate :value="ambient" size="26" activeColor="#FF9900" inactiveColor="#909399" allowHalf></u-rate>
					</view>
					<view class="hm-col-tips hm-font-24 hm-p-t-20">场所环境、卫生、包装情况您满意吗？</view>
				</view>
				<view class="hm-p-t-20">
					<u--textarea v-model="content" border="none" count placeholder="小主有其它意见和建议，都可以给我们留言哦~我们一定会认真反馈的！" ></u--textarea>
				</view>
			</view>
			<view class="hm-m-t-50 hm-p-lr-b25 hm-text-center">
				<u-button @click="formSubmit" type="success" :disabled="disabled" :loading="loading" text="提交"></u-button>
			</view>
		</view>
		<!-- 技术支持 -->
		<view class="hm">
			{{applet.copyright}} <text class="v">V{{applet.version}}</text>
		</view>
	</view>
</template>

<script>
	let App = getApp();

	export default {
		data() {
			return {
				applet:{},
				order_id: null,
				order: null,
				serve: 5, //服务评分
				speed: 5, //速度评分
				flavor: 5, //口味评分
				ambient: 5, //环境评分	
				content: '', //评价内容
				disabled:false,
				loading:false,
			};
		},

		components: {},
		props: {},

		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad: function(options) {
			let _this = this;
			_this.order_id = options.id;
			_this.applet = uni.getStorageSync('applet');
			_this.getOrderDetail();
		},
		methods: {
			/**
			 * 提交评论
			 */
			formSubmit() {
				let _this = this;
				_this.disabled = true;
				_this.loading = true;
				App._post_form('user.comment/add', {
					serve: _this.serve,
					speed: _this.speed,
					flavor: _this.flavor,
					ambient: _this.ambient,
					order_id: _this.order_id,
					content: _this.content
				}, function(result) {
					App.showSuccess(result.msg, function() {
						uni.navigateBack(); //返回上一页
					});
				}, false, function() {});
			},

			/**
			 * 获取订单详情
			 */
			getOrderDetail: function() {
				let _this = this;
				App._get('user.order/detail', {
					order_id:_this.order_id
				}, function(result) {
					_this.setData(result.data);
				});
			}
		}
	};
</script>
<style>
	textarea{
		background-color: #f2f2f2;
		padding: 20rpx;
		border-radius: 8rpx;
	}
</style>
