Blame view

pages/login.vue 1.88 KB
46b6767c   刘淇   init 提交到库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
  <template>
  	<view class="container">
  		<view class="fs-bg__primary fs-pt200 fs-pl30 fs-pb160">
  			<view class="fs-size__h1 fs-color__white">系统登录</view>
  			<view class="fs-size__h4 fs-color__white fs-mt12">欢迎来到园林养护智慧平台</view>
  		</view>
  		<view class="fs-p30 fs-bg__white fs-radius__48 fs-mt-60">
  			<view class="fs-flex__center">
  				<image src="/static/images/1.png" style="width:400rpx;height:280rpx;"></image>
  			</view>
  			<tui-form ref="form" :showMessage="false">
  				<tui-input marginTop="20" placeholder="请输入账号" v-model="formData.username"></tui-input>
  				<tui-input marginTop="20" password placeholder="请输入密码" v-model="formData.password"></tui-input>
  			</tui-form>
  			<view class="fs-mt96 fs-align__center fs-flex__center">
  				<tui-button width="520rpx" height="86rpx" shadow shape="circle" :loading="isLoading" :disabled="isLoading" @click="onSubmit">立即登录</tui-button>
  			</view>
  		</view>
  	</view>
  </template>
  
  <script>
  import { apiAccountLogin } from '@/api/app'
  const rules = [
  	{
  		name: "username",
  		rule: ["required"],
  		msg: ["请输入账号"]
  	}, 
  	{
  		name: "password",
  		rule: ["required"],
  		msg: ["请输入密码"]
  	}
  ]
  export default {
  	data() {
  		return {
  			formData: {
  				username: '',
  				password: '',
  				isSkipCaptchaVerify: true
  			},
  			isLoading: false
  		}
  	},
  	onLoad() {
  		// 取消监听位置上报
  		uni.stopLocationUpdate()
  	},
  	methods: {
  		onSubmit() {
  			this.$refs.form.validate(this.formData, rules).then(res => {
  				if (!res.isPass) {
  					uni.$tui.toast(res.errorMsg)
  					return
  				}
  				this.isLoading = true
  				apiAccountLogin({data:{...this.formData}}).then(res => {
  					// 设置登录信息
  					this.login(res)
  					uni.$tui.href('/pages/index', 1)
  				}).finally(() => {
  					this.isLoading = false
  				})
  			})
  		}
  	}
  }
  </script>
  
  <style lang="scss">
  	page {
  		background-color: #FFF;
  	}
  </style>