<template>
<view class="container">
	<view  class="h-method flex-row justify-center">
		<view class="btn flex-row justify-center " @click="bindWechat()">
			<view class="h-img flex-col justify-center">
				<u-icon name="weixin-fill" color="green" size="30"></u-icon>
			</view>
			<view class="h-name ">
				<text>绑定当前登录微信号</text>
			</view>
		</view>

	</view>
</view>
</template>

<script>
export default {
	data() {
		return {
			userInfo: {
				auth: true,
				openId: ''
			},
			tips2: '',
		}
	},
	onReady() {
	},
	onLoad() {
		// 用户信息
		let user = uni.getStorageSync('userInfo');
		this.userInfo.openId = user.openId;
	},
	methods: {
		// 绑定微信
		bindWechat(){
			// 保存数据
			this.$api.bindWechat(this.userInfo).then((res)=>{
				uni.showToast({
					title: '绑定成功'
				})
				setTimeout(function() {
				   // 选择完成后返回上一页
				   uni.navigateBack({
				     delta: 1,
				     success: function(res) {
				       console.log('返回成功');
				     }
				   });
				}, 2000); // 延迟2秒执行
			}).catch(() =>{
				uni.showToast({
					title: "操作失败"
				})
			});

		},
	}
}
</script>

<style lang="scss" scoped>
	@import '/common/css/common.css';
page,body{
	background: #F7F7F7;
}
.container{
}
.h-method{
	height: 100vh;
	background: #f7f7f7;
}

	.btn{

		width: 686rpx;
		height: 100rpx;
		background: #FFFFFF;
		border-radius: 50rpx;
		margin-top: 35vh;

		.h-name{
			line-height: 100rpx;
		}
	}
</style>
