<template>
	<view class="">
		<u-notify ref="uNotify" message=""></u-notify>
		<view class="pwd_view">
			<!-- <view class="cancel">
				<image src="../../static/images/close.png" mode=""></image>
			</view> -->
			<view class="" style="font-size: 30rpx;margin-bottom: 42rpx;">
				账号登录
			</view>
			<u--input placeholder="请输入账号" border="none" inputAlign="center" v-model="acount_input"
				style="background-color: #F2F2F4;border-radius: 10rpx;font-size: 28rpx;padding: 20rpx 0;">
			</u--input>
			<view class="tips">
				备注：请输入账号登录，如没有账号请找授课老师获取
			</view>
			<view class="btn_pwd" @click="send">
				进入
			</view>
		</view>
	</view>
</template>

<script>
	export default {

		name: "acount_login",
		props: {
			logintype: Object
		},
		mounted() {

		},
		data() {
			return {
				acount_input: '',
				nickname:''
			}
		},
		methods: {
			send() {
				if (this.acount_input.length <= 0) {
					uni.showToast({
						title:"账号不能为空",
						icon:"none"
					})
				} else {
					this.$api.roomwatchytypephone(this.acount_input).then(res => {
						console.log(res);
						if (res.data.code == 200) {
							this.nickname = res.data.data
							uni.setStorageSync('room_account',this.acount_input)
							if (localStorage.getItem('wxnick') == 1) {
								this.$api.getusertoken('', this.acount_input, true).then(res => {
									uni.setStorageSync('room_token', res.data.data)
									this.$refs.uNotify.show({
									    top: 30,
									    type: 'success',
									    message: '验证成功',
									    duration: 1000 * 3,
									    fontSize: 20,
									    safeAreaInsetTop:true
									})
									setTimeout(() => {
										location.reload()
									}, 1500);
								})
							}
							if (localStorage.getItem('wxnick') == 0) {
								this.nickname = this.nickname + ""
								uni.setStorageSync("user_name1",this.nickname)
								this.$api.getusertoken(this.nickname, this.acount_input, true).then(res => {
									uni.setStorageSync('room_token', res.data.data)
									this.$refs.uNotify.show({
									    top: 30,
									    type: 'success',
									    message: '验证成功',
									    duration: 1000 * 3,
									    fontSize: 20,
									    safeAreaInsetTop:true
									})
									setTimeout(() => {
										window.location.reload()
									}, 1500);
								})
							}
						} else {
							this.$refs.uNotify.show({
							    top: 30,
							    type: 'error',
							    message: res.data.msg,
							    duration: 1000 * 3,
							    fontSize: 20,
							    safeAreaInsetTop:true
							})
						}
					})
				}
			},
		},
	}
</script>

<style>
	.pwd_view {
		padding: 45rpx 60rpx;
		text-align: center;
	}

	.btn_pwd {
		margin-top: 80rpx;
		height: 80rpx;
		background: #266FE8;
		line-height: 80rpx;
		color: #fff;
		border-radius: 40rpx;
	}

	/* .cancel{
		margin-top: -20rpx;
		margin-bottom: 50rpx;
		margin-right: -20rpx;
	}
	.cancel image{
		width: 30rpx;
		float: right;
		height: 30rpx;
	} */
	.tips {
		font-size: 24rpx;
		color: #777777;
		margin-top: 90rpx;
	}
</style>
