Commit 7ef24d78 by lirandong

fix

parent 1a95ffa9
......@@ -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' }
})
}
......
......@@ -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() 函数没有实际作用
// 请勿修改此函数
......
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' })
const res = await MyStorage.getItem({ key: 'token' })
console.log({ res })
console.log('11111')
return MyStorage.getItem({ key: 'token' })
// if (!!data) this.token = data
} catch (error) {
console.warn('获取本地 token 失败~', error)
......
......@@ -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()
}
......
......@@ -3,38 +3,52 @@
.login {
width: 100%;
height: 100%;
padding-top: 90;
padding-top: 90px;
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: 10px;
margin-bottom: 30px;
align-items: center;
flex-direction: row;
&-text {
flex: 1;
font-size: 12;
font-size: 24px;
}
}
&-bottom-btn {
margin-top: 120px;
}
}
......@@ -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>
......
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