<template>
	<view>
		<z-slide-card :title="title" :visible.sync="isvisible" @beforeClose="beforeClose" rightBtnText="切换" @rightClick="submit">
			<z-cell :label="item.storeName" v-for="(item,index) in dataList" :key="item.storeId" @click.native="choose=item.storeId">
				<view class="iconfont iconicon-test" v-if="choose==item.storeId"></view>
			</z-cell>
		</z-slide-card>
	</view>
</template>

<script>
	const app = getApp({allowDefault: true});
	export default{
		props:{
			visible:Boolean,
			title:{
				type:String,
				default:'变更店铺为'
			}
		},
		data(){
			return{
				isvisible: false,
				dataList:[],
				checkedList:[],
				oldcheckedList: [],
				chooseContent:'',
				choose:''
			}
		},
		watch:{
			visible(newval,oldval){
				console.log(newval)
				this.isvisible=newval;
				this.getData();
			},
		},
		mounted(){
		
		},
		methods:{
			getData(){
				uni.getStorage({
					key:'storeInfo',
					success: (res) => {
						this.dataList=res.data.store;
						this.choose=uni.getStorageSync('storeId');
					}
				})
			},
			beforeClose(){
				this.$emit('update:visible', false)
			},
			submit(){
				uni.setStorage({
					key:'storeId',
					data:this.choose
				})
				this.$emit('submit');
				this.$emit('update:visible', false)
			},
		}
	}
</script>

<style lang="scss" scoped>
	.iconfont{
		color: #2481EE;
	}
</style>
