Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
visualcloud
/
Vmatrix-client-taro
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7ef24d78
authored
Aug 23, 2019
by
lirandong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
1a95ffa9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
25 deletions
+60
-25
src/api/users.ts
+6
-1
src/app.tsx
+8
-7
src/common/token.ts
+6
-5
src/pages/home/tempaltes/index.tsx
+4
-0
src/pages/login/index.scss
+26
-8
src/pages/login/index.tsx
+10
-4
No files found.
src/api/users.ts
View file @
7ef24d78
...
...
@@ -3,12 +3,17 @@ import { ApiClient } from './client'
class
UsersApi
extends
ApiClient
{
/** 获取验证码 */
getCheckCode
(
phone
:
string
|
number
)
{
return
this
.
request
({
method
:
'GET'
,
url
:
`/publics/login/send/code/
${
phone
}
`
})
return
this
.
request
({
method
:
'GET'
,
config
:
{
headers
:
{
noToken
:
true
}
},
url
:
`/publics/login/send/code/
${
phone
}
`
})
}
login
(
userPhone
,
codeInfo
)
{
return
this
.
request
({
url
:
'/publics/login/info'
,
config
:
{
headers
:
{
noToken
:
true
}
},
data
:
{
userPhone
,
codeInfo
,
userTerminal
:
'APP'
}
})
}
...
...
src/app.tsx
View file @
7ef24d78
...
...
@@ -19,6 +19,7 @@ import './app.scss'
/** 初始化 tokne */
!
(
async
()
=>
{
await
token
.
init
()
console
.
log
(
'object'
)
Taro
.
render
(<
App
/>,
document
.
getElementById
(
'app'
))
})()
...
...
@@ -34,9 +35,10 @@ class App extends Component {
*/
config
:
Config
=
{
pages
:
[
'pages/home/tempaltes/index'
,
'pages/login/index'
,
'pages/home/device/index'
,
'pages/home/device/device_detail/index'
,
'pages/home/tempaltes/index'
,
'pages/system/wifi_list/index'
,
'pages/home/device/device_bind/index'
,
'pages/home/user/index'
,
...
...
@@ -79,12 +81,11 @@ class App extends Component {
}
}
// componentWillMount() {
// setTimeout(() => {
// // Taro.login()
// Taro.navigateTo({ url: '/pages/index/index' })
// }, 2000)
// }
componentWillMount
()
{
console
.
log
(
'token.isLogon()'
,
token
.
isLogon
())
// setTimeout(() => {
// }, 2000)
}
// 在 App 类中的 render() 函数没有实际作用
// 请勿修改此函数
...
...
src/common/token.ts
View file @
7ef24d78
import
{
MyStorage
}
from
'./utils'
class
Token
{
private
initDone
=
false
private
token
=
'676191a8b17442cfb06d31fdc936db6e-APP'
// private token = '676191a8b17442cfb06d31fdc936db6e-APP'
private
token
=
'f3c5a23c5c5544d08a614f22ac8d4344-APP'
// constructor() {
// this.getStorageToken()
// }
...
...
@@ -18,10 +19,10 @@ class Token {
return
!!
this
.
token
}
setToken
(
token
:
string
)
{
async
setToken
(
token
:
string
)
{
if
(
!
token
)
return
this
.
token
=
token
return
MyStorage
.
setItem
({
key
:
'token'
,
data
:
token
})
await
MyStorage
.
setItem
({
key
:
'token'
,
data
:
token
})
}
getToken
()
{
...
...
@@ -31,8 +32,8 @@ class Token {
async
getStorageToken
()
{
try
{
// const { data } = await MyStorage.getItem({ key: 'token' })
cons
t
res
=
await
MyStorage
.
getItem
({
key
:
'token'
}
)
console
.
log
({
res
})
cons
ole
.
log
(
'11111'
)
return
MyStorage
.
getItem
({
key
:
'token'
})
// if (!!data) this.token = data
}
catch
(
error
)
{
console
.
warn
(
'获取本地 token 失败~'
,
error
)
...
...
src/pages/home/tempaltes/index.tsx
View file @
7ef24d78
...
...
@@ -6,6 +6,7 @@ import TempItem from './conpoments/temp_item'
import
{
View
,
Input
,
ScrollView
}
from
'@tarojs/components'
import
'./scss/index.scss'
import
token
from
'@/common/token'
type
PageStateProps
=
{
list
:
any
[]
...
...
@@ -52,6 +53,9 @@ class Tempaltes extends Component {
}
}
componentDidMount
()
{
// !token.isLogon() && Taro.navigateTo({ url: '/pages/login/index' })
}
async
componentWillMount
()
{
this
.
getData
()
}
...
...
src/pages/login/
login
.scss
→
src/pages/login/
index
.scss
View file @
7ef24d78
...
...
@@ -3,38 +3,52 @@
.login
{
width
:
100%
;
height
:
100%
;
padding-top
:
90
;
padding-top
:
90
px
;
flex-direction
:
column
;
background-color
:
white
;
&
-logo
{
font-size
:
20
;
font-size
:
60px
;
color
:
#5ea1fb
;
text-align
:
center
;
@include
eject
(
display
,
block
);
}
&
-
wrapper
{
&
-
content
{
width
:
100%
;
padding
:
60px
38px
0
;
@include
eject
(
box-sizing
,
border-box
);
}
&
-user-phone
{
@include
border-bottom
;
// @include border-bottom;
margin-bottom
:
20px
;
&
-input
{
flex
:
1
;
color
:
$input-color
;
padding
:
16px
20px
;
border-radius
:
6px
;
border
:
1px
solid
$border-color
;
}
}
&
-check-code
{
display
:
flex
;
align-items
:
center
;
flex-direction
:
row
;
margin-bottom
:
20px
;
@include
border-bottom
;
//
@include border-bottom;
&
-input
{
flex
:
1
;
padding
:
16px
20px
;
border-radius
:
6px
;
color
:
$input-color
;
border
:
1px
solid
$border-color
;
}
&
-btn
{
...
...
@@ -48,14 +62,18 @@
&
-app-clause
{
width
:
100%
;
margin-top
:
10
;
margin-bottom
:
30
;
margin-top
:
10
px
;
margin-bottom
:
30
px
;
align-items
:
center
;
flex-direction
:
row
;
&
-text
{
flex
:
1
;
font-size
:
12
;
font-size
:
24px
;
}
}
&
-bottom-btn
{
margin-top
:
120px
;
}
}
src/pages/login/index.tsx
View file @
7ef24d78
...
...
@@ -8,7 +8,7 @@ import { checkPhone, showMyToast } from '../../common/utils'
import
Taro
,
{
Component
,
Config
}
from
'@tarojs/taro'
import
{
View
,
Text
,
Input
,
Button
,
Checkbox
,
Label
}
from
'@tarojs/components'
import
'./
login
.scss'
import
'./
index
.scss'
type
PageStateProps
=
{
counter
:
{
...
...
@@ -39,7 +39,8 @@ interface Login {
}))
class
Login
extends
Component
{
config
:
Config
=
{
navigationStyle
:
'custom'
navigationBarTitleText
:
'登录'
,
navigationStyle
:
process
.
env
.
TARO_ENV
===
'rn'
?
'custom'
:
'default'
}
constructor
(
props
)
{
...
...
@@ -98,7 +99,7 @@ class Login extends Component {
Taro
.
hideLoading
()
if
(
data
)
{
await
token
.
setToken
(
data
)
Taro
.
redirectTo
({
url
:
HONE
})
Taro
.
redirectTo
({
url
:
'/pages/home/tempaltes/index'
})
}
}
catch
(
error
)
{
// console.warn('用户登录出错~', error)
...
...
@@ -161,7 +162,12 @@ class Login extends Component {
我已阅读并同意《可视化平台用户协议》中相关条款
</
Text
>
</
Label
>
<
Button
disabled=
{
!
loginBtnState
}
type=
"primary"
onClick=
{
this
.
login
}
>
<
Button
className=
"login-bottom-btn"
disabled=
{
!
loginBtnState
}
type=
"primary"
onClick=
{
this
.
login
}
>
登录
</
Button
>
</
View
>
...
...
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