You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.3 KiB
62 lines
1.3 KiB
<template> |
|
<view> |
|
<view class="content"> |
|
<view class="title">账号密码登录</view> |
|
<view class="ip-div"> |
|
<input v-model="form.tel" type="number" placeholder="请输入账号" /> |
|
</view> |
|
<view class="ip-div"> |
|
<input v-model="form.password" type="password" placeholder="请输入密码" /> |
|
</view> |
|
<view class="btn-div"> |
|
<button @tap="submit" :disabled="form.tel&&form.password?false:true" type="primary">登录</button> |
|
</view> |
|
</view> |
|
</view> |
|
|
|
</template> |
|
|
|
<script> |
|
import { |
|
login |
|
} from "../../api/user.js"; |
|
import { |
|
mapMutations |
|
} from 'vuex'; |
|
export default { |
|
data() { |
|
return { |
|
form: { |
|
tel: '', |
|
password: '' |
|
} |
|
}; |
|
}, |
|
methods: { |
|
...mapMutations(['setToken', 'setUserInfo', 'setRefreshToken']), |
|
submit() { |
|
if (this.form.tel == "") { |
|
this.$functions.error("请输入账号"); |
|
return false; |
|
} |
|
if (this.form.password == "") { |
|
this.$functions.error("请输入密码"); |
|
return false; |
|
} |
|
|
|
login(this.form).then(res => { |
|
this.setToken(res.token.token); |
|
this.setUserInfo(res); |
|
this.setRefreshToken(res.token.refresh_token); |
|
uni.switchTab({ |
|
url: "../index/index" |
|
}) |
|
}) |
|
} |
|
} |
|
} |
|
</script> |
|
|
|
<style lang="scss"> |
|
@import "./index.scss" |
|
</style>
|
|
|