<template>
	<!-- style="background: #FFFFFF;" -->
	<view class="page" style="background: #f0f0f0; padding-top: 7rpx;">
		<!-- <view class="feedback-title">
			<view>问题和意见</view>
			<view class="feedback-quick" @tap="chooseMsg">
				<text>快速键入</text>
				<u-icon name="arrow-right"></u-icon>
			</view>
、
		</view> -->
		<view style="background: #FFFFFF;" class="feedback-body">
			<view class="flex align-center padding-tb-sm">
				<view>
					<image v-if="globalImages" :src="globalImages + 'images/order/tiem.png'" style="width: 100rpx;height: 100rpx;" mode=""></image>
				</view>
				<view style="margin-left: 30rpx; line-height: 40rpx;">
					<view style="color: #999;">司机师傅</view>
					<view>什么时间段的订单</view>
				</view>
			</view>
			<view class="flex align-center add_name" style="margin: 30rpx 0rpx 4rpx;">
				<view class="green"></view>出发地点：12312
			</view>
			<image v-if="globalImages" :src="globalImages + 'images/static/upload/up.png'" class="order_up"></image>
			<view class="flex align-center add_name">
				<view class="orgin"></view>到达地点：111111
			</view>
		</view>
		<view style="background: #FFFFFF;" class="feedback-body">
			<view class="titls" style="text-align: center;">
				为本次服务评分
			</view>
			<view style="display: flex; justify-content: center; margin-bottom: 30rpx;">
				<u-rate :allow-half="false" :disabled="true" size="58" active-color="#fe6b01" :is-fill="false" :value="3.5" />
			</view>
			<view style="font-size: 24rpx;color: #ccc;text-align: center;">点击星星评分</view>
		</view>
		<view style="background: #FFFFFF;margin-top: 30rpx;" class="feedback-body">
			<view class="titls">
				快速评价
			</view>
			<view class="flex-container">
				<view class="item"><image v-if="globalImages" :src="globalImages + 'images/evaluate/icon_1.png'" style="width: 25rpx;height: 25rpx; margin-right: 10rpx;" mode=""></image>车内整洁</view>
				<view class="item"><image v-if="globalImages" :src="globalImages + 'images/evaluate/icon_2.png'" style="width: 25rpx;height: 25rpx; margin-right: 10rpx;" mode=""></image>礼貌热情</view>
				<view class="item"><image v-if="globalImages" :src="globalImages + 'images/evaluate/icon_3.png'" style="width: 25rpx;height: 25rpx; margin-right: 10rpx;" mode=""></image>准时到达</view>
				<view class="item"><image v-if="globalImages" :src="globalImages + 'images/evaluate/icon_4.png'" style="width: 25rpx;height: 25rpx; margin-right: 10rpx;" mode=""></image>乐于助人</view>
				<view class="item"><image v-if="globalImages" :src="globalImages + '/images/evaluate/icon_5.png'" style="width: 25rpx;height: 25rpx; margin-right: 10rpx;" mode=""></image>驾驶平稳</view>
		  </view>
		</view>
		<view style="background: #FFFFFF;" class="feedback-body">
			<view class="titls">
				详细评价
			</view>
			<textarea placeholder="说说这次乘车体验吧..." v-model="sendDate.content" class="feedback-textare" />
		</view>
		<!-- <view class="feedback-title"><text>QQ/邮箱</text></view> -->
		<!-- <view class="feedback-body"><input class="feedback-input" v-model="sendDate.contact" placeholder="方便我们联系你 " />
		</view> -->
	<!-- 	<view class="feedback-title feedback-star-view">
			<text>我的评价:</text>
			<view style="margin-left: 20rpx;">
				<u-radio-group v-model="value" @change="radioGroupChange">
					<u-radio @change="radioChange" v-for="(item, index) in list" :key="index" :name="item.id"
						:disabled="item.disabled" active-color="#346EF6">
						{{item.name}}
					</u-radio>
				</u-radio-group>
			</view>
			<view class="feedback-star-view">
				<text class="feedback-star" v-for="(value, key) in stars" :key="key" :class="key < sendDate.score ? 'active' : ''" @tap="chooseStar(value)"></text>
			</view>
		</view> -->
		
		<view style="text-align: center; color: #999;">
			<view style="font-size: 24rpx;">评价信息仅供平台服务改进使用</view>
			<view style="font-size: 24rpx;">双峰均不可见具体评价内容</view>
		</view>
		<button type="primary" style="background: #fe6b01; margin-bottom: 30rpx;" class="feedback-submit" @tap="send">提交评价</button>
	</view>
</template>

<script>
	import { waitForGlobalImages } from '@/utils/globalImageLoader'
	export default {
		data() {
			return {
				msgContents: ['界面显示错乱', '启动缓慢，卡出翔了', 'UI无法直视，丑哭了', '偶发性崩溃'],
				// stars: [1, 2, 3, 4, 5],
				// count: 5,
				// value: 0,
				list: [{
					id: 0,
					name: '满意',
					disabled: false
				}, {
					id:1,
					name: '不满意',
					disabled: false
				}],
				// u-radio-group的v-model绑定的值如果设置为某个radio的name，就会被默认选中
				value: 0,
				imageList: [],
				sendDate: {
					score: 0,
					content: '',
					contact: ''
				},
				riderUserId: '',
				satisfactionFlag: '',
				globalImages: ''
			};
		},
		onLoad(e) {
			waitForGlobalImages().then((path) => {
			    console.log('✅ 全局图片路径:', path)
			    this.globalImages = path
			  })
			console.log(e)
			this.riderUserId = e.riderUserId
			this.indentNumber = e.indentNumber
			// console.log(this.riderUserId,'........',this.indentNumber)
			// let deviceInfo = {
			// 	appid: plus.runtime.appid,
			// 	imei: plus.device.imei, //设备标识
			// 	p: plus.os.name === 'Android' ? 'a' : 'i', //平台类型，i表示iOS平台，a表示Android平台。
			// 	md: plus.device.model, //设备型号
			// 	app_version: plus.runtime.version,
			// 	plus_version: plus.runtime.innerVersion, //基座版本号
			// 	os: plus.os.version,
			// 	net: '' + plus.networkinfo.getCurrentType()
			// };
			// this.sendDate = Object.assign(deviceInfo, this.sendDate);
		},
		methods: {
			close(e) {
				this.imageList.splice(e, 1);
			},
			chooseMsg() {
				//快速输入
				uni.showActionSheet({
					itemList: this.msgContents,
					success: res => {
						this.sendDate.content = this.msgContents[res.tapIndex];
					}
				});
			},
			chooseImg() {
				//选择图片
				uni.chooseImage({
					sourceType: ['camera', 'album'],
					sizeType: 'compressed',
					count: 8 - this.imageList.length,
					success: res => {
						this.imageList = this.imageList.concat(res.tempFilePaths);
					}
				});
			},
			// 选中某个单选框时，由radio时触发
			radioChange(e) {
				console.log(e);
				if (this.value == "满意" && e == "满意") {
					this.satisfactionFlag = 1
				} else if (this.value == '不满意' && e == "不满意") {
					this.satisfactionFlag = 2
				}
			},
			// 选中任一radio时，由radio-group触发
			radioGroupChange(e) {
				// console.log(e);
			},
			// chooseStar(e) {
			// 	//点击评星
			// 	this.sendDate.score = e;
			// },
			// previewImage() {
			// 	//预览图片
			// 	uni.previewImage({
			// 		urls: this.imageList
			// 	});
			// },
			send() {
				//发送反馈
				// console.log(JSON.stringify(this.sendDate), '11111');

				if (!this.sendDate.content) {
					uni.showToast({
						icon: 'none',
						title: '请输入反馈内容'
					});
					return;
				}
				// if (this.value = 0) {
				// 	uni.showToast({
				// 		icon: 'none',
				// 		title: '请评论是否满意'
				// 	});
				// 	return;
				// }
				// uni.report( this.sendDate,'意见反馈');
				// console.log("uni.report( '意见反馈',this.sendDate)", uni.report('意见反馈', this.sendDate))
				uni.report('意见反馈', this.sendDate);
				console.log(this.indentNumber, this.satisfactionFlag)
				this.$queue.showLoading('加载中...');
				this.$Request
					.postJson('/app/indent/userEvaluate', {
						// state: this.value,
						// title: this.sendDate.contact,
						// evaluateMessage: JSON.stringify(this.sendDate.content),
						evaluateMessage: this.sendDate.content,
						// riderUserId: this.riderUserId,
						indentNumber: this.indentNumber,
						satisfactionFlag: this.value
					})
					.then(res => {
						if (res.code == 0) {
							uni.showToast({
								title: '评论成功'
							});
							setTimeout(function() {
								uni.navigateBack();
							}, 1000);
						} else {
							uni.hideLoading();
							uni.showModal({
								showCancel: false,
								title: '评论失败',
								content: res.msg
							});
						}
					});
			}
		}
	};
</script>

<style>
	/* @font-face {
		font-family: uniicons;
		font-weight: normal;
		font-style: normal;
		src: url('https://img-cdn-qiniu.dcloud.net.cn/fonts/uni.ttf') format('truetype');
	} */

	page {
		background-color: #FFFFFF;
	}

	view {
		font-size: 28upx;
	}

	.input-view {
		font-size: 28upx;
	}

	.close-view {
		text-align: center;
		line-height: 14px;
		height: 16px;
		width: 16px;
		border-radius: 50%;
		background: #ff5053;
		color: #ffffff;
		position: absolute;
		top: -6px;
		right: -4px;
		font-size: 12px;
	}

	/* 上传 */
	.uni-uploader {
		flex: 1;
		flex-direction: column;
	}

	.uni-uploader-head {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
	}

	.uni-uploader-info {
		color: #b2b2b2;
	}

	.uni-uploader-body {
		margin-top: 16upx;
	}

	.uni-uploader__files {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
	}

	.uni-uploader__file {
		margin: 10upx;
		width: 210upx;
		height: 210upx;
	}

	.uni-uploader__img {
		display: block;
		width: 210upx;
		height: 210upx;
	}

	.uni-uploader__input-box {
		position: relative;
		margin: 10upx;
		width: 208upx;
		height: 208upx;
		border: 2upx solid #d9d9d9;
	}

	.uni-uploader__input-box:before,
	.uni-uploader__input-box:after {
		content: ' ';
		position: absolute;
		top: 50%;
		left: 50%;
		-webkit-transform: translate(-50%, -50%);
		transform: translate(-50%, -50%);
		background-color: #d9d9d9;
	}

	.uni-uploader__input-box:before {
		width: 4upx;
		height: 79upx;
	}

	.uni-uploader__input-box:after {
		width: 79upx;
		height: 4upx;
	}

	.uni-uploader__input-box:active {
		border-color: #999999;
	}

	.uni-uploader__input-box:active:before,
	.uni-uploader__input-box:active:after {
		background-color: #999999;
	}

	.uni-uploader__input {
		position: absolute;
		z-index: 1;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		opacity: 0;
	}

	/*问题反馈*/
	.feedback-title {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		padding: 20upx;
		color: #8f8f94;
		font-size: 28upx;
	}

	.feedback-star-view.feedback-title {
		justify-content: flex-start;
		margin: 0;
	}

	.feedback-quick {
		/* position: relative; */
		/* padding-right: 40upx; */
	}

	/* .feedback-quick:after {
		font-family: uniicons;
		font-size: 40upx;
		content: '\e581';
		position: absolute;
		right: 0;
		top: 50%;
		color: #bbb;
		-webkit-transform: translateY(-50%);
		transform: translateY(-50%);
	} */

	.feedback-body {
		font-size: 32upx;
		padding: 30upx;
		margin: 30upx 30upx;
		border-radius: 16upx;
		background: #F8F8F8;
	}

	.feedback-textare {
		height: 200upx;
		font-size: 24upx;
		line-height: 50upx;
		width: 100%;
		box-sizing: border-box;
		padding:20upx 20upx 0;
		border: #e4e7ed 1rpx solid;
		background: #f5f5f5;
		border-radius: 15rpx;
	}

	.feedback-input {
		font-size: 32upx;
		height: 60upx;
		padding: 15upx 20upx;
		line-height: 60upx;
	}

	.feedback-uploader {
		padding: 22upx 20upx;
	}

	.feedback-star {
		font-family: uniicons;
		font-size: 40upx;
		margin-left: 6upx;
	}

	.feedback-star-view {
		margin-left: 20upx;
	}

	.feedback-star:after {
		content: '\e408';
	}

	.feedback-star.active {
		color: #ffb400;
	}

	.feedback-star.active:after {
		content: '\e438';
	}

	.feedback-submit {
		background: #007aff;
		color: #ffffff;
		margin: 20upx;
	}
	
	.titls {
		font-size: 32rpx;
		font-family: PingFang SC;
		color: #333333;
		padding-bottom: 30rpx;
	}
	
	.order_up {
		width: 6rpx;
		height: 24rpx;
		margin-left: 6rpx;
	}
	
	.add_name {
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 28rpx;
		color: #1F1F1F;
	}
	
	.green {
		width: 16rpx;
		height: 16rpx;
		background: #1FC657;
		border-radius: 50%;
		margin-right: 20rpx;
	}
	
	.orgin {
		width: 16rpx;
		height: 16rpx;
		background: #FBAC04;
		border-radius: 50%;
		margin-right: 20rpx;
	}
	
	.flex-container {
	  display: flex;
	  flex-wrap: wrap; /* 允许换行 */
	}
	
	.item {
	  flex-basis: calc(33.33% - 30rpx);
	  text-align: center;
	  border-radius: 8rpx;
	  border: 1px solid #999; /* 为了便于观察布局，添加边框 */
	  padding: 10rpx 15rpx;
	  margin: 15rpx 10rpx;
	  line-height: 50rpx;
	}
</style>
