liudan 3 months ago
parent ff46de0d22
commit 4d500e767f
  1. 354
      pages/login/components/main - 副本.vue
  2. 158
      pages/login/components/main.vue
  3. BIN
      static/phone.png
  4. BIN
      static/psw.png

@ -0,0 +1,354 @@
<template>
<view class="container">
<!-- 页面头部 -->
<view class="header">
<view class="title">
<text>手机号登录</text>
</view>
<view class="sub-title">
<text>未注册的手机号登录后将自动注册</text>
</view>
</view>
<!-- 表单 -->
<view class="login-form">
<!-- 手机号 -->
<view class="form-item">
<input class="form-item--input" type="number" v-model="mobile" maxlength="11" placeholder="请输入手机号码" />
</view>
<!-- 图形验证码 -->
<view class="form-item">
<input class="form-item--input" type="text" v-model="captchaCode" maxlength="5" placeholder="请输入图形验证码" />
<view class="form-item--parts">
<view class="captcha" @click="getCaptcha()">
<image class="image" :src="captcha.base64"></image>
</view>
</view>
</view>
<!-- 短信验证码 -->
<view class="form-item">
<input class="form-item--input" type="number" v-model="smsCode" maxlength="6" placeholder="请输入短信验证码" />
<view class="form-item--parts">
<view class="captcha-sms" @click="handelSmsCaptcha()">
<text v-if="!smsState" class="activate">获取验证码</text>
<text v-else class="un-activate">重新发送({{ times }})</text>
</view>
</view>
</view>
<!-- 登录按钮 -->
<view class="login-button" @click="handleLogin">
<text>登录</text>
</view>
</view>
<!-- 微信授权手机号一键登录 -->
<!-- #ifdef MP-WEIXIN -->
<MpWeixinMobile v-if="isMpWeixinMobile" :isParty="isParty" :partyData="partyData" />
<!-- #endif -->
</view>
</template>
<script>
import store from '@/store'
import * as CaptchaApi from '@/api/captcha'
import * as Verify from '@/utils/verify'
import MpWeixinMobile from './mp-weixin-mobile'
// ()
const times = 60
//
const GET_CAPTCHA = 10
const SUBMIT_LOGIN = 20
export default {
components: {
MpWeixinMobile
},
props: {
//
isParty: {
type: Boolean,
default: () => false
},
//
partyData: {
type: Object
},
//
isMpWeixinMobile: {
type: Boolean,
default: () => false
},
},
data() {
return {
//
isLoading: false,
//
captcha: {},
//
smsState: false,
//
times,
//
mobile: '',
//
captchaCode: '',
//
smsCode: ''
}
},
/**
* 生命周期函数--监听页面加载
*/
created() {
//
this.getCaptcha()
},
methods: {
//
getCaptcha() {
const app = this
CaptchaApi.image()
.then(result => app.captcha = result.data)
},
//
handelSmsCaptcha() {
const app = this
if (!app.isLoading && !app.smsState && app.formValidation(GET_CAPTCHA)) {
app.sendSmsCaptcha()
}
},
//
formValidation(scene = GET_CAPTCHA) {
const app = this
//
if (scene === GET_CAPTCHA) {
if (!app.validteMobile(app.mobile) || !app.validteCaptchaCode(app.captchaCode)) {
return false
}
}
//
if (scene === SUBMIT_LOGIN) {
if (!app.validteMobile(app.mobile) || !app.validteSmsCode(app.smsCode)) {
return false
}
}
return true
},
//
validteMobile(str) {
if (Verify.isEmpty(str)) {
this.$toast('请先输入手机号')
return false
}
if (!Verify.isMobile(str)) {
this.$toast('请输入正确格式的手机号')
return false
}
return true
},
//
validteCaptchaCode(str) {
if (Verify.isEmpty(str)) {
this.$toast('请先输入图形验证码')
return false
}
return true
},
//
validteSmsCode(str) {
if (Verify.isEmpty(str)) {
this.$toast('请先输入短信验证码')
return false
}
return true
},
//
sendSmsCaptcha() {
const app = this
app.isLoading = true
CaptchaApi.sendSmsCaptcha({
form: {
captchaKey: app.captcha.key,
captchaCode: app.captchaCode,
mobile: app.mobile
}
})
.then(result => {
//
app.$toast(result.message)
//
app.timer()
})
.catch(() => app.getCaptcha())
.finally(() => app.isLoading = false)
},
//
timer() {
const app = this
app.smsState = true
const inter = setInterval(() => {
app.times = app.times - 1
if (app.times <= 0) {
app.smsState = false
app.times = times
clearInterval(inter)
}
}, 1000)
},
//
handleLogin() {
const app = this
if (!app.isLoading && app.formValidation(SUBMIT_LOGIN)) {
app.submitLogin()
}
},
//
submitLogin() {
const app = this
app.isLoading = true
store.dispatch('Login', {
smsCode: app.smsCode,
mobile: app.mobile,
isParty: app.isParty,
partyData: app.partyData,
refereeId: store.getters.refereeId
})
.then(result => {
//
app.$toast(result.message)
// :
uni.$emit('syncRefresh', true)
//
setTimeout(() => app.onNavigateBack(1), 2000)
})
.catch(err => {
//
if (err.result.data.isBack) {
setTimeout(() => app.onNavigateBack(1), 2000)
}
})
.finally(() => app.isLoading = false)
},
/**
* 登录成功-跳转回原页面
*/
onNavigateBack(delta = 1) {
const pages = getCurrentPages()
if (pages.length > 1) {
uni.navigateBack({
delta: Number(delta || 1)
})
} else {
this.$navTo('pages/index/index')
}
}
}
}
</script>
<style lang="scss" scoped>
.container {
padding: 100rpx 60rpx;
min-height: 100vh;
background-color: #fff;
}
//
.header {
margin-bottom: 60rpx;
.title {
color: #191919;
font-size: 54rpx;
}
.sub-title {
margin-top: 20rpx;
color: #b3b3b3;
font-size: 28rpx;
}
}
//
.form-item {
display: flex;
align-items: center;
padding: 18rpx;
border-bottom: 1rpx solid #f3f1f2;
margin-bottom: 30rpx;
height: 96rpx;
&--input {
font-size: 28rpx;
letter-spacing: 1rpx;
flex: 1;
height: 100%;
}
&--parts {
min-width: 100rpx;
}
//
.captcha {
height: 60rpx;
.image {
display: block;
width: 192rpx;
height: 100%;
}
}
//
.captcha-sms {
font-size: 28rpx;
line-height: 50rpx;
padding-right: 20rpx;
.activate {
color: $main-bg;
}
.un-activate {
color: #9e9e9e;
}
}
}
//
.login-button {
width: 100%;
height: 86rpx;
margin-top: 80rpx;
background: linear-gradient(to right, $main-bg, $main-bg2);
color: $main-text;
border-radius: 80rpx;
box-shadow: 0px 10px 20px 0px rgba(0, 0, 0, 0.1);
letter-spacing: 5rpx;
display: flex;
justify-content: center;
align-items: center;
}
</style>

@ -4,14 +4,48 @@
<!-- 页面头部 -->
<view class="header">
<view class="title">
<text>手机号登录</text>
<text>欢迎使用</text>
</view>
<view class="sub-title">
<!-- <view class="sub-title">
<text>未注册的手机号登录后将自动注册</text>
</view>
</view> -->
</view>
<view class="tabs">
<view class="tabItem" v-for="item in tabList" @click="changeTab(item)" :key="item.id">
<text :class="item.id==activeIndex?'activeText':''">{{item.name}}</text>
<view class="flag" v-if="activeIndex==item.id"></view>
</view>
</view>
<!-- 密码登录 -->
<view class="mimaForm" v-if="activeIndex==1">
<view class="formItem">
<image src="../../../static/phone.png" mode=""></image>
<u-input v-model="value" type="text" height="90" />
</view>
<view class="formItem">
<image src="../../../static/psw.png" mode=""></image>
<u-input v-model="value" type="password" height="90" />
</view>
<!-- <u-checkbox-group class="checkBox" > -->
<view class="xinxi">
<u-checkbox v-model="checked" active-color="#F92404" @change="changeHandle">
<view class="infoText">
我已认真阅读并同意<text>服务协议</text><text>隐私政策</text>
</view>
</u-checkbox>
</view>
<view class="loginBtn">
登录
</view>
<view class="tool">
<text class="forget">忘记密码</text>
<text class="register">注册账号</text>
</view>
<!-- </u-checkbox-group> -->
</view>
<!-- 表单 -->
<view class="login-form">
<view class="login-form" v-if="activeIndex==2">
<!-- 手机号 -->
<view class="form-item">
<input class="form-item--input" type="number" v-model="mobile" maxlength="11" placeholder="请输入手机号码" />
@ -43,7 +77,7 @@
<!-- 微信授权手机号一键登录 -->
<!-- #ifdef MP-WEIXIN -->
<MpWeixinMobile v-if="isMpWeixinMobile" :isParty="isParty" :partyData="partyData" />
<!-- <MpWeixinMobile v-if="isMpWeixinMobile" :isParty="isParty" :partyData="partyData" /> -->
<!-- #endif -->
</view>
@ -99,7 +133,13 @@
//
captchaCode: '',
//
smsCode: ''
smsCode: '',
activeIndex:1,
tabList:[
{id:1,name:'密码登录'},
{id:2,name:'验证码登录'},
],
checked:false
}
},
@ -112,7 +152,13 @@
},
methods: {
changeHandle(val){
this.checked = val;
},
changeTab(item){
this.activeIndex=item.id
},
//
getCaptcha() {
const app = this
@ -229,6 +275,9 @@
mobile: app.mobile,
isParty: app.isParty,
partyData: app.partyData,
squied_smsCode:null,
squied_mobile:'',
password:'',
refereeId: store.getters.refereeId
})
.then(result => {
@ -351,4 +400,99 @@
justify-content: center;
align-items: center;
}
.tabs{
display: flex;
text{
font-family: Source Han Sans SC;
font-weight: 400;
font-size: 32rpx;
color: #999999;
}
.flag{
width: 110rpx;
height: 8rpx;
background: #F92404;
border-radius: 4rpx;
margin: 12rpx auto;
}
.activeText{
font-family: Source Han Sans SC;
font-weight: 400;
font-size: 32rpx;
color: #222222;
}
.tabItem{
margin-right: 60rpx;
}
}
</style>
<style lang="scss">
.mimaForm{
.formItem{
position: relative;
margin-top: 20rpx;
background: #F7F7F7;
border-radius: 45px;
border: 1px solid #EAEAEA;
padding-left: 60rpx;
padding-right: 30rpx;
image{
width:30rpx;
height:30rpx;
position: absolute;
z-index: 1;
top: 50%;
transform: translateY(-50%);
left: 20rpx;
}
}
.xinxi{
margin-top:43rpx;
.infoText{
font-family: Source Han Sans SC;
font-weight: 400;
font-size: 24rpx;
color: #999999;
text{
color: #F92404;
}
}
}
.loginBtn{
padding:30rpx 0;
background: #F92404;
border-radius: 45px;
font-family: Source Han Sans SC;
font-weight: 400;
font-size: 34rpx;
color: #FFFFFF;
text-align: center;
margin-top:60rpx;
}
.tool{
display: flex;
align-items: center;
justify-content: space-between;
margin-top:29rpx;
.forget{
font-family: Source Han Sans SC;
font-weight: 400;
font-size: 28rpx;
color: #999999;
}
.register{
font-family: Source Han Sans SC;
font-weight: 400;
font-size: 28rpx;
color: #F92404;
}
}
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 713 B

Loading…
Cancel
Save