<template>
|
<view class="login">
|
<view class="login-image">
|
<image src="/static/images/logo@2x.png" mode="widthFix"></image>
|
</view>
|
<view class="login-list">
|
<view class="login-list-item">
|
<view class="icon">
|
<image src="/static/icon/login_ic_phone@2x.png" mode="widthFix"></image>
|
</view>
|
<input :focus='focus' @blur="focus=false" type="text" v-model="form.userName" placeholder="请输入登录账号" />
|
</view>
|
<view class="login-list-item">
|
<view class="icon">
|
<image src="/static/icon/login_ic_password@2x.png" mode="widthFix"></image>
|
</view>
|
<input :focus='focus1' @blur="focus1=false" type="safe-password" v-model="form.password" placeholder="请输入密码" />
|
</view>
|
</view>
|
<view class="login-btn" @click="submitDo">立即登录</view>
|
<view class="login-info">
|
<image src="/static/icon/ic_agree@2x.png" v-if="!radio" @click="changeRadio()" mode="widthFix"></image>
|
<image src="/static/icon/ic_agree_sel@2x.png" v-if="radio" @click="changeRadio()" mode="widthFix"></image>
|
<view class="login-info-text">
|
我已阅读并同意<text>《鼎元科技用户服务协议》</text>及<text>《鼎元科技用户隐私政策》</text>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import { mapState } from 'vuex'
|
export default {
|
computed: {
|
...mapState(['shopInfo', 'shopToken','openid'])
|
},
|
data() {
|
return {
|
focus:false,
|
focus1:false,
|
loading:false,
|
form:{
|
userName:'',
|
password:'',
|
openid:'',
|
memberId:''
|
},
|
radio:false
|
};
|
},
|
onShow() {
|
this.focus=false
|
this.focus1=false
|
this.form.openid=this.openid
|
this.checkLogin()
|
},
|
methods:{
|
checkLogin(){
|
if( !this.shopInfo && !this.shopToken){
|
let res = await that.$u.api.getUserInfo()
|
if (res.code === 200) {
|
await that.$store.commit('setUserInfo', res.data)
|
await that.$store.commit('setOpenId', res.data.openId)
|
this.jumpShopIndex()
|
}
|
}
|
},
|
changeRadio(){
|
this.radio = !this.radio
|
},
|
submitDo(){
|
if(!this.form.userName){
|
uni.showToast({
|
'title': '请输入登录账号',icon:'none'
|
})
|
this.focus=true
|
this.loading=false
|
return
|
}
|
if(!this.form.password){
|
uni.showToast({
|
'title': '请输入登录密码',icon:'none'
|
})
|
this.focus1=true
|
this.loading=false
|
return
|
}
|
if(!this.radio){
|
uni.showToast({
|
'title': '请先仔细阅读并同意用户协议和隐私政策',icon:'none'
|
})
|
this.loading=false
|
return
|
}
|
this.$u.api.shopPasswordLogin(this.form)
|
.then(res => {
|
if (res.code === 200) {
|
await that.$store.commit('setShopInfo', res.data.member)
|
await that.$store.commit('setShopToken', res.data.token)
|
this.jumpShopIndex()
|
}
|
})
|
},
|
jumpShopIndex() {
|
uni.navigateTo({
|
url: '/pages/distributor/distributor'
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.login {
|
width: 100%;
|
padding: 0 60rpx;
|
box-sizing: border-box;
|
.login-image {
|
width: 100%;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
margin-top: 162rpx;
|
image {
|
width: 400rpx;
|
}
|
}
|
.login-list {
|
width: 100%;
|
margin-top: 160rpx;
|
.login-list-item {
|
width: 100%;
|
height: 100rpx;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
border-bottom: 1rpx solid #E5E5E5;
|
.icon {
|
width: 40rpx;
|
height: 40rpx;
|
flex-shrink: 0;
|
margin-right: 20rpx;
|
image {
|
width: 100%;
|
}
|
}
|
input {
|
flex: 1;
|
height: 100%;
|
font-weight: 400;
|
font-size: 30rpx;
|
color: #111111;
|
}
|
text {
|
font-weight: 400;
|
font-size: 28rpx;
|
color: #004096;
|
margin-left: 20rpx;
|
}
|
}
|
}
|
.login-btn {
|
width: 100%;
|
height: 88rpx;
|
line-height: 88rpx;
|
text-align: center;
|
background: #004096;
|
border-radius: 44rpx;
|
font-weight: 600;
|
font-size: 32rpx;
|
color: #FFFFFF;
|
margin-top: 60rpx;
|
}
|
.login-info {
|
width: 100%;
|
display: flex;
|
align-items: flex-start;
|
margin-top: 60rpx;
|
image {
|
width: 36rpx;
|
height: 36rpx;
|
flex-shrink: 0;
|
margin-right: 14rpx;
|
}
|
.login-info-text {
|
flex: 1;
|
font-weight: 400;
|
font-size: 24rpx;
|
color: #555555;
|
text {
|
color: #2E68C4;
|
}
|
}
|
}
|
}
|
</style>
|