Commit 7ef24d78 by lirandong

fix

parent 1a95ffa9
...@@ -3,12 +3,17 @@ import { ApiClient } from './client' ...@@ -3,12 +3,17 @@ import { ApiClient } from './client'
class UsersApi extends ApiClient { class UsersApi extends ApiClient {
/** 获取验证码 */ /** 获取验证码 */
getCheckCode(phone: string | number) { 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) { login(userPhone, codeInfo) {
return this.request({ return this.request({
url: '/publics/login/info', url: '/publics/login/info',
config: { headers: { noToken: true } },
data: { userPhone, codeInfo, userTerminal: 'APP' } data: { userPhone, codeInfo, userTerminal: 'APP' }
}) })
} }
......
...@@ -19,6 +19,7 @@ import './app.scss' ...@@ -19,6 +19,7 @@ import './app.scss'
/** 初始化 tokne */ /** 初始化 tokne */
!(async () => { !(async () => {
await token.init() await token.init()
console.log('object')
Taro.render(<App />, document.getElementById('app')) Taro.render(<App />, document.getElementById('app'))
})() })()
...@@ -34,9 +35,10 @@ class App extends Component { ...@@ -34,9 +35,10 @@ class App extends Component {
*/ */
config: Config = { config: Config = {
pages: [ pages: [
'pages/home/tempaltes/index',
'pages/login/index',
'pages/home/device/index', 'pages/home/device/index',
'pages/home/device/device_detail/index', 'pages/home/device/device_detail/index',
'pages/home/tempaltes/index',
'pages/system/wifi_list/index', 'pages/system/wifi_list/index',
'pages/home/device/device_bind/index', 'pages/home/device/device_bind/index',
'pages/home/user/index', 'pages/home/user/index',
...@@ -79,12 +81,11 @@ class App extends Component { ...@@ -79,12 +81,11 @@ class App extends Component {
} }
} }
// componentWillMount() { componentWillMount() {
console.log('token.isLogon()', token.isLogon())
// setTimeout(() => { // setTimeout(() => {
// // Taro.login()
// Taro.navigateTo({ url: '/pages/index/index' })
// }, 2000) // }, 2000)
// } }
// 在 App 类中的 render() 函数没有实际作用 // 在 App 类中的 render() 函数没有实际作用
// 请勿修改此函数 // 请勿修改此函数
......
import { MyStorage } from './utils' import { MyStorage } from './utils'
class Token { class Token {
private initDone = false private initDone = false
private token = '676191a8b17442cfb06d31fdc936db6e-APP' // private token = '676191a8b17442cfb06d31fdc936db6e-APP'
private token = 'f3c5a23c5c5544d08a614f22ac8d4344-APP'
// constructor() { // constructor() {
// this.getStorageToken() // this.getStorageToken()
// } // }
...@@ -18,10 +19,10 @@ class Token { ...@@ -18,10 +19,10 @@ class Token {
return !!this.token return !!this.token
} }
setToken(token: string) { async setToken(token: string) {
if (!token) return if (!token) return
this.token = token this.token = token
return MyStorage.setItem({ key: 'token', data: token }) await MyStorage.setItem({ key: 'token', data: token })
} }
getToken() { getToken() {
...@@ -31,8 +32,8 @@ class Token { ...@@ -31,8 +32,8 @@ class Token {
async getStorageToken() { async getStorageToken() {
try { try {
// const { data } = await MyStorage.getItem({ key: 'token' }) // const { data } = await MyStorage.getItem({ key: 'token' })
const res = await MyStorage.getItem({ key: 'token' }) console.log('11111')
console.log({ res }) return MyStorage.getItem({ key: 'token' })
// if (!!data) this.token = data // if (!!data) this.token = data
} catch (error) { } catch (error) {
console.warn('获取本地 token 失败~', error) console.warn('获取本地 token 失败~', error)
......
...@@ -6,6 +6,7 @@ import TempItem from './conpoments/temp_item' ...@@ -6,6 +6,7 @@ import TempItem from './conpoments/temp_item'
import { View, Input, ScrollView } from '@tarojs/components' import { View, Input, ScrollView } from '@tarojs/components'
import './scss/index.scss' import './scss/index.scss'
import token from '@/common/token'
type PageStateProps = { type PageStateProps = {
list: any[] list: any[]
...@@ -52,6 +53,9 @@ class Tempaltes extends Component { ...@@ -52,6 +53,9 @@ class Tempaltes extends Component {
} }
} }
componentDidMount() {
// !token.isLogon() && Taro.navigateTo({ url: '/pages/login/index' })
}
async componentWillMount() { async componentWillMount() {
this.getData() this.getData()
} }
......
...@@ -3,38 +3,52 @@ ...@@ -3,38 +3,52 @@
.login { .login {
width: 100%; width: 100%;
height: 100%; height: 100%;
padding-top: 90; padding-top: 90px;
flex-direction: column; flex-direction: column;
background-color: white; background-color: white;
&-logo { &-logo {
font-size: 20; font-size: 60px;
color: #5ea1fb; color: #5ea1fb;
text-align: center; text-align: center;
@include eject(display, block);
} }
&-wrapper { &-content {
width: 100%; width: 100%;
padding: 60px 38px 0; padding: 60px 38px 0;
@include eject(box-sizing, border-box);
} }
&-user-phone { &-user-phone {
@include border-bottom; // @include border-bottom;
margin-bottom: 20px;
&-input { &-input {
flex: 1; flex: 1;
color: $input-color; color: $input-color;
padding: 16px 20px;
border-radius: 6px;
border: 1px solid $border-color;
} }
} }
&-check-code { &-check-code {
display: flex;
align-items: center; align-items: center;
flex-direction: row; flex-direction: row;
margin-bottom: 20px;
@include border-bottom; // @include border-bottom;
&-input { &-input {
flex: 1; flex: 1;
padding: 16px 20px;
border-radius: 6px;
color: $input-color;
border: 1px solid $border-color;
} }
&-btn { &-btn {
...@@ -48,14 +62,18 @@ ...@@ -48,14 +62,18 @@
&-app-clause { &-app-clause {
width: 100%; width: 100%;
margin-top: 10; margin-top: 10px;
margin-bottom: 30; margin-bottom: 30px;
align-items: center; align-items: center;
flex-direction: row; flex-direction: row;
&-text { &-text {
flex: 1; flex: 1;
font-size: 12; font-size: 24px;
} }
} }
&-bottom-btn {
margin-top: 120px;
}
} }
...@@ -8,7 +8,7 @@ import { checkPhone, showMyToast } from '../../common/utils' ...@@ -8,7 +8,7 @@ import { checkPhone, showMyToast } from '../../common/utils'
import Taro, { Component, Config } from '@tarojs/taro' import Taro, { Component, Config } from '@tarojs/taro'
import { View, Text, Input, Button, Checkbox, Label } from '@tarojs/components' import { View, Text, Input, Button, Checkbox, Label } from '@tarojs/components'
import './login.scss' import './index.scss'
type PageStateProps = { type PageStateProps = {
counter: { counter: {
...@@ -39,7 +39,8 @@ interface Login { ...@@ -39,7 +39,8 @@ interface Login {
})) }))
class Login extends Component { class Login extends Component {
config: Config = { config: Config = {
navigationStyle: 'custom' navigationBarTitleText: '登录',
navigationStyle: process.env.TARO_ENV === 'rn' ? 'custom' : 'default'
} }
constructor(props) { constructor(props) {
...@@ -98,7 +99,7 @@ class Login extends Component { ...@@ -98,7 +99,7 @@ class Login extends Component {
Taro.hideLoading() Taro.hideLoading()
if (data) { if (data) {
await token.setToken(data) await token.setToken(data)
Taro.redirectTo({ url: HONE }) Taro.redirectTo({ url: '/pages/home/tempaltes/index' })
} }
} catch (error) { } catch (error) {
// console.warn('用户登录出错~', error) // console.warn('用户登录出错~', error)
...@@ -161,7 +162,12 @@ class Login extends Component { ...@@ -161,7 +162,12 @@ class Login extends Component {
我已阅读并同意《可视化平台用户协议》中相关条款 我已阅读并同意《可视化平台用户协议》中相关条款
</Text> </Text>
</Label> </Label>
<Button disabled={!loginBtnState} type="primary" onClick={this.login}> <Button
className="login-bottom-btn"
disabled={!loginBtnState}
type="primary"
onClick={this.login}
>
登录 登录
</Button> </Button>
</View> </View>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment