全新UI视觉体验,移动端API优化降低重复调用,提高并发6倍,修复N多Bug
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view v-if="isUp">
|
||||
<view class="mobile-bg" @click="close"></view>
|
||||
<view class="mobile-mask animated" :class="{slideInUp:isUp}">
|
||||
<view class="mobile-bg" v-if="isShow" @click="close"></view>
|
||||
<view class="mobile-mask animated" :class="{slideInUp:isUp}" :style="{position:isPos?'fixed':'static'}">
|
||||
<view class="input-item">
|
||||
<input type="text" v-model="account" placeholder="输入手机号" />
|
||||
</view>
|
||||
@@ -9,7 +9,7 @@
|
||||
<input type="text" v-model="codeNum" placeholder="输入验证码" />
|
||||
<button class="code" :disabled="disabled" @click="code">{{text}}</button>
|
||||
</view>
|
||||
<view class="sub_btn" @click="loginBtn">立即登录</view>
|
||||
<view class="sub_btn" @click="loginBtn">{{(!userInfo.phone && isLogin) || (userInfo.phone && isLogin)?'立即绑定':'立即登录'}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -18,6 +18,7 @@
|
||||
const app = getApp();
|
||||
import sendVerifyCode from "@/mixins/SendVerifyCode";
|
||||
import Routine from '@/libs/routine';
|
||||
import {mapGetters} from "vuex";
|
||||
import {
|
||||
loginMobile,
|
||||
registerVerify,
|
||||
@@ -26,32 +27,59 @@
|
||||
phoneSilenceAuth,
|
||||
phoneWxSilenceAuth
|
||||
} from "@/api/user";
|
||||
import { bindingPhone } from '@/api/api.js'
|
||||
import { getUserPhone } from '@/api/public';
|
||||
export default{
|
||||
name:'login_mobile',
|
||||
props:{
|
||||
isUp:{
|
||||
type:Boolean,
|
||||
default:false,
|
||||
import {
|
||||
bindingPhone
|
||||
} from '@/api/api.js'
|
||||
import {
|
||||
getUserPhone,
|
||||
iosBinding
|
||||
} from '@/api/public';
|
||||
const BACK_URL = "login_back_url";
|
||||
export default {
|
||||
name: 'login_mobile',
|
||||
computed: mapGetters(['userInfo','isLogin']),
|
||||
props: {
|
||||
isUp: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
authKey:{
|
||||
type:String,
|
||||
default:'',
|
||||
authKey: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
isShow: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
isPos: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
appleShow: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
platform: {
|
||||
type: String,
|
||||
default: '',
|
||||
}
|
||||
},
|
||||
data(){
|
||||
data() {
|
||||
return {
|
||||
keyCode:'',
|
||||
account:'',
|
||||
codeNum:''
|
||||
keyCode: '',
|
||||
account: '',
|
||||
codeNum: '',
|
||||
isApp: 0
|
||||
}
|
||||
},
|
||||
mixins: [sendVerifyCode],
|
||||
mounted() {
|
||||
//this.getCode();
|
||||
},
|
||||
methods:{
|
||||
onLoad() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
// 获取验证码
|
||||
async code() {
|
||||
let that = this;
|
||||
@@ -61,12 +89,14 @@
|
||||
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
|
||||
title: '请输入正确的手机号码'
|
||||
});
|
||||
await registerVerify(that.account).then(res=>{
|
||||
that.$util.Tips({title:res.msg});
|
||||
await registerVerify(that.account).then(res => {
|
||||
that.$util.Tips({
|
||||
title: res.msg
|
||||
});
|
||||
that.sendCode();
|
||||
}).catch(err=>{
|
||||
}).catch(err => {
|
||||
return that.$util.Tips({
|
||||
title:err
|
||||
title: err
|
||||
})
|
||||
})
|
||||
},
|
||||
@@ -81,11 +111,11 @@
|
||||
});
|
||||
});
|
||||
},
|
||||
close(){
|
||||
this.$emit('close',false)
|
||||
close() {
|
||||
this.$emit('close', false)
|
||||
},
|
||||
// 登录
|
||||
loginBtn(){
|
||||
loginBtn() {
|
||||
let that = this
|
||||
if (!that.account) return that.$util.Tips({
|
||||
title: '请填写手机号码'
|
||||
@@ -99,47 +129,66 @@
|
||||
if (!/^[\w\d]+$/i.test(that.codeNum)) return that.$util.Tips({
|
||||
title: '请输入正确的验证码'
|
||||
});
|
||||
uni.showLoading({ title: '正在登录中' });
|
||||
getUserPhone({
|
||||
captcha: that.codeNum,
|
||||
phone: that.account,
|
||||
spid: app.globalData.spid,
|
||||
spread: app.globalData.code,
|
||||
type: 'public',
|
||||
key: this.authKey
|
||||
}).then(res=>{
|
||||
let time = res.data.expires_time - this.$Cache.time();
|
||||
this.$store.commit('LOGIN', {
|
||||
token: res.data.token,
|
||||
time: time
|
||||
});
|
||||
this.getUserInfo();
|
||||
}).catch(error=>{
|
||||
uni.hideLoading()
|
||||
this.$util.Tips({
|
||||
title:error
|
||||
uni.showLoading({
|
||||
title: !this.userInfo.phone && this.isLogin?'正在绑定中':'正在登录中'
|
||||
});
|
||||
if (!this.userInfo.phone && this.isLogin) {
|
||||
iosBinding({
|
||||
captcha: that.codeNum,
|
||||
phone: that.account
|
||||
}).then(res => {
|
||||
that.$util.Tips({
|
||||
title: '绑定手机号成功',
|
||||
icon: 'success'
|
||||
}, {
|
||||
tab: 3
|
||||
})
|
||||
that.isApp = 1;
|
||||
that.getUserInfo();
|
||||
}).catch(error => {
|
||||
uni.hideLoading()
|
||||
that.$util.Tips({
|
||||
title: error
|
||||
})
|
||||
})
|
||||
})
|
||||
} else {
|
||||
getUserPhone({
|
||||
captcha: that.codeNum,
|
||||
phone: that.account,
|
||||
// #ifdef H5
|
||||
type: 'public',
|
||||
// #endif
|
||||
key: that.authKey
|
||||
}).then(res => {
|
||||
that.$store.commit('LOGIN', {
|
||||
token: res.data.token
|
||||
});
|
||||
that.$store.commit("SETUID", res.data.uid);
|
||||
that.getUserInfo();
|
||||
}).catch(error => {
|
||||
uni.hideLoading()
|
||||
that.$util.Tips({
|
||||
title: error
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
// #ifdef MP
|
||||
phoneSilenceAuth(code){
|
||||
phoneSilenceAuth(code) {
|
||||
let self = this
|
||||
phoneSilenceAuth({
|
||||
code:code,
|
||||
code: code,
|
||||
spid: app.globalData.spid,
|
||||
spread: app.globalData.code,
|
||||
phone:this.account,
|
||||
captcha:this.codeNum
|
||||
}).then(res=>{
|
||||
let time = res.data.expires_time - this.$Cache.time();
|
||||
this.$store.commit('LOGIN', {
|
||||
token: res.data.token,
|
||||
time: time
|
||||
});
|
||||
phone: this.account,
|
||||
captcha: this.codeNum
|
||||
}).then(res => {
|
||||
this.$store.commit('LOGIN', res.data.token);
|
||||
this.$store.commit("SETUID", res.data.uid);
|
||||
this.getUserInfo();
|
||||
}).catch(error=>{
|
||||
}).catch(error => {
|
||||
self.$util.Tips({
|
||||
title:error
|
||||
title: error
|
||||
})
|
||||
})
|
||||
},
|
||||
@@ -151,52 +200,56 @@
|
||||
let that = this;
|
||||
getUserInfo().then(res => {
|
||||
uni.hideLoading();
|
||||
that.userInfo = res.data
|
||||
that.$store.commit("SETUID", res.data.uid);
|
||||
that.$store.commit("UPDATE_USERINFO", res.data);
|
||||
// #ifdef MP
|
||||
// #ifdef MP
|
||||
that.$util.Tips({
|
||||
title:'登录成功',
|
||||
icon:'success'
|
||||
},{
|
||||
tab:3
|
||||
title: '登录成功',
|
||||
icon: 'success'
|
||||
}, {
|
||||
tab: 3
|
||||
})
|
||||
that.close()
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
that.$emit('wechatPhone',true)
|
||||
that.$emit('wechatPhone', true)
|
||||
// #endif
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="stylus">
|
||||
.mobile-bg{
|
||||
<style lang="stylus" scoped>
|
||||
.mobile-bg {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0,0,0,0.5);
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.isPos {
|
||||
position: static;
|
||||
}
|
||||
|
||||
.mobile-mask {
|
||||
z-index: 20;
|
||||
position: fixed;
|
||||
// position: fixed;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
padding: 67rpx 30rpx;
|
||||
background: #fff;
|
||||
.input-item{
|
||||
|
||||
.input-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
height: 86rpx;
|
||||
margin-bottom: 38rpx;
|
||||
input{
|
||||
|
||||
input {
|
||||
flex: 1;
|
||||
display: block;
|
||||
height: 100%;
|
||||
@@ -204,7 +257,8 @@
|
||||
border-radius: 43rpx;
|
||||
border: 1px solid #DCDCDC;
|
||||
}
|
||||
.code{
|
||||
|
||||
.code {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -213,15 +267,17 @@
|
||||
margin-left: 30rpx;
|
||||
background: rgba(233, 51, 35, 0.05);
|
||||
font-size: 28rpx;
|
||||
color: #E93323;
|
||||
color: $theme-color;
|
||||
border-radius: 43rpx;
|
||||
&[disabled]{
|
||||
|
||||
&[disabled] {
|
||||
background: rgba(0, 0, 0, 0.05);
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
}
|
||||
.sub_btn{
|
||||
|
||||
.sub_btn {
|
||||
width: 690rpx;
|
||||
height: 86rpx;
|
||||
line-height: 86rpx;
|
||||
@@ -233,7 +289,8 @@
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
.animated{
|
||||
animation-duration:.4s
|
||||
|
||||
.animated {
|
||||
animation-duration: .4s
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user