<template>
	<view class="content">
		<view class="centerbox">
			<u--form labelPosition="left" :model="dataForm" :rules="rules" ref="uForm">
				<view class="view-class">
					<u-form-item :label="$t('S_L_16')" @click='selectShow = true' label-width="150rpx" prop="type">
						<u--input :readonly='true' v-model="dataForm.typeName" suffixIcon="arrow-down"
							:placeholder="$t('CK_KS_38')">
						</u--input>

					</u-form-item>
				</view>
				<view class="view-class">
					<u-form-item :label="$t('S_L_15')" label-width="150rpx" prop="idea">
						<u--textarea v-model="dataForm.idea" :placeholder="$t('S_C_70')"></u--textarea>
					</u-form-item>
				</view>
			</u--form>
		</view>
		<view class="bottombtn">
			<u-button @click="submit" :text="$t('S_L_17')" color="#D61820"></u-button>
		</view>
		<u-picker @cancel='selectShow=false' :show="selectShow" ref="uPicker" :columns="typeList" @confirm="confirm"
			keyName='label'></u-picker>
	</view>
</template>

<script>
	import * as sid from '@/config/balance.js'
	export default {
		data() {
			return {
				dataForm: {
					type: "",
					idea: "",
					typeName: ""
				},
				rules: {
					type: [{
						// 必填项
						required: true,
						// 提示内容（会出现在u-form-item内的底部）
						message: this.$t('CK_KS_38'),
					}],
					idea: [{
						// 必填项
						required: true,
						// 提示内容（会出现在u-form-item内的底部）
						message: this.$t('S_C_70'),

						trigger: ["change"],
					}],
				},
				selectShow: false,
				typeList: [],

			}
		},
		onLoad() {
			this.getData()
		},
		methods: {
			submit() {
				this.$refs.uForm.validate().then((res) => {
					sid.saveFeedBack(this.dataForm).then((res) => {
						if (res.code == 200) {

							uni.showToast({
								title: res.msg,
								icon: 'none',

							})
							// uni.setStorageSync('isTab', 3);
							uni.$emit('tabChange', 3);
							// 跳转到tabbar页面
							setTimeout(() => {
								uni.switchTab({
									url: '/pages/email/index'
								})
							}, 100)
							// this.$refs.uForm.resetFields()
							// this.$refs.uForm.clearValidate()
						}
					})
				})
			},
			confirm(e) {
				this.dataForm.type = e.value[0].value
				this.dataForm.typeName = e.value[0].label
				this.selectShow = false

			},
			getData() {
				sid.getFeedbackType().then((res) => {
					this.typeList = [res.data];
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		background: #F9F9F9;
		padding: 10rpx 12rpx;

		.centerbox {
			padding: 10rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 2rpx 10rpx 0rpx rgba(204, 204, 204, 0.4);
			border-radius: 10rpx 10rpx 0rpx 0rpx;
		}

		.bottombtn {
			padding: 10rpx 30rpx 40rpx 30rpx;
			position: fixed;
			background-color: #FFFFFF;
			bottom: 0;
			left: 0;
			right: 0;
		}
	}
</style>