<template>
	<view class="page">
		<u-navbar title="店铺地图展示" :border-bottom="false" :background="bgc" title-color='#333' back-icon-color="#333"
			title-size='36' height='50'></u-navbar>
		<view class="box">
			<view class="rt">
				<view class="wz1">
					是否申请店铺展示在地图上
				</view>
				<view class="wz2">
					方便用户在地图上查找门店
				</view>
			</view>
			<view class="lt">
				<u-switch v-model="checked" active-color="#8883F0"></u-switch>
			</view>
		</view>
		<map class='map' id="map" :latitude="latitude" :longitude="longitude"/>
		<view class="tishi">
			注：提交需在要求范围内才能通过，否则将驳回申请！
		</view>
		<view class="anniu" @click="btntj">
			提交申请
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				storeId:'',
				checked: false,
				latitude:'',
				longitude:''
			}
		},
		onLoad(option) {
			console.log(option);
			this.storeId = option.storeId
			if(option.status){
				if(option.status == 1){
					this.checked = true
				}else{
					this.checked = false
				}
			}
			uni.getLocation({
				type: 'wgs84',
				success: (res) => {
					this.latitude = Number(res.latitude.toFixed(5)) - 0.005
					this.longitude = Number(res.longitude.toFixed(5)) + 0.005
				},
				fail: (err) => {
					console.error('获取位置失败：', err)
				}
			})
		},
		onShow() {
			
		},
		// 分享到好友（会话）
		  onShareAppMessage: function () {  
		    return {  
		      title: '创想物联',  
		      path: '/pages/shouye/index'  
		    }  
		  },  
		  
		  // 分享到朋友圈  
		  onShareTimeline: function () {  
		    return {  
		      title: '创想物联',  
		      query: '',  
		      path: '/pages/shouye/index'  
		    }  
		  },
		methods: {	
             btntj(){
				 this.$u.put(`/app/store/setShow?storeId=${this.storeId}&show=${this.checked}`).then(res => {
				 	if (res.code == 200) {
                        uni.showToast({
                        	title: '操作成功',
                        	icon: 'success',
                        	duration:2000
                        })
						setTimeout(()=>{
							uni.navigateBack()
						},1000)
				 	}else{
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration:2000
						})
					}
			   })
			}
		}
	}
</script>

<style lang="scss">
	page{
		padding: 0 74rpx;
		box-sizing: border-box;
	}
	.anniu{
		width: 536rpx;
		height: 84rpx;
		background: #8883F0;
		filter: blur(0px);
		text-align: center;
		line-height: 84rpx;
		margin: auto;
		margin-top: 600rpx;
		border-radius: 50rpx;
		font-weight: 600;
		font-size: 36rpx;
		color: #FFFFFF;
	}
	.tishi{
		font-size: 24rpx;
		color: #FF5252;
		margin-top: 58rpx;
	}
	map{
		margin-top: 36rpx;
	}
	.box{
		display: flex;
		justify-content: space-between;
		margin-top: 42rpx;
		.rt{
			.wz1{
				font-size: 32rpx;
				color: #3D3D3D;
			}
			.wz2{
				font-size: 24rpx;
				color: #3D3D3D;
				margin-top: 14rpx;
			}
		}
	}
	/deep/ .u-title {
		padding-bottom: 22rpx;
	}

	/deep/ .u-icon__icon {
		padding-bottom: 22rpx;
	}
</style>