Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wx-school-app
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
姜雷
wx-school-app
Commits
123868be
Commit
123868be
authored
Mar 11, 2019
by
姜雷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改登录逻辑
parent
79571db0
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
50 additions
and
241 deletions
+50
-241
index.ts
src/api/index.ts
+9
-1
CheckTelephone.scss
src/pages/CheckTelephone/CheckTelephone.scss
+0
-84
CheckTelephone.tsx
src/pages/CheckTelephone/CheckTelephone.tsx
+0
-115
Login.tsx
src/pages/Login/Login.tsx
+21
-11
Register.tsx
src/pages/Register/Register.tsx
+4
-2
index.tsx
src/pages/index/index.tsx
+14
-24
userinfo.ts
src/store/rootReducers/userinfo.ts
+2
-3
Customer.ts
src/types/Customer/Customer.ts
+0
-1
No files found.
src/api/index.ts
View file @
123868be
...
@@ -4,6 +4,8 @@ import {
...
@@ -4,6 +4,8 @@ import {
BASE_SERVER_URL
,
BASE_SERVER_URL
,
CUSTOMER_SERVER_URL
,
CUSTOMER_SERVER_URL
,
SCHOOL_MAIN_URL
,
SCHOOL_MAIN_URL
,
LogoutCode
,
SuccessCode
,
}
from
'../constants/index'
;
}
from
'../constants/index'
;
export
type
ResponseDataEntity
<
T
>
=
{
export
type
ResponseDataEntity
<
T
>
=
{
...
@@ -33,9 +35,15 @@ const createFetch = (basePath: string) => {
...
@@ -33,9 +35,15 @@ const createFetch = (basePath: string) => {
},
},
url
:
basePath
+
entity
.
url
,
url
:
basePath
+
entity
.
url
,
}).
then
(({
data
}:
ResponseEntity
)
=>
{
}).
then
(({
data
}:
ResponseEntity
)
=>
{
if
(
data
.
code
===
1000
)
{
if
(
data
.
code
===
SuccessCode
)
{
return
data
;
return
data
;
}
}
if
(
data
.
code
===
LogoutCode
)
{
Taro
.
redirectTo
({
url
:
'/pages/Login/Login'
,
});
throw
data
;
}
Taro
.
showToast
({
Taro
.
showToast
({
title
:
data
.
msg
,
title
:
data
.
msg
,
icon
:
'none'
,
icon
:
'none'
,
...
...
src/pages/CheckTelephone/CheckTelephone.scss
deleted
100644 → 0
View file @
79571db0
.checkTelephone
{
width
:
100%
;
height
:
100%
;
overflow
:
hidden
;
// background: url('../../images/login/bg@2x.png') center;
background-size
:
cover
;
}
.loginBox
{
width
:
634px
;
height
:
538px
;
margin
:
180px
auto
0
;
background-color
:
rgba
(
255
,
255
,
255
,
0
.5
);
border-radius
:
8px
;
padding
:
50px
40px
0
;
line-height
:
88px
;
.loginBox-input
{
box-sizing
:
border-box
;
background-color
:
#fff
;
width
:
100%
;
height
:
88px
;
padding
:
0
20px
;
font-size
:
30px
;
margin-bottom
:
50px
;
border-radius
:
8px
;
color
:
#ff9000
;
}
.
loginBox-input
:
:-
webkit-input-placeholder
{
/* WebKit browsers */
color
:
#d9a842
;
}
.loginBox-button
{
font-size
:
28px
;
width
:
100%
;
height
:
88px
;
background-color
:
#ff9000
;
color
:
#fff
;
border
:
none
;
outline
:
none
;
border-radius
:
8px
;
}
.loginBox-button.big
{
font-size
:
34px
;
}
.loginBox-button.fetching
{
background-color
:
#ccc
;
}
.loginBox-vcodeBox
{
display
:
flex
;
}
.vcodeBox-input-wrap
{
flex
:
1
;
margin-right
:
20px
;
}
.vcodeBox-button-wrap
{
text-align
:
center
;
width
:
200px
;
height
:
88px
;
}
.countDownText
{
color
:
#ff9000
;
font-size
:
30px
;
}
}
.imgVcodeBox-wrap
{
.imgVcodeBox-content
{
width
:
380px
;
height
:
332px
;
}
.imgVcodeBox
{
display
:
flex
;
margin-bottom
:
60px
;
justify-content
:
space-between
;
}
.imgVcodeBox-item
{
width
:
180px
;
height
:
88px
;
background-color
:
#ffebcc
;
border-radius
:
8px
;
}
.loginBox-input
{
background-color
:
#ffebcc
;
color
:
#d9a842
;
}
}
src/pages/CheckTelephone/CheckTelephone.tsx
deleted
100644 → 0
View file @
79571db0
import
{
ComponentClass
}
from
'react'
;
import
Taro
,
{
Component
}
from
'@tarojs/taro'
;
import
{
View
,
Text
,
Button
,
Input
}
from
'@tarojs/components'
;
import
'./CheckTelephone.scss'
;
type
PageOwnProps
=
{};
type
PageState
=
{
count
:
number
;
timer
:
null
;
fetching
:
boolean
;
tel
:
string
;
code
:
string
;
sending
:
boolean
;
vcode
:
string
;
imgCode
:
string
;
imgVcode
:
string
;
dialogVisible
:
boolean
;
};
interface
CheckTelephone
{
state
:
PageState
;
}
class
CheckTelephone
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
timer
:
null
,
fetching
:
false
,
tel
:
''
,
code
:
''
,
count
:
60
,
sending
:
false
,
vcode
:
''
,
imgCode
:
''
,
imgVcode
:
''
,
dialogVisible
:
false
,
};
}
fetchImageVcode
=
()
=>
{
console
.
log
(
'in fetchImageVcode'
);
};
registerUser
=
()
=>
{
Taro
.
navigateTo
({
url
:
'/pages/Register/Register'
,
});
};
render
()
{
const
{
sending
,
count
}
=
this
.
state
;
return
(
<
View
className=
'checkTelephone'
>
<
View
className=
'loginBox'
>
<
Input
className=
'loginBox-input'
type=
'text'
placeholder=
'输入您的手机号'
/>
<
View
className=
'loginBox-vcodeBox'
>
<
View
className=
'vcodeBox-input-wrap'
>
<
Input
className=
'loginBox-input'
type=
'text'
placeholder=
'请输入短信验证码'
/>
</
View
>
<
View
className=
'vcodeBox-button-wrap'
>
{
sending
&&
<
Text
className=
'countDownText'
>
{
{
count
}
}
s
</
Text
>
}
<
Button
v
-
else
className=
'loginBox-button'
onClick=
{
this
.
fetchImageVcode
}
>
获取验证码
</
Button
>
</
View
>
</
View
>
<
Button
className=
'loginBox-button big'
onClick=
{
this
.
registerUser
}
>
登 录
</
Button
>
{
/* // <ks-Dialog
// class="imgVcodeBox-wrap"
// :visible.sync="dialogVisible"
// top="180px"
// >
// <View class="imgVcodeBox-content">
// <View class="imgVcodeBox">
// <View class="imgVcodeBox-item">
// <input
// class="loginBox-input"
// type="text"
// v-model="imgCode"
// maxlength="6"
// />
// </View>
// <CodeView class="imgVcodeBox-item" :value="imgVcode"></CodeView>
// </View>
// <button v-if="fetching" class="loginBox-button big fetching">
// 确认
// </button>
// <button v-else class="loginBox-button big" @click="fetchVcode">
// 确认
// </button>
// </View>
// </ks-Dialog> */
}
</
View
>
</
View
>
);
}
}
export
default
CheckTelephone
as
ComponentClass
<
PageOwnProps
,
PageState
>
;
src/pages/Login/Login.tsx
View file @
123868be
...
@@ -5,11 +5,12 @@ import { View, Button, Input, Navigator } from '@tarojs/components';
...
@@ -5,11 +5,12 @@ import { View, Button, Input, Navigator } from '@tarojs/components';
import
'./Login.scss'
;
import
'./Login.scss'
;
import
{
appLogin
}
from
'../../api/customer'
;
import
{
appLogin
}
from
'../../api/customer'
;
import
{
connect
}
from
'@tarojs/redux'
;
import
{
connect
}
from
'@tarojs/redux'
;
import
{
updateUserInfo
}
from
'../../store/rootReducers/userinfo'
;
import
{
updateUserInfo
,
UserState
}
from
'../../store/rootReducers/userinfo'
;
import
{
LoginInfoVo
}
from
'../../api/baseClass
'
;
import
{
NotRegisterCode
}
from
'../../constants/index
'
;
type
PageDispatchProps
=
{
type
PageDispatchProps
=
{
updateUserInfo
:
(
e
:
LoginInfoVo
)
=>
void
;
userinfo
:
UserState
;
updateUserInfo
:
(
e
:
UserState
)
=>
void
;
};
};
type
PageState
=
{
type
PageState
=
{
...
@@ -23,9 +24,9 @@ interface Login {
...
@@ -23,9 +24,9 @@ interface Login {
}
}
@
connect
(
@
connect
(
(
)
=>
({
}),
(
{
userinfo
})
=>
({
userinfo
}),
dispatch
=>
({
dispatch
=>
({
updateUserInfo
(
data
:
LoginInfoVo
)
{
updateUserInfo
(
data
:
UserState
)
{
dispatch
(
updateUserInfo
(
data
));
dispatch
(
updateUserInfo
(
data
));
},
},
}),
}),
...
@@ -64,24 +65,33 @@ class Login extends Component {
...
@@ -64,24 +65,33 @@ class Login extends Component {
loginHandle
():
void
{
loginHandle
():
void
{
if
(
this
.
validataLoginData
())
{
if
(
this
.
validataLoginData
())
{
const
{
updateUserInfo
,
userinfo
}
=
this
.
props
;
const
{
account
,
pwd
}
=
this
.
state
;
const
{
account
,
pwd
}
=
this
.
state
;
console
.
log
(
'in loginHandle'
);
console
.
log
(
'in loginHandle'
);
appLogin
({
appLogin
({
loginAccount
:
account
,
loginAccount
:
account
,
password
:
pwd
,
password
:
pwd
,
code
:
userinfo
.
code
,
})
})
.
then
(
res
=>
{
.
then
(
res
=>
{
const
data
=
res
.
data
;
const
data
=
res
.
data
;
console
.
log
(
data
);
console
.
log
(
data
);
this
.
props
.
updateUserInfo
({
updateUserInfo
(
data
);
...
data
,
Taro
.
redirectTo
({
token
:
data
.
wxToken
,
});
Taro
.
navigateTo
({
url
:
'/pages/Home/Home'
,
url
:
'/pages/Home/Home'
,
});
});
})
})
.
catch
(
console
.
error
);
.
catch
(
err
=>
{
console
.
log
(
err
);
if
(
err
.
code
&&
err
.
code
===
NotRegisterCode
)
{
updateUserInfo
({
customerPhone
:
account
,
});
Taro
.
navigateTo
({
url
:
'/pages/Register/Register'
,
});
}
});
}
}
}
}
...
...
src/pages/Register/Register.tsx
View file @
123868be
...
@@ -18,9 +18,10 @@ import { connect } from '@tarojs/redux';
...
@@ -18,9 +18,10 @@ import { connect } from '@tarojs/redux';
import
{
UserState
,
updateUserInfo
}
from
'../../store/rootReducers/userinfo'
;
import
{
UserState
,
updateUserInfo
}
from
'../../store/rootReducers/userinfo'
;
import
{
wxUserRegister
}
from
'../../api/customer'
;
import
{
wxUserRegister
}
from
'../../api/customer'
;
import
{
replaceIllegalPwd
}
from
'../../utils/pwd'
;
import
{
replaceIllegalPwd
}
from
'../../utils/pwd'
;
import
{
Customer
}
from
'@/types/Customer/Customer'
;
type
PageStateProps
=
{
type
PageStateProps
=
{
userinfo
:
UserState
;
userinfo
:
Customer
;
};
};
type
PageDispatchProps
=
{
type
PageDispatchProps
=
{
updateUserInfo
:
(
e
:
UserState
)
=>
void
;
updateUserInfo
:
(
e
:
UserState
)
=>
void
;
...
@@ -61,9 +62,10 @@ class Register extends Component {
...
@@ -61,9 +62,10 @@ class Register extends Component {
constructor
(
props
:
IProps
)
{
constructor
(
props
:
IProps
)
{
super
(
props
);
super
(
props
);
const
{
customerPhone
}
=
props
.
userinfo
;
this
.
state
=
{
this
.
state
=
{
name
:
''
,
name
:
''
,
cellphone
:
''
,
cellphone
:
customerPhone
,
vcode
:
''
,
vcode
:
''
,
pwd
:
''
,
pwd
:
''
,
checkPwd
:
''
,
checkPwd
:
''
,
...
...
src/pages/index/index.tsx
View file @
123868be
...
@@ -3,11 +3,11 @@ import Taro, { Component, Config } from '@tarojs/taro';
...
@@ -3,11 +3,11 @@ import Taro, { Component, Config } from '@tarojs/taro';
import
{
View
}
from
'@tarojs/components'
;
import
{
View
}
from
'@tarojs/components'
;
import
'./index.scss'
;
import
'./index.scss'
;
import
{
LoginReponse
}
from
'../../api/wx'
;
import
{
connect
}
from
'@tarojs/redux'
;
import
{
connect
}
from
'@tarojs/redux'
;
import
{
updateUserInfo
,
UserState
}
from
'../../store/rootReducers/userinfo'
;
import
{
updateUserInfo
,
UserState
}
from
'../../store/rootReducers/userinfo'
;
import
{
appLogin
}
from
'../../api/customer'
;
import
{
appLogin
}
from
'../../api/customer'
;
import
{
NotRegisterCode
}
from
'@/constants'
;
type
PageDispatchProps
=
{
type
PageDispatchProps
=
{
updateUserInfo
:
(
e
:
UserState
|
{
token
:
string
})
=>
void
;
updateUserInfo
:
(
e
:
UserState
|
{
token
:
string
})
=>
void
;
...
@@ -67,35 +67,25 @@ class Index extends Component {
...
@@ -67,35 +67,25 @@ class Index extends Component {
Taro
.
login
()
Taro
.
login
()
.
then
(
res
=>
{
.
then
(
res
=>
{
console
.
log
(
res
);
console
.
log
(
res
);
const
code
=
res
.
code
;
updateUserInfo
({
code
,
});
appLogin
({
appLogin
({
code
:
res
.
code
,
code
:
res
.
code
,
})
})
.
then
((
res
:
LoginReponse
)
=>
{
.
then
(
res
=>
{
const
{
register
,
wxToken
,
...
userInfo
}
=
res
.
data
;
const
data
=
res
.
data
;
console
.
log
(
wxToken
);
updateUserInfo
(
data
);
Taro
.
redirectTo
({
if
(
register
)
{
url
:
'/pages/Home/Home'
,
updateUserInfo
({
});
...
userInfo
,
token
:
wxToken
,
});
Taro
.
redirectTo
({
url
:
'/pages/Home/Home'
,
});
}
else
{
updateUserInfo
({
token
:
wxToken
,
});
Taro
.
hideLoading
();
Taro
.
redirectTo
({
url
:
'/pages/Login/Login'
,
});
}
})
})
.
catch
(
err
=>
{
.
catch
(
err
=>
{
console
.
log
(
err
);
console
.
log
(
err
);
this
.
setState
({
Taro
.
hideLoading
();
errorText
:
err
.
msg
,
Taro
.
redirectTo
({
url
:
'/pages/Login/Login'
,
});
});
});
});
})
})
...
...
src/store/rootReducers/userinfo.ts
View file @
123868be
import
Action
from
'../../types/Store/Actions'
;
import
Action
from
'../../types/Store/Actions'
;
import
{
Customer
}
from
'../../types/Customer/Customer'
;
import
{
Customer
}
from
'../../types/Customer/Customer'
;
export
type
UserState
=
StoreState
<
Customer
>
;
export
type
UserState
=
StoreState
<
Customer
&
{
code
:
string
}
>
;
export
const
INITIAL_STATE
=
{
export
const
INITIAL_STATE
=
{
login
:
false
,
code
:
''
,
areaId
:
0
,
areaId
:
0
,
areaName
:
''
,
areaName
:
''
,
birthDay
:
''
,
birthDay
:
''
,
...
@@ -36,7 +36,6 @@ export const INITIAL_STATE = {
...
@@ -36,7 +36,6 @@ export const INITIAL_STATE = {
updateAt
:
''
,
updateAt
:
''
,
updateLoginDate
:
''
,
updateLoginDate
:
''
,
version
:
''
,
version
:
''
,
wxToken
:
''
,
};
};
export
const
updateUserInfo
=
(
entity
:
UserState
):
Action
=>
({
export
const
updateUserInfo
=
(
entity
:
UserState
):
Action
=>
({
...
...
src/types/Customer/Customer.ts
View file @
123868be
...
@@ -30,5 +30,4 @@ export type Customer = {
...
@@ -30,5 +30,4 @@ export type Customer = {
updateAt
:
string
;
updateAt
:
string
;
updateLoginDate
:
string
;
updateLoginDate
:
string
;
version
:
string
;
version
:
string
;
wxToken
:
string
;
};
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment