<template>
	<view>
		<van-dialog  title="请登录"
		:show-cancel-button="ishow"
		:show="show"
		@cancel="cancelDialog" @confirm="confirmOrder"
		confirm-button-open-type="getUserInfo"	
		confirm-button-color = "#323232"	
		>
		</van-dialog>
			<!-- <button @click="wxlogion"   open-type="getUserInfo">请点击授权</button> -->
	</view>
	
</template>

<script>
	import {
		mapMutations,mapState
	} from 'vuex'
	export default {
		props:{
		  showdialog:{
		    default: false,
		    type: Boolean
		  },
		  ishow:{
		    default: true,
		    type: Boolean
		  },
		},
		 data() {
			return{
				show: false
			}
		},
		watch:{
			'showdialog':function(val) {
				console.log("jinlaile")
				console.log(val)
				if(val) {
					this.show = true;
				}else {
					this.show = false;
				}
				console.log(this.show);
			}
		},
		methods:{
			...mapMutations(['login','showDialog']),
			cancelDialog() {
				this.show = false;
				this.$emit('cancelDiaolog')
				this.showDialog(false);
				this.login();
				this.$msg('登录失败');
			},
			confirmOrder() {
				this.show = false;
				this.$emit('changeDiaolog');
				this.wxlogion();
			},
			wxlogion() {
				let  that = this;
				    uni.getUserInfo({
					     success(res) {
							 that.login(res.userInfo);
							 that.showDialog(true); // 改变haslogion的值
							 that.$emit('confirmDiaolog');
							 that.$msg("登录成功")
					     },
					     fail(res) {
						     that.$emit('keepdialog');  // 订单我的保持登录
							 that.showDialog(false);
							 that.$msg("登录失败")
					     }
				    })
			}
		}
	}
</script>

<style>
</style>
