Commit fdb1bb4f by zhangquan

登录ui改版

1 parent 865db9cf
......@@ -45,11 +45,13 @@ class UsersApi {
}
/**授权手机号登录 */
async authUserPhone(detail, loginToken) {
console.log(221)
if (!loginToken) {
wx.$api.showToast('缺少loginToken')
Promise.reject()
return
}
console.log(111)
if (detail.errMsg && detail.errMsg == 'getPhoneNumber:fail user deny') Promise.reject()
delete detail.errMsg
if (detail.iv && detail.encryptedData) {
......
.login-bg{
position: absolute;
bottom: 0;
left: 0;
top: 0;
}
.container{
height: 100vh;
background-color: #fff;
display: flex;
flex-direction: column;
position: relative;
.salutation-wrap{
padding: 112rpx 96rpx 0;
padding: 96rpx 96rpx 0;
flex: 1;
.salutation{
height: 88rpx;
......@@ -24,18 +29,28 @@
color: #333333;
line-height: 64rpx;
}
.logo{
width: 100%;
display: flex;
align-items: center;
justify-content: center;
margin-top: 80rpx;
.logo-img{
width:480rpx;
height: 480rpx;
border: 1rpx dashed #E2E2E2;
}
}
}
.footer{
width: 100%;
height: 850rpx;
background-size: 100% 100%;
margin-top: 120rpx;
.login-wrap{
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
flex-wrap: nowrap;
margin-top: 500rpx;
.login-btn{
width: 590rpx;
height: 88rpx;
......@@ -52,8 +67,9 @@
}
.phone-btn{
margin-top: 40rpx;
background: #F9F9F9;
background: #fff;
color: #1B233D;
border: 2rpx solid #DCDFE6;
}
}
}
......
// pages/login.js
const navStyle = "background-color: transparent;";
import USERAPI from '~/api/usersApi/index'
import {
selectAccountLogin,
......@@ -10,29 +10,34 @@ Page({
* 页面的初始数据
*/
data: {
navStyle,
padHeight:0,
headerHeight: 0,
loginMethod: 0,
formData:{
phone:'13097951885',
code:'8888'
phone:'',
code:''
},
authorized: false
},
navbarReady(e) {
let {
height
} = e.detail;
this.setData({
headerHeight: height,
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
this.init()
},
/**页面初始化 */
async init() {
try {
const {
......@@ -67,26 +72,26 @@ Page({
})
},
inputBindFocus(e){
if(this.data.padHeight) return;
this.setData({
padHeight: e.detail.height
})
this.pageScrollToBottom()
},
inputBindBlur(){
this.setData({
padHeight: 0
})
},
pageScrollToBottom() {
wx.createSelectorQuery().select('.container').boundingClientRect(function(rect) {
// 使页面滚动到底部
wx.pageScrollTo({
scrollTop: rect.height
})
}).exec()
},
// inputBindFocus(e){
// if(this.data.padHeight) return;
// this.setData({
// padHeight: e.detail.height
// })
// this.pageScrollToBottom()
// },
// inputBindBlur(){
// this.setData({
// padHeight: 0
// })
// },
// pageScrollToBottom() {
// wx.createSelectorQuery().select('.container').boundingClientRect(function(rect) {
// // 使页面滚动到底部
// wx.pageScrollTo({
// scrollTop: rect.height
// })
// }).exec()
// },
handleLogin(){
const {
formData
......@@ -95,12 +100,15 @@ Page({
mobile: formData.phone,
code: formData.code
}
if(this.data.showLoading) return;
this.setShowLoading(true)
USERAPI.phoneSmsLogin(obj).then(({
code,
data,
message,
errId
}) => {
this.setShowLoading(false)
if (code == '0') {
this.checkLoginUserInfo(data)
} else if(errId=='30990103') {
......@@ -111,6 +119,7 @@ Page({
wx.$api.showToast(message || '系统异常')
}
}).catch(err => {
this.setShowLoading(false)
wx.$api.showToast('系统异常')
})
},
......@@ -131,15 +140,22 @@ Page({
sessionId
})
},
switchLoginMethod(){
switchLoginMethod(e){
const {type} = e.target.dataset
this.setData({
loginMethod: 1
loginMethod: type
})
},
input(e){
const {value} = e.detail
const {name} = e.target.dataset
console.log(e,this.data.formData,'88')
this.setData({
[`formData.${name}`] : value
})
let a = this.validate.methods.tel(formData.phone)
console.log(a)
},
/**获取验证码 */
getSmsCode() {
......@@ -187,16 +203,23 @@ Page({
})
}, 1e3)
},
setShowLoading(val){
this.setData({
showLoading: val
})
},
wxLogin({
detail
}) {
if (!detail.code) return
if (!detail.code || this.data.showLoading) return
this.setShowLoading(true)
USERAPI.authUserPhone(detail, this.loginToken).then(({
code,
data,
message,
errId
}) => {
this.setShowLoading(false)
if (code == '0'){
this.checkLoginUserInfo(data)
}else if(errId=='30990103'){
......@@ -209,6 +232,7 @@ Page({
}).catch(({
errMsg
}) => {
this.setShowLoading(false)
wx.$api.showToast('系统异常')
})
},
......
{
"usingComponents": {},
"navigationBarTitleText": "登录"
"navigationStyle": "custom"
}
\ No newline at end of file
......@@ -9,7 +9,15 @@
color: #333333;
}
.login-input-wrap{
margin-top: 450rpx !important;
.login-title{
width: 590rpx;
text-align: left;
font-weight: 500;
font-size: 48rpx;
color: #333333;
line-height: 64rpx;
margin-bottom: 80rpx;
}
.phone, .code{
background-color: #fff;
display: flex;
......@@ -19,10 +27,10 @@
text-align: left!important;
}
.phone{
margin-bottom: 24rpx;
margin-bottom: 48rpx;
}
.code{
margin-bottom: 50rpx;
margin-bottom: 128rpx;
}
.code-btn{
width: 180rpx;
......@@ -33,8 +41,21 @@
border-radius: 28rpx;
font-size: 24rpx;
color: #666666;
border: none;
}
.code-btn::after{
border: none;
}
.placeholderClass,.placeholder{
color: #BCBCBC;
}
.other{
margin-top: 64rpx;
font-size: 28rpx;
letter-spacing: 0;
color: #A8ABBC;
text{
color: #5570D4;
}
}
}
<!--pages/login.wxml-->
<view class="container" style="padding-bottom: {{padHeight}}px;">
<view class="salutation-wrap">
<navigation-bar bindnavbarReady="navbarReady" navStyle="{{navStyle}}" page-title="门店助手">
<text>门店助手</text>
</navigation-bar>
<image class="login-bg" src="{{IMGURL}}login.png"></image>
<view class="container" style="padding-top: {{headerHeight}}px;">
<view class="salutation-wrap" wx:if="{{loginMethod==0}}">
<view class="salutation">您好</view>
<view class="welcome">欢迎登录门店助手</view>
<view class="logo">
<image class="logo-img" src="{{IMGURL}}login-logo.png"></image>
</view>
</view>
<view class="footer" style="background-image: url('{{IMGURL}}register.png');">
<view class="footer">
<view class="login-wrap" wx:if="{{loginMethod==0}}">
<!-- <view class="wx-btn login-btn">微信授权登录</view> -->
<button class="wx-btn login-btn" hover-class="btn-hover" open-type="getPhoneNumber" bindgetphonenumber="wxLogin">微信授权登录</button>
<view class="phone-btn login-btn" bindtap="switchLoginMethod">手机号码登录</view>
<button class="wx-btn login-btn" hover-class="btn-hover" open-type="getPhoneNumber" bindgetphonenumber="wxLogin" loading="{{showLoading}}">微信授权登录</button>
<view class="phone-btn login-btn" bindtap="switchLoginMethod" data-type="1">手机号码登录</view>
</view>
<view class="login-wrap login-input-wrap" wx:else>
<view class="login-btn phone">
<input maxlength="11" adjust-position="{{false}}" bindfocus="inputBindFocus" bindblur="inputBindBlur" placeholder-class="placeholderClass" placeholder="请输入手机号码" bindinput="input" value="{{formData.phone}}" data-name="phone"/>
</view>
<view class="login-btn code">
<input maxlength="4" adjust-position="{{false}}" bindfocus="inputBindFocus" bindblur="inputBindBlur" placeholder-class="placeholder" placeholder="请输入验证码"
bindinput="input" value="{{formData.code}}" data-name="code"/>
<view class="code-btn" bindtap="getSmsCode">{{count? count + 's':'获取验证码'}}</view>
<block wx:else>
<view class="login-wrap login-input-wrap">
<view class="login-title">手机号码登录</view>
<view class="login-btn phone">
<input maxlength="11" adjust-position="{{false}}" placeholder-class="placeholderClass" placeholder="请输入手机号码" bindinput="input" value="{{formData.phone}}" data-name="phone"/>
</view>
<view class="login-btn code">
<input maxlength="4" adjust-position="{{false}}" placeholder-class="placeholder" placeholder="请输入验证码"
bindinput="input" value="{{formData.code}}" data-name="code"/>
<button disabled="{{phoneReady}}" class="code-btn" bindtap="getSmsCode">{{count? count + 's':'获取验证码'}}</button>
</view>
<view class="login-btn wx-btn" bindtap="handleLogin">登录</view>
<view class="other">或 <text bindtap="switchLoginMethod" data-type="0">微信登录</text></view>
</view>
<view class="login-btn wx-btn" bindtap="handleLogin">登录</view>
</view>
</block>
</view>
<popup bindconfirm="goServicePage" show="{{authorized}}" confirmText="联系客服" title="提示" height="560rpx">
<view class="popup-content">当前登录手机号未认证,请联系客服处理</view>
......
import USERAPI from '~/api/usersApi/index'
const navStyle = "background-color: transparent;";
Page({
/**
* 页面的初始数据
*/
data: {
navStyle,
headerHeight:0
},
navbarReady(e) {
let {
height
} = e.detail;
this.setData({
headerHeight: height,
});
},
async init() {
try {
......@@ -46,7 +56,6 @@ Page({
toRegister({
detail
}) {
console.log(detail,'detaildetail')
if (!detail.code) return
USERAPI.authUserPhone(detail, this.loginToken).then(({
code,
......@@ -55,7 +64,7 @@ Page({
errId
}) => {
if (code == '0'){
wx.$router.reLaunch('/pages/tab/index/index')
this.checkLoginUserInfo(data)
}else{
if(errId=='30990103'){
let params = {
......@@ -74,6 +83,22 @@ Page({
wx.$api.showToast(message || '系统异常')
})
},
checkLoginUserInfo({
loginUserInfoList,
sessionId
}) {
/**多个账号 */
console.log(loginUserInfoList,'loginUserInfoList')
if (loginUserInfoList.length > 1) wx.$router.go('/pages/authentication/accountItems/accountItems', {
sessionId,
...this.options
})
/**只有一个账号 */
else selectAccountLogin({
id: loginUserInfoList[0].uuid,
sessionId
})
},
/**
* 生命周期函数--监听页面加载
*/
......
{
"usingComponents": {},
"navigationBarTitleText": "注册"
"navigationStyle": "custom"
}
\ No newline at end of file
<!--pages/login/register/register.wxml-->
<view class="container">
<navigation-bar bindnavbarReady="navbarReady" navStyle="{{navStyle}}" page-title="门店助手">
<text>门店助手</text>
</navigation-bar>
<image class="login-bg" src="{{IMGURL}}login.png"></image>
<view class="container" style="padding-top: {{headerHeight}}px;">
<view class="salutation-wrap">
<view class="salutation">您好</view>
<view class="welcome">欢迎注册门店助手</view>
<view class="logo">
<image class="logo-img" src="{{IMGURL}}login-logo.png"></image>
</view>
</view>
<view class="footer" style="background-image: url('{{IMGURL}}register.png');">
<view class="login-wrap">
......
......@@ -104,9 +104,13 @@ Page({
}
console.log(params,'ddd')
USERAPI.register(params).then((res) => {
console.log(res,'paramsparams')
if (code == '0'){
wx.$router.go('/pages/authentication/registerSuccess/registerSuccess',{type:0})
}else{
wx.$api.showToast(message || '系统异常')
}
})
// wx.$router.go('/pages/authentication/registerSuccess/registerSuccess',{type:0})
//
},
inputStaffNamme(e){
const {value} = e.detail
......
......@@ -9,10 +9,6 @@ Page({
interval:null
},
onRoute(options){
console.log(options,111)
this.setData({
type: options.type
})
},
/**
* 生命周期函数--监听页面加载
......
......@@ -6,7 +6,7 @@ Page({
* 页面的初始数据
*/
data: {
btnHeight: 0,
headerHeight: 0,
navStyle,
},
navbarReady(e) {
......@@ -14,7 +14,7 @@ Page({
height
} = e.detail;
this.setData({
btnHeight: height,
headerHeight: height,
});
},
/**
......
<view style="background:#fff;" class="container">
<image style="height: {{btnHeight+45}}px;" src="{{IMGURL}}discovery_center_bg.png" class="bg-img"></image>
<image style="height: {{headerHeight+45}}px;" src="{{IMGURL}}discovery_center_bg.png" class="bg-img"></image>
<navigation-bar bindnavbarReady="navbarReady" navStyle="{{navStyle}}" page-title="发现">
<text>发现</text>
</navigation-bar>
<view style="padding-top: {{btnHeight}}px;">
<view style="padding-top: {{headerHeight}}px;">
<product></product>
</view>
</view>
\ No newline at end of file
......@@ -6,7 +6,7 @@ const target = ['ip', 'dev', 'uat', 'prod']
2测试
3生产
*/
const index = 0
const index = 1
const secretKey = {
ip: {},
dev: {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!