<template>
	<view>
		<view class="feedback-title">
			<view class="content">
				<view class="title">请选择问题反馈类型：</view>
				<view class="choicebox">
					<view class="choices ">
						<view style="float: left;margin-right: 10px;"  v-for="(item,index) in choicelist" class="a"
							:key="index" :class="{changeStyle:changeSelectStyle == index}"  @click="changeStyle(index)">
							{{item.name}}
						</view>
					</view>
				</view>
				<view style="height: 0px;border: 1px solid rgba(112, 112, 112, 0.10980392156862745);">
				</view>
				<view>
					<textarea auto-height placeholder="请填写15字以上的内容描述，我们将尽快给您回复" v-model="text"
						placeholder-style="font-size: 12px;font-family: PingFang SC;font-weight: 400;color: #999999;" />
				</view>
			</view>

			<!-- <text @tap="chooseMsg">快速键入</text> -->
		</view>
		<!-- <view class="feedback-body"><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 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 type="primary" class="button" @tap="send">提交</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				msgContents: ['界面显示错乱', '启动缓慢，卡出翔了', 'UI无法直视，丑哭了', '偶发性崩溃'],
				stars: [1, 2, 3, 4, 5],
				imageList: [],
				sendDate: {
					score: 5,
					content: '',
					contact: ''
				},
				text: '',
				choicelist: [{
						"name": "其他反馈"
					},
					{
						"name": "优化建议"
					},

				],
				changeSelectStyle: '',
				isshow: true
			};
		},
		// onLoad() {
		// 	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);
			},
			changeStyle(index) {
				this.changeSelectStyle = index;
			},
			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);
					}
				});
			},
			chooseStar(e) {
				//点击评星
				this.sendDate.score = e;
			},
			previewImage() {
				//预览图片
				uni.previewImage({
					urls: this.imageList
				});
			},
			send() {
				//发送反馈
				console.log(JSON.stringify(this.sendDate));

				if (!this.sendDate.content) {
					uni.showToast({
						icon: 'none',
						title: '请输入反馈内容'
					});
					return;
				}
				if (!this.sendDate.contact) {
					uni.showToast({
						icon: 'none',
						title: '请填写QQ或邮箱'
					});
					return;
				}
				// uni.report('意见反馈', this.sendDate);
				this.$queue.showLoading('加载中...');
				this.$Request
					.postJson('/message/add', {
						state: 2,
						title: this.sendDate.contact,
						content: JSON.stringify(this.sendDate)
					})
					.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>
	page {
		background-color: #F6F6F6;
	}

	.feedback-title {
		height: 200px;
		background: #FFFFFF;
		opacity: 1;
		border-radius: 6px;
		margin: 0 16px;
		margin-top: 16px;
	}

	.feedback-title .content {
		margin: 0 16px;
	}

	.feedback-title .title {
		padding-top: 12px;
		margin-bottom: 8rpx;
		font-size: 14px;
		font-family: PingFang SC;
		font-weight: 400;
		color: #000000;
	}




	.feedback-submit {
		background: #007aff;
		color: #ffffff;
		margin: 20upx;
	}

	.choicebox {
		height: 32px;
	}

	.choices {
		padding-top: 10px;
		margin-bottom: 8px;
	}

	 .a {
		background: #F5F5F5;
		border: 1px solid #999999;
		opacity: 1;
		border-radius: 2px;
		color: #999999;
	}

	.button {
		width: 120px;
		height: 24px;
		background: linear-gradient(141deg, #FF4848 0%, #FF2929 100%);
		opacity: 1;
		border-radius: 12px;
		font-size: 11px;
		font-family: PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		padding-top: 4px;
		padding-left: 50px;
		margin: 0 auto;
		margin-top: 10px;
	}

	.changeStyle {
		background: #F8E3DF;
		border: 1px solid #FF6A6A;
		opacity: 1;
		border-radius: 2px;
		color: #FF7171;
	}
</style>
