<!-- 账号密码登录 accountLogin  -->
<template>
  <view>
    <!-- 表单项 -->
    <u-form
      ref="accountLoginRef"
      labelWidth="140"
      labelAlign="left"
      labelPosition="top"
    >
      <u-form-item prop="loginName" label="账号">
        <view class="input-line">
					<u-input
							placeholder="请输入账号"
							v-model="model.loginName"
							border="none"
					></u-input>
        </view>
      </u-form-item>

      <u-form-item prop="password" label="密码">
        <view class="input-line">
					<u-input
						type="password"
						placeholder="请输入密码"
						v-model="model.password"
						border="none"
					></u-input>
        </view>
      </u-form-item>
    </u-form>
  </view>
</template>

<script>
	import {login} from '@/common/request/apis/login'
	import md5 from '@/common/request/md5.js'
	export default{
		data() {
			return {
				model:{
					loginName:'',
					password:''
				},
			}
		},
		methods:{
			accountLoginSubmit() {
			  if(!this.model.loginName){
			  	return uni.$u.toast("请输入账号");
			  }
			  if(!this.model.password) {
			  	return uni.$u.toast("请输入密码");
			  }
				let params = {
					...this.model,
					password: md5(this.model.password)
				}
				login(params)
				.then(res=>{
					if(res.code == 200) {
						let userInfo = {
							token:res.data.token,
							...res.data.user
						}
						this.$store.dispatch('userLogin',userInfo)
					}
				})
			}
		}
	}

</script>

<style lang="scss" scoped>
// @import "../index.scss";
.input-line {
	display: flex;
	align-items: center;
	width: 100%;
  background-color: #f5f7fb;
  border-radius: 16rpx;
  padding-left: 30rpx;
  height: 88rpx;
  box-sizing: border-box;
}
</style>
