<template>
	<view>
		<view class="box">
			<view class="top" style="margin-bottom: 50rpx;">
				<text class="title">登录</text>
			</view>
			<view class="item">
				<view class="l">手机号码：</view>
				<view class="r">
					<u-input v-model="form.key" placeholder="登录名"/>
				</view>
			</view>
			<view class="item">
				<view class="l">密码：</view>
				<view class="r">
					<u-input v-model="form.password" placeholder="输入密码" type="password"/>
				</view>
			</view>
		<!-- 	<view class="item">
				<view class="l">验证码：</view>
				<view class="r">
					<u-input placeholder="输入验证码"/>
					<view class="btn">发送</view>
				</view>
			</view> -->
		</view>
		<view class="common-btn" @click="loginFn">确认登录</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form:{
					key:'',
					password:''
				}
			}
		},
		methods: {
			loginFn(){
				if(!this.form.key){
					this.$common.toast('请输入登录名');
					return;
				}
				if(!this.form.password){
					this.$common.toast('请输入密码');
					return;
				}
				this.$api.doLogin(this.form).then(resp=>{
					let data=resp.data;
					if(data.tokenInfo){
						uni.setStorageSync('token',data.tokenInfo.tokenValue);
						uni.setStorageSync('customerId',data.admin.customerId)
						uni.setStorageSync('info',data.admin)
						this.$common.to('/pages/index/index')
					}else{
						this.$common.toast('登录失败');
					}
				})
			}
			
			
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #fff;
	}
	@import '@/common/common.scss'
</style>
