<template>
|
|
<view class="login-wrapper wrapperLayer colCen">
|
<titleBar titleText='' :pageForm='"loginPage"' @backIndex="backHome"></titleBar>
|
<view class="pageContent borderBox colCen">
|
<view class="titleText">
|
欢迎登录
|
</view>
|
|
<view class="input-container colCen">
|
<view class="outSidebox rowCen" :class="selectedInput=='phone'?'outSidebox-active':''">
|
<input type="number" data-type='phone' @focus="changeType" @blur="cleanActive" v-model="phone" placeholder="请输入手机号"
|
placeholder-class="input-placeHolder" />
|
</view>
|
</view>
|
|
<view class="input-container colCen" v-if="ifPasslogin">
|
<view class="outSidebox rowCenBet" data-type='pass' :class="selectedInput=='pass'?'outSidebox-active':''">
|
<input @focus="changeType" @blur="cleanActive" data-type='pass' :password="showPass" type="text" v-model="pass"
|
placeholder="请输入密码" placeholder-class="input-placeHolder" />
|
<view class="hidepass iconfont" @click="showPassfnc()">
|
{{showPass?'':''}}
|
</view>
|
</view>
|
</view>
|
<view class="input-container colCen" v-else>
|
<view class="outSidebox rowCenBet" data-type='pass' :class="selectedInput=='code'?'outSidebox-active':''">
|
<input @focus="changeType" @blur="cleanActive" data-type='code' type="number" v-model="code" placeholder="请输入验证码"
|
placeholder-class="input-placeHolder" />
|
<view class="getcodebox" :class="canGetCode?'colorTxt':''" @click="getCode()">
|
{{canGetCode?'获取验证码':second+'s后重新获取'}}
|
</view>
|
</view>
|
</view>
|
|
<view class="login-btn rowCenCen" :class="(ifPasslogin?pass:code)&&phone?'colorfulbtn':''" @click="dologin()">
|
<view class="btn-font">
|
登录
|
</view>
|
</view>
|
|
<view class="bottom-fixed colCen">
|
<view class="verification-Code" @click="changeWay()">
|
{{ifPasslogin?'验证码':'密码'}}登录
|
</view>
|
<view class="explain-text rowCen">
|
<switch type="checkbox" @change="changeread" :checked='isread' style="transform:scale(0.6)"/>
|
登陆代表已详细阅读并同意<text @click="goPage('agreement')">《用户协议》</text>和<text @click="goPage('policy')">《隐私政策》</text>
|
</view>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import {
|
mapMutations
|
} from 'vuex';
|
import titleBar from '../../components/backTitlebar.vue'
|
import MD5 from '../../utils/md5.js'
|
import config from '../../utils/config.js'
|
import utils from '../../utils/utils.js'
|
export default {
|
components: {
|
titleBar
|
},
|
data() {
|
return {
|
ifPasslogin: false,
|
pass: '',
|
phone: '',
|
code: '',
|
selectedInput: '',
|
isread:false,
|
|
cleanfocus: true,
|
showPass: true,
|
second: 60,
|
canGetCode: true,
|
prevent: true,
|
clientid:""
|
};
|
},
|
onLoad() {
|
|
},
|
methods: {
|
...mapMutations(['login']),
|
backHome() {
|
uni.switchTab({
|
url: '../index/index'
|
})
|
},
|
changeread(e){
|
this.isread = e.target.value
|
},
|
dologin() {
|
var that = this;
|
// #ifdef APP-PLUS
|
plus.push.getClientInfoAsync((info) => {
|
that.clientid = info["clientid"];
|
});
|
// #endif
|
|
if(this.isread){
|
if (this.ifPasslogin) {
|
//密码登录
|
var param = {
|
account: this.phone,
|
password: this.pass,
|
push_cid:this.clientid
|
}
|
this.$u.api.login(param).then(e => {
|
if(e.code != 0) return that.$alert(e.msg)
|
this.targetToIndex(e);
|
/* that.login(e.data.userinfo);
|
that.$alert('登录成功')
|
setTimeout(function(){
|
uni.switchTab({
|
url: '../index/index'
|
});
|
},1000) */
|
}).catch(function (err) {
|
})
|
} else {
|
//验证码登录
|
this.$u.api.mobileLogin({
|
mobile: this.phone,
|
captcha: this.code,
|
push_cid:this.clientid
|
}).then(e => {
|
that.login(e.data.userinfo);
|
if(e.code != 0) return that.$alert(e.msg)
|
this.targetToIndex(e);
|
/* that.login(e.data.userinfo);
|
utils.setCache('userInfo', e.data.userinfo)
|
getApp().globalData.userInfo = e.data.userinfo
|
that.$alert('登录成功')
|
setTimeout(function(){
|
if (e.data.userinfo.isPwd == 'N') {
|
uni.redirectTo({
|
url: './setPass'
|
})
|
} else {
|
uni.switchTab({
|
url: '../index/index'
|
})
|
}
|
},1000) */
|
|
}).catch(function (err) {
|
})
|
}
|
}else{
|
uni.showToast({
|
title:'请先阅读并同意《用户协议》和《隐私协议》',
|
icon:"none",
|
})
|
}
|
},
|
|
getCode() {
|
var that = this;
|
if(this.phone == '') return this.$alert('手机号码不能为空');
|
if (this.prevent && this.canGetCode) {
|
this.prevent = false
|
var timerChuo = new Date().getTime()
|
this.$u.api.sendSms({
|
mobile: that.phone,
|
event: 'login'
|
}).then(e => {
|
if(e.code != 0) return that.$alert(e.msg)
|
that.canGetCode = false
|
that.prevent = true
|
var timer = setInterval(() => {
|
that.second--
|
if (that.second < 1) {
|
that.second = 60
|
that.canGetCode = true
|
clearInterval(timer)
|
}
|
}, 1000)
|
|
}).catch(function (err) {
|
that.canGetCode = true
|
that.prevent = true
|
})
|
} else {
|
uni.showToast({
|
title: '您点的太快了~',
|
icon: 'none',
|
position: 'bottom',
|
duration: 3000
|
});
|
}
|
},
|
|
targetToIndex(e)
|
{
|
var that = this;
|
|
that.login(e.data.userinfo);
|
utils.setCache('userInfo', e.data.userinfo)
|
getApp().globalData.userInfo = e.data.userinfo
|
that.$alert('登录成功')
|
setTimeout(function(){
|
console.log(e.data.userinfo)
|
if(!e.data.userinfo.invitation_code)
|
{
|
uni.redirectTo({
|
url: './setInviteCode'
|
})
|
}
|
else if (e.data.userinfo.isPwd == 'N') {
|
uni.redirectTo({
|
url: './setPass'
|
})
|
} else {
|
uni.switchTab({
|
url: '../index/index'
|
})
|
}
|
},1000)
|
},
|
|
showPassfnc() {
|
this.showPass = !this.showPass
|
},
|
|
|
changeType(e) {
|
this.selectedInput = e.target.dataset.type
|
},
|
cleanActive() {
|
this.selectedInput = ''
|
},
|
|
changeWay() {
|
this.ifPasslogin = !this.ifPasslogin
|
},
|
|
goPage(type) {
|
uni.navigateTo({
|
url: './policyAgreement?type=' + type
|
})
|
}
|
}
|
};
|
</script>
|
|
<style lang="scss">
|
.login-wrapper {
|
width: 100%;
|
min-height: 100vh;
|
background-color: #FFFFFF;
|
|
.pageContent {
|
width: 100%;
|
padding: 0 60rpx;
|
|
.titleText {
|
width: 100%;
|
font-size: 42rpx;
|
font-weight: bold;
|
color: #333333;
|
margin: 60rpx 0;
|
}
|
|
.input-container {
|
width: 100%;
|
margin-bottom: 20rpx;
|
|
.outSidebox {
|
width: 100%;
|
height: 85rpx;
|
border-bottom: 2rpx solid #F1F1F1;
|
|
.input-placeHolder {
|
font-size: 34rpx;
|
font-weight: 500;
|
color: #CACACA;
|
}
|
|
input {
|
font-size: 34rpx;
|
font-weight: 500;
|
color: #222222;
|
}
|
|
.hidepass {
|
font-size: 32rpx;
|
font-weight: 800;
|
color: #CACACA;
|
}
|
|
.getcodebox {
|
font-size: 28rpx;
|
white-space: nowrap;
|
font-weight: 400;
|
color: #FF2851;
|
pointer-events: none;
|
}
|
|
.colorTxt {
|
pointer-events: auto;
|
}
|
}
|
|
.outSidebox-active {
|
border-bottom: 2rpx solid #FF2851;
|
}
|
}
|
|
.login-btn {
|
width: 100%;
|
height: 86rpx;
|
background: #E2E2E2;
|
border-radius: 43rpx;
|
margin-top: 80rpx;
|
pointer-events: none;
|
|
.btn-font {
|
font-size: 30rpx;
|
font-weight: 500;
|
color: #FFFFFF;
|
}
|
}
|
|
.colorfulbtn {
|
background: #FD002F;
|
pointer-events: auto;
|
}
|
|
.bottom-fixed {
|
width: 100%;
|
position: fixed;
|
bottom: 100rpx;
|
bottom: calc(100rpx + constant(safe-area-inset-bottom));
|
bottom: env(100rpx + constant(safe-area-inset-bottom));
|
left: 0;
|
z-index: 1;
|
|
.verification-Code {
|
white-space: nowrap;
|
font-size: 28rpx;
|
font-weight: 500;
|
color: #333333;
|
}
|
|
.explain-text {
|
font-size: 22rpx;
|
font-weight: 500;
|
color: #999999;
|
margin-top: 30rpx;
|
white-space: nowrap;
|
}
|
}
|
}
|
}
|
</style>
|