<template>
	<view class="container">
		<view class="page-block">
			<view class="page-title-block">
				<view class="title">账号信息</view>
			</view>
			<view class="content">
				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>门店</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.title}}</view>
					</view>
				</view>
				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>联系电话</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.tel}}</view>
					</view>
				</view>
				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>省市</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.province_name}}{{info.city_name}}{{info.district_name}}</view>
					</view>
				</view>

				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>门店地址</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.address}}</view>
					</view>
				</view>

				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>门店公告</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.announcement}}</view>
					</view>
				</view>


				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>经营类目</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.one_category_name +'>'+ info.two_category_name}}</view>
					</view>
				</view>
				
				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>支付方式</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.pay_type==2?'餐后付款':'餐前付款'}}</view>
					</view>
				</view>


				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>是否开启会员</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.is_vip==1?'是':'否'}}</view>
					</view>
				</view>
				
				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>是否开启堂食</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.is_hall==1?'是':'否'}}</view>
					</view>
				</view>

				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>是否开启外卖</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.is_waimai==1?'是':'否'}}</view>
					</view>
				</view>
				
				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>是否开启到店自提</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.is_ziti==1?'是':'否'}}</view>
					</view>
				</view>
				<view class="flex home-qrcode">
					<view class="title-block">
						码管理
					</view>
					<view class="">
						<image :src="URL+info.skm" @click="previewImage(info.skm)"></image>
						<text>收款码</text>
					</view>
					
					<view class="">
						<image :src="URL+info.line_qrcode" @click="previewImage(info.line_qrcode)"></image>
						<text>排队取号</text>
					</view>	
				</view>
				
			</view>
		</view>

		<view class="page-block">
			<view class="page-title-block"></view>
			<view class="content">
				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>logo</text>
					</view>
				</view>
				<view class="qrcode-block">
					<image :src="URL+info.thumb" mode="aspectFit" class="qr-code-img"></image>
				</view>
			</view>
		</view>
		
		<view style="height:30rpx;"></view>
		
		<view class="footer-bar" style="height: 100rpx;">
			<view class="content flex flex-center" style="height: 100rpx;">
				<view class="detail-btn flex flex-center" style="border-right: 2rpx solid #F4F5F7;" @click="del">
					<image src="../static/images/icon_16.png" mode="aspectFit" class="btn-icon"></image>
					<view style="color:#999999">删除门店</view>
				</view>
				<view class="detail-btn flex flex-center" @click="toEdit">
					<image src="../static/images/icon_17.png" mode="aspectFit" class="btn-icon"></image>
					<view style="color:#3387FF">重新编辑</view>
				</view>
			</view>
		</view>
		
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				URL: getApp().globalData.URL,
				info: {},
				zt_list: [
					'否', '是'
				],
				is_zt: 0,
			}
		},
		onLoad(options) {
			if (options.id) {
				this.id = options.id;
				this.store_user_info(options.id);
			}
		},
		methods: {		
			previewImage(src) {
				let url = this.URL +src;
				uni.previewImage({
					current: 1,
					urls: [url],
					longPressActions: {
						itemList: ['保存图片'],
						success: function(data) {
							console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
						},
						fail: function(err) {
							console.log(err.errMsg);
						}
					}
				});
			},
			//获取详情
			store_user_info(id) {
				this.request({
					url: 'Smdcshop/storeinfo',
					data: {
						store_id: id,
					}
				}).then(res => {
					if (res.code == 200) {
						this.info = res.data
					}
				})
			},

			toEdit() {
				uni.redirectTo({
					url: `../addStore/addStore?id=${this.info.id}`
				})
			},

			del() {
				uni.showModal({
					title: '提示',
					content: '是否要删除？',
					showCancel: true,
					cancelText: '取消',
					confirmText: '确定',
					success: res => {
						if (res.confirm) {
							this.request({
								url: 'Smdcshop/store_delect',
								data: {
									id: this.id,
								},
							}).then(res => {
								console.log(res, "res")
								if (res.code === 200 || res.code === "200") {
									uni.showToast({
										title: "删除成功",
										icon: "none",
									})
									setTimeout(() => {
										uni.navigateBack()
									}, 2000)
								}
							}).catch((res) => {
								uni.showToast({
									title: res.message,
									icon: "none",
								})
							});
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
		}
	}
</script>

<style>
	@import url("../static/css/common.css");
	.home-qrcode {
		text-align: center;
		font-size: 28rpx;
		padding: 20rpx 0;
	}

	.home-qrcode .title-block {
		font-size: 30rpx;
		color: #333;
		font-weight: 600;
		padding-right: 20rpx;
	}

	.home-qrcode image {
		width: 250rpx;
		height: 250rpx;
		display: block;
	}
	page {
		background-color: #F4F5F7;
	}

	.qrcode-block {
		padding: 56rpx 0;
	}

	.qrcode-block .qr-code-img {
		display: block;
		width: 150rpx;
		height: 150rpx;
	}
	.page-block .cell .input-box {
		height: initial;
		line-height: 1.5;
	}

</style>
