<template>
	<view>
		 <form @submit="formSubmit" >
			<view class="uni-form-item uni-column">
				<view>
					 <input
						 class="uni-input" 
						 name="username"
						 placeholder-class="icon iconfont icon-bianji1" 
						 placeholder="请输入用户名" />
				</view>
				<view>
					 <input 
						 class="uni-input" 
						 name="pass"
						 placeholder-class="icon iconfont icon-bianji1" 
						 placeholder="请输入密码" />
				</view>
				 <view class="uni-btn-v">
					<button form-type="submit">Submit</button>
				</view>
			</view>
		</form>
						
	</view>
</template>

<script>
	export default {
		data() {
			return {
			}
		},
		onLoad(){
			
		},
		methods: {
			async formSubmit(e){
				let formdata=e.detail.value;
				const res=await this.$myRequest({
					url:'/api/api_gateway?method=user.login.login_user',
					data:{
						username: formdata.username,
						password: formdata.pass
					}
				})
				let session_key=res.session_key
				uni.setStorage({
				    key: 'session_key',
				    data: session_key,
				    success: function () {
				        console.log('success');
				    }
				})
			}
		}
	}
</script>

<style>
.uni-form-item{
	margin-top:50rpx;
}
</style>
