3 changed files with 12 additions and 123 deletions
@ -1,113 +0,0 @@ |
|||
<template> |
|||
<view> |
|||
<view class="main"> |
|||
<view class="code"> |
|||
<uni-easyinput v-model="ret.phone" :maxlength="11" :placeholder="plad"/> |
|||
<com-zw/> |
|||
<uni-easyinput v-model="ret.password" :maxlength="25" placeholder="请输入密码" type="password"/> |
|||
<com-zw/> |
|||
<view class="flex"> |
|||
<uni-easyinput v-model="ret.code" :clearable="false" :maxlength="4" placeholder="请输入验证码"/> |
|||
<img :src="captchaImg" alt="加载验证码失败" style="width: 70px; height: 21px; cursor: pointer; display: block" |
|||
@click="getCaptchaImg"/> |
|||
</view> |
|||
</view> |
|||
<u-button type="primary" @tap.stop="confirm(ret)">登录</u-button> |
|||
</view> |
|||
</view> |
|||
</template> |
|||
<script> |
|||
|
|||
import { |
|||
mapMutations, |
|||
mapActions, |
|||
mapState |
|||
} from 'vuex'; |
|||
|
|||
export default { |
|||
name: "phone-verify", |
|||
props: { |
|||
ret: { |
|||
type: Object, |
|||
default() { |
|||
return { |
|||
phone: 'delicacylee', |
|||
code: '', |
|||
password: '1qazxsw2#', |
|||
} |
|||
} |
|||
}, |
|||
plad: {type: String, default: '请输入手机号'}, |
|||
}, |
|||
computed:mapState(['type']), |
|||
data() { |
|||
return { |
|||
captchaId: '', |
|||
captchaImg: '', |
|||
} |
|||
}, |
|||
created() { |
|||
this.getCaptchaImg(); |
|||
}, |
|||
methods: { |
|||
...mapMutations(['login']), |
|||
...mapActions(['getUserInfo']), |
|||
getCaptchaImg() { |
|||
this.tui.request("/common/captcha/init", "GET", null).then((res) => { |
|||
if (res.code == 200) { |
|||
this.captchaId = res.result |
|||
this.captchaImg = this.tui.interfaceUrl() + '/common/captcha/draw/' + this |
|||
.captchaId |
|||
} |
|||
}).catch((res) => { |
|||
}) |
|||
}, |
|||
async confirm(form) { // 提 |
|||
this.isChoose = true; |
|||
this.tui.request("/auth/login", "POST", { |
|||
username: form.phone, |
|||
password: form.password, |
|||
code: form.code, |
|||
captchaId: this.captchaId, |
|||
saveLogin: true |
|||
}, true, true).then((res) => { |
|||
if (res.code == 200) { |
|||
uni.setStorageSync("hiver_token", res.result) |
|||
let state = { |
|||
token: res.result |
|||
} |
|||
this.login(state) |
|||
this.getUserInfo().then((type) => { |
|||
console.log('this.type',type) |
|||
if (type == 2) { |
|||
setTimeout(() => { |
|||
uni.reLaunch({ |
|||
// url: '/pages/index/logistics' |
|||
url: '/pages/other/custom' |
|||
}) |
|||
}, 200) |
|||
} else { |
|||
setTimeout(() => { |
|||
uni.reLaunch({ |
|||
url: '/pages/index/index' |
|||
// url: '/pages/index/logistics' |
|||
}) |
|||
}, 200) |
|||
} |
|||
}) |
|||
this.tui.toast('登录成功', 2000, true) |
|||
|
|||
} else { |
|||
this.tui.toast(res.message) |
|||
return |
|||
} |
|||
}).catch((res) => { |
|||
}) |
|||
}, |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss" scoped> |
|||
@import '@/scss/phone-verify.scss'; |
|||
</style> |
|||
Loading…
Reference in new issue