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
1e20be2d
Commit
1e20be2d
authored
Mar 11, 2019
by
姜雷
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into test
parents
051ba2c8
123868be
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
93 additions
and
289 deletions
+93
-289
index.js
config/index.js
+40
-45
global.d.ts
global.d.ts
+0
-4
index.ts
src/api/index.ts
+9
-1
index.js
src/constants/index.js
+3
-0
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
+11
-21
index.ts
src/store/index.ts
+3
-2
userinfo.ts
src/store/rootReducers/userinfo.ts
+2
-3
Customer.ts
src/types/Customer/Customer.ts
+0
-1
No files found.
config/index.js
View file @
1e20be2d
const
path
=
require
(
'path'
);
const
config
=
{
projectName
:
'wx-school-app'
,
date
:
'2019-2-20'
,
...
...
@@ -5,32 +7,35 @@ const config = {
deviceRatio
:
{
'640'
:
2.34
/
2
,
'750'
:
1
,
'828'
:
1.81
/
2
'828'
:
1.81
/
2
,
},
sourceRoot
:
'src'
,
outputRoot
:
'dist'
,
alias
:
{
'@'
:
path
.
resolve
(
__dirname
,
'..'
,
'src'
),
},
plugins
:
{
babel
:
{
sourceMap
:
true
,
presets
:
[
[
'env'
,
{
modules
:
false
}]
[
'env'
,
{
modules
:
false
,
},
],
],
plugins
:
[
'transform-decorators-legacy'
,
'transform-class-properties'
,
'transform-object-rest-spread'
]
}
'transform-object-rest-spread'
,
],
},
defineConstants
:
{
},
defineConstants
:
{},
copy
:
{
patterns
:
[
],
options
:
{
}
patterns
:
[],
options
:
{},
},
weapp
:
{
module
:
{
...
...
@@ -38,34 +43,28 @@ const config = {
autoprefixer
:
{
enable
:
true
,
config
:
{
browsers
:
[
'last 3 versions'
,
'Android >= 4.1'
,
'ios >= 8'
]
}
browsers
:
[
'last 3 versions'
,
'Android >= 4.1'
,
'ios >= 8'
],
},
},
pxtransform
:
{
enable
:
true
,
config
:
{
}
config
:
{},
},
url
:
{
enable
:
true
,
config
:
{
limit
:
10240
// 设定转换尺寸上限
}
limit
:
10240
,
// 设定转换尺寸上限
}
,
},
cssModules
:
{
enable
:
false
,
// 默认为 false,如需使用 css modules 功能,则设为 true
config
:
{
namingPattern
:
'module'
,
// 转换模式,取值为 global/module
generateScopedName
:
'[name]__[local]___[hash:base64:5]'
}
}
}
}
generateScopedName
:
'[name]__[local]___[hash:base64:5]'
,
}
,
}
,
}
,
}
,
},
h5
:
{
publicPath
:
'/'
,
...
...
@@ -75,28 +74,24 @@ const config = {
autoprefixer
:
{
enable
:
true
,
config
:
{
browsers
:
[
'last 3 versions'
,
'Android >= 4.1'
,
'ios >= 8'
]
}
browsers
:
[
'last 3 versions'
,
'Android >= 4.1'
,
'ios >= 8'
],
},
},
cssModules
:
{
enable
:
false
,
// 默认为 false,如需使用 css modules 功能,则设为 true
config
:
{
namingPattern
:
'module'
,
// 转换模式,取值为 global/module
generateScopedName
:
'[name]__[local]___[hash:base64:5]'
}
}
}
}
}
}
generateScopedName
:
'[name]__[local]___[hash:base64:5]'
,
}
,
}
,
}
,
}
,
}
,
}
;
module
.
exports
=
function
(
merge
)
{
module
.
exports
=
function
(
merge
)
{
if
(
process
.
env
.
NODE_ENV
===
'development'
)
{
return
merge
({},
config
,
require
(
'./dev'
))
return
merge
({},
config
,
require
(
'./dev'
))
;
}
return
merge
({},
config
,
require
(
'./prod'
))
}
return
merge
({},
config
,
require
(
'./prod'
))
;
}
;
global.d.ts
View file @
1e20be2d
...
...
@@ -8,7 +8,3 @@ declare module '*.less';
declare
module
'*.scss'
;
declare
module
'*.sass'
;
declare
module
'*.styl'
;
interface
Window
{
__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
:
(
option
)
=>
any
;
}
src/api/index.ts
View file @
1e20be2d
...
...
@@ -4,6 +4,8 @@ import {
BASE_SERVER_URL
,
CUSTOMER_SERVER_URL
,
SCHOOL_MAIN_URL
,
LogoutCode
,
SuccessCode
,
}
from
'../constants/index'
;
export
type
ResponseDataEntity
<
T
>
=
{
...
...
@@ -33,9 +35,15 @@ const createFetch = (basePath: string) => {
},
url
:
basePath
+
entity
.
url
,
}).
then
(({
data
}:
ResponseEntity
)
=>
{
if
(
data
.
code
===
1000
)
{
if
(
data
.
code
===
SuccessCode
)
{
return
data
;
}
if
(
data
.
code
===
LogoutCode
)
{
Taro
.
redirectTo
({
url
:
'/pages/Login/Login'
,
});
throw
data
;
}
Taro
.
showToast
({
title
:
data
.
msg
,
icon
:
'none'
,
...
...
src/constants/index.js
View file @
1e20be2d
export
const
APP_ID
=
'wxf5912b79bba23663'
;
export
const
SuccessCode
=
1000
;
export
const
LogoutCode
=
-
2
;
export
const
NotRegisterCode
=
1005
;
export
const
BASE_SERVER_URL
=
'https://ex-test-dcxy-base-app.168cad.top'
;
export
const
CUSTOMER_SERVER_URL
=
...
...
src/pages/CheckTelephone/CheckTelephone.scss
deleted
100644 → 0
View file @
051ba2c8
.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 @
051ba2c8
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 @
1e20be2d
...
...
@@ -5,11 +5,12 @@ import { View, Button, Input, Navigator } from '@tarojs/components';
import
'./Login.scss'
;
import
{
appLogin
}
from
'../../api/customer'
;
import
{
connect
}
from
'@tarojs/redux'
;
import
{
updateUserInfo
}
from
'../../store/rootReducers/userinfo'
;
import
{
LoginInfoVo
}
from
'../../api/baseClass
'
;
import
{
updateUserInfo
,
UserState
}
from
'../../store/rootReducers/userinfo'
;
import
{
NotRegisterCode
}
from
'../../constants/index
'
;
type
PageDispatchProps
=
{
updateUserInfo
:
(
e
:
LoginInfoVo
)
=>
void
;
userinfo
:
UserState
;
updateUserInfo
:
(
e
:
UserState
)
=>
void
;
};
type
PageState
=
{
...
...
@@ -23,9 +24,9 @@ interface Login {
}
@
connect
(
(
)
=>
({
}),
(
{
userinfo
})
=>
({
userinfo
}),
dispatch
=>
({
updateUserInfo
(
data
:
LoginInfoVo
)
{
updateUserInfo
(
data
:
UserState
)
{
dispatch
(
updateUserInfo
(
data
));
},
}),
...
...
@@ -64,24 +65,33 @@ class Login extends Component {
loginHandle
():
void
{
if
(
this
.
validataLoginData
())
{
const
{
updateUserInfo
,
userinfo
}
=
this
.
props
;
const
{
account
,
pwd
}
=
this
.
state
;
console
.
log
(
'in loginHandle'
);
appLogin
({
loginAccount
:
account
,
password
:
pwd
,
code
:
userinfo
.
code
,
})
.
then
(
res
=>
{
const
data
=
res
.
data
;
console
.
log
(
data
);
this
.
props
.
updateUserInfo
({
...
data
,
token
:
data
.
wxToken
,
});
Taro
.
navigateTo
({
updateUserInfo
(
data
);
Taro
.
redirectTo
({
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 @
1e20be2d
...
...
@@ -18,9 +18,10 @@ import { connect } from '@tarojs/redux';
import
{
UserState
,
updateUserInfo
}
from
'../../store/rootReducers/userinfo'
;
import
{
wxUserRegister
}
from
'../../api/customer'
;
import
{
replaceIllegalPwd
}
from
'../../utils/pwd'
;
import
{
Customer
}
from
'@/types/Customer/Customer'
;
type
PageStateProps
=
{
userinfo
:
UserState
;
userinfo
:
Customer
;
};
type
PageDispatchProps
=
{
updateUserInfo
:
(
e
:
UserState
)
=>
void
;
...
...
@@ -61,9 +62,10 @@ class Register extends Component {
constructor
(
props
:
IProps
)
{
super
(
props
);
const
{
customerPhone
}
=
props
.
userinfo
;
this
.
state
=
{
name
:
''
,
cellphone
:
''
,
cellphone
:
customerPhone
,
vcode
:
''
,
pwd
:
''
,
checkPwd
:
''
,
...
...
src/pages/index/index.tsx
View file @
1e20be2d
...
...
@@ -3,11 +3,11 @@ import Taro, { Component, Config } from '@tarojs/taro';
import
{
View
}
from
'@tarojs/components'
;
import
'./index.scss'
;
import
{
LoginReponse
}
from
'../../api/wx'
;
import
{
connect
}
from
'@tarojs/redux'
;
import
{
updateUserInfo
,
UserState
}
from
'../../store/rootReducers/userinfo'
;
import
{
appLogin
}
from
'../../api/customer'
;
import
{
NotRegisterCode
}
from
'@/constants'
;
type
PageDispatchProps
=
{
updateUserInfo
:
(
e
:
UserState
|
{
token
:
string
})
=>
void
;
...
...
@@ -67,35 +67,25 @@ class Index extends Component {
Taro
.
login
()
.
then
(
res
=>
{
console
.
log
(
res
);
const
code
=
res
.
code
;
updateUserInfo
({
code
,
});
appLogin
({
code
:
res
.
code
,
})
.
then
((
res
:
LoginReponse
)
=>
{
const
{
register
,
wxToken
,
...
userInfo
}
=
res
.
data
;
console
.
log
(
wxToken
);
if
(
register
)
{
updateUserInfo
({
...
userInfo
,
token
:
wxToken
,
});
.
then
(
res
=>
{
const
data
=
res
.
data
;
updateUserInfo
(
data
);
Taro
.
redirectTo
({
url
:
'/pages/Home/Home'
,
});
}
else
{
updateUserInfo
({
token
:
wxToken
,
});
Taro
.
hideLoading
();
Taro
.
redirectTo
({
url
:
'/pages/Login/Login'
,
});
}
})
.
catch
(
err
=>
{
console
.
log
(
err
);
this
.
setState
({
errorText
:
err
.
msg
,
Taro
.
hideLoading
();
Taro
.
redirectTo
({
url
:
'/pages/Login/Login'
,
});
});
})
...
...
src/store/index.ts
View file @
1e20be2d
...
...
@@ -3,8 +3,9 @@ import thunkMiddleware from 'redux-thunk';
import
rootReducer
from
'./reducers'
;
const
composeEnhancers
=
typeof
window
===
'object'
&&
window
.
__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
?
window
.
__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
({
typeof
window
===
'object'
&&
(
window
as
any
).
__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
?
(
window
as
any
).
__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
({
// Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize...
})
:
compose
;
...
...
src/store/rootReducers/userinfo.ts
View file @
1e20be2d
import
Action
from
'../../types/Store/Actions'
;
import
{
Customer
}
from
'../../types/Customer/Customer'
;
export
type
UserState
=
StoreState
<
Customer
>
;
export
type
UserState
=
StoreState
<
Customer
&
{
code
:
string
}
>
;
export
const
INITIAL_STATE
=
{
login
:
false
,
code
:
''
,
areaId
:
0
,
areaName
:
''
,
birthDay
:
''
,
...
...
@@ -36,7 +36,6 @@ export const INITIAL_STATE = {
updateAt
:
''
,
updateLoginDate
:
''
,
version
:
''
,
wxToken
:
''
,
};
export
const
updateUserInfo
=
(
entity
:
UserState
):
Action
=>
({
...
...
src/types/Customer/Customer.ts
View file @
1e20be2d
...
...
@@ -30,5 +30,4 @@ export type Customer = {
updateAt
:
string
;
updateLoginDate
:
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