<template>
	<ciy-header title="意见建议"></ciy-header>
	<view v-if="init.code != 1" class="px4 py4">
		<view class="ciy-skeleton" style="height:80vw;width:100%;"></view>
		<view class="ciy-skeleton" style="height:6em;width:100%;"></view>
		<view class="ciy-skeleton" style="height:6em;width:100%;"></view>
	</view>
	<view v-else>
		<form @submit="submit">
			<view class="ciy-card">
				<view class="content char4">
					<view class="ciy-form v">
						<label class="imp">意见建议</label>
						<view>
							<ciy-textarea name="content" type="text" bb ciystyle="min-height:5em"></ciy-textarea>
						</view>
					</view>
					<view class="ciy-form">
						<label>图片截图</label>
						<view>
							<ciy-upload left num="8" path="suggest" action="amb" name="imgs" imgwidth="1600" sourcetype="camera,album,message"></ciy-upload>
						</view>
					</view>
					<view class="ciy-form">
						<label>联系方式</label>
						<view>
							<ciy-input name="contract" type="text" bb></ciy-input>
						</view>
					</view>
					<view class="ciy-form-bottom">
						<button class="btn lg cc" form-type="submit">提交</button>
					</view>
				</view>
			</view>
		</form>
		<view class="ciy-list" v-for="(item,index) in init.list" :key="item.id">
			<view class="l2" v-html="tobr(item.content)"></view>
			<ciy-showimgs :src="item.imgs" label="图片截图"></ciy-showimgs>
			<view class="l2" v-if="item.contract">联系方式: {{item.contract}}</view>
			<template v-if="item.replytimes > 0">
				<view class="ciy-hr my4"></view>
				<view class="l2 ciy-tip" v-html="tobr(item.replymsg)"></view>
			<view class="rt" style="color:var(--succ5)">已答复</view>
			</template>
			<view class="rt" v-else>未答复</view>
			<view class="rb">{{todatetime(item.addtimes)}}</view>
		</view>
	</view>
</template>

<style>
</style>

<script>
	export default {
		data() {
			return {
			}
		},
		onLoad() {
			this.getinit();
		},
		methods: {
			async getinit() {
				var retjson = await this.callajax({
					func: 'me.suggest_get',
					data: {}
				});
				if (retjson.code != 1)
					return this.alert(retjson.errmsg);
				this.init = retjson;
			},
			async submit(e) {
				if (e.detail.value.content.length < 5)
					return this.toast('内容至少输入5个字');

				this._loading = true;
				var retjson = await this.callajax({
					func: 'me.suggest_submit',
					data: e.detail.value
				});
				this._loading = false;
				if (retjson.code != 1)
					return this.alert(retjson.errmsg);
				await this.toast('已提交');
				uni.navigateBack();
			}
		}
	}
</script>