<template>
	<view class="content">
		<view class="contentlist">
			<view class="content_box">
				<view class="content_title">
					参观须知
				</view>
				<view class="content_info">
					<rich-text :nodes="notice.content"></rich-text>
				</view>
			</view>
			<view class="content_box">
				<view class="content_title">
					常见问题
				</view>
				<view class="content_info">
					<rich-text :nodes="ask.content"></rich-text>
				</view>
			</view>
			<view class="content_box">
				<view class="content_title">
					投诉建议
				</view>
				<view class="content_info">
					<u-form labelPosition="top" :model="form">
						<u-form-item label="手机号" prop="mobile" labelWidth="60px" required>
							<u-input v-model="form.mobile" placeholder="请输入手机号"></u-input>
						</u-form-item>
						<u-form-item label="内容" prop="content" labelWidth="60px" required>
							<u-textarea v-model="form.content" placeholder="请输入内容"></u-textarea>
						</u-form-item>
					</u-form>
					<u-button type="primary" @click="tosubmit">确认提交</u-button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				notice: {},
				ask: {},
				form: {
					mobile: "",
					content: ""
				},
				urls: {
					1: '/api/mobile/other/visit-notice-index',
					4: '/api/mobile/other/ask-index'
				}
			}
		},
		onLoad() {
			var that = this;
			that.loadList(1, 1)
			that.loadList(1, 4)
		},
		methods: {
			loadList(page, type) {
				var that = this;
				this.util.request({
					api: this.urls[type],
					data: {
						page: page
					},
					utilSuccess: function(res) {
						if (type == 1)
							that.notice = res.data[0];
						if (type == 4)
							that.ask = res.data[0];
					},
					utilFail: function(res) {
						uni.showToast({
							icon: "none",
							title: res
						})
					}
				})
			},
			tosubmit() {
				let that = this;
				if (this.util.isNull(that.form.mobile)) {
					this.util.toast("请填写手机号！");
					return false;
				} else {
					if (!uni.$u.test.mobile(that.form.mobile)) {
						this.util.toast("请填写正确的手机号！");
						return false;
					}
				}
				if (this.util.isNull(that.form.content)) {
					this.util.toast("请填写内容！");
					return false;
				}
				this.util.request({
					api: '/api/mobile/other/tip-store',
					data: this.form,
					method: "POST",
					utilSuccess: function(res) {
						console.log(res)
						uni.showToast({
							icon: "none",
							title: "投诉建议成功",
							complete() {
								uni.reLaunch({
									url: "/pages/success/success?from=feed"
								})
							}
						})
					},
					utilFail: function(res) {
						that.util.toast(res);
					}
				})

			}
		}
	}
</script>

<style>
	page {
		background: #f7f6f4;
	}

	.content {
		padding: 30rpx 24rpx;
	}

	.content_box {
		background: #FFFFFF;
		border-radius: 16rpx;
		padding: 30rpx 21rpx;
		margin-bottom: 25rpx;
	}

	.content_title {
		padding-bottom: 26rpx;
		border-bottom: #F7F6F4 1rpx solid;
		font-size: 32rpx;
		color: #351C1B;
	}

	.content_info {
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #828282;
		line-height: 40rpx;
		padding-top: 32rpx;
	}
</style>
