<template>
	<view class="all-container backcor6 pd-main  font15" style="padding-bottom: 60px;">
		<view class="form-gorup  backcorfff ">
			<view class="dis-flex marb10 bor-botm1 pd-main">
				<view class="group-title marRight10 fontwig6 padleft15 paddtright10 flex-s0">营业时间:
				</view>
				<input type="text" v-model.trim="messageData.openingHours" placeholder-class="corf6 font15"
					class=" flex-1 " placeholder="请输入营业时间,例如: 8:00-20:00">
			</view>
			<view class="dis-flex marb10 bor-botm1 margin10">
				<view class="group-title marRight10 fontwig6 padleft15 paddtright10 flex-s0 self-top">门店地址:
				</view>
				<textarea :cursor-spacing="50" class="height45 border-r flex-1 backcor6 paading10 marb10" :focus="false"
					:disable-default-padding="false" v-model.trim="messageData.address" placeholder="请输入门店地址"
					placeholder-class="font15" :maxlength="999"></textarea>
			</view>
			<view class="dis-flex marb10 bor-botm1 margin10">
				<view class="group-title marRight10  padleft15 paddtright10 flex-s0 self-top">
					<view class="fontwig6">门店标签:</view>
					<view class="font14 fcor999 mart5">
						(用'#'隔开)例如:可电话预订#可吸烟
					</view>
				</view>
				<textarea :cursor-spacing="50" class=" border-r flex-1 backcor6 paading10 marb10" :focus="false"
					:disable-default-padding="false" v-model.trim="messageData.storeLabel"
					placeholder="请输入门店标签" placeholder-class="font15" :maxlength="999"></textarea>
			</view>
			<view class="dis-flex marb10 bor-botm1 margin10">
				<view class="group-title marRight10  padleft15 paddtright10 flex-s0 self-top">
					<view class="fontwig6">门店关键词:</view>
					<view class="font14 fcor999 mart5">
						(用'#'隔开)例如:火锅#川菜
					</view>
					
				</view>
				<textarea :cursor-spacing="50" class=" border-r flex-1 backcor6 paading10 marb10" :focus="false"
					:disable-default-padding="false" v-model.trim="messageData.storeTag"
					placeholder="请输入门店关键词" placeholder-class="font15" :maxlength="999"></textarea>
			</view>
			<view class="footer-btn">
				<button class="backcor89 fcorfff" @click="clickToSave">保存</button>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		editStoreExtMsg,
		findStoreExtMsgByStoreId
	} from '@/Utils/groupBuying.js'

	const app = getApp();
	export default {
		data() {
			return {

				storeId: '',
				messageData: {
					address: '', //门店地址
					openingHours: '', //营业时间
					storeId: '', //门店编码
					storeLabel: '', //门店标签（，隔开）
					storeTag: '', //门店关键词（，隔开）
				}

			}
		},

		onLoad(options) {
			if (options.storeId) {
				this.storeId = options.storeId;
				this.messageData.storeId = options.storeId;
				this.findStoreExtMsgByStoreId();
			}
		},
		methods: {
			/* 点击保存 */
			clickToSave() {
				if (!this.messageData.address || !this.messageData.openingHours || !this.messageData.storeLabel || !this
					.messageData.storeTag) {

					uni.showToast({
						icon: 'none',
						title: '请填写完整哦！'
					})

					return
				}
				this.editStoreExtMsg();

			},
			editStoreExtMsg() {

				console.log(this.messageData, "this.messageData")

				editStoreExtMsg(this.messageData).then(res => {
					let title;
					if (res.return_code == '000000') {
						title = res.return_data;
						setTimeout(() => {
							uni.navigateBack();
						}, 1000)
					} else {
						title = res.return_msg;
					}
					uni.showToast({
						title: title,
						icon: 'none',
						duration: 2000
					})


				})
			},
			findStoreExtMsgByStoreId() {
				let params = {
					storeId: this.storeId
				}
				findStoreExtMsgByStoreId(params).then(res => {
					if (res.return_code == '000000') {
						if (res.return_data) {
							this.messageData.address = res.return_data.address;
							this.messageData.openingHours = res.return_data.openingHours;
							this.messageData.storeId = res.return_data.storeId;
							this.messageData.storeLabel = res.return_data.storeLabel;
							this.messageData.storeTag = res.return_data.storeTag;
							// console.log(res.return_data, "res.return_data")
						}
					} else {
						uni.showToast({
							title: res.return_msg,
							icon: 'none',
							duration: 2000
						})
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.margin10 {
		margin: 10px;
	}

	/* 底部按钮 */
	.footer-btn {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;

		button {
			height: 50px;
			line-height: 50px;
		}
	}
	
	.group-title{
		width:80px;
	}
</style>