refactor mainpage service
parent
dd56725575
commit
6583b51750
|
|
@ -1,9 +1,9 @@
|
|||
import { Component, ReactNode } from 'react';
|
||||
import { AtForm, AtInput, AtButton, AtMessage } from 'taro-ui';
|
||||
import { View } from '@tarojs/components';
|
||||
import { getUrl } from '@/service';
|
||||
import Taro from '@tarojs/taro';
|
||||
import pt from '@/plain-text';
|
||||
import { updateUserInfo } from '@/service/UserInfo';
|
||||
import './inform.scss';
|
||||
|
||||
const submitInterval = 5000;
|
||||
|
|
@ -40,32 +40,7 @@ export default class InformPage extends Component {
|
|||
isDisable: true,
|
||||
});
|
||||
console.log(this.state.name, this.state.phone);
|
||||
Taro.request({
|
||||
url: getUrl('/user/update'),
|
||||
method: 'POST',
|
||||
data: {
|
||||
token: 'token_test',
|
||||
name: this.state.name,
|
||||
phone: this.state.phone,
|
||||
},
|
||||
})
|
||||
.then(res => {
|
||||
console.log(res.data);
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.submitText.success,
|
||||
type: 'success',
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.submitText.error + err.toString(),
|
||||
type: 'error',
|
||||
});
|
||||
});
|
||||
this.setState({
|
||||
isLoading: false,
|
||||
});
|
||||
updateUserInfo(this);
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
isDisable: false,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
import InformPage from '@/pages/user/inform/inform';
|
||||
import Taro from '@tarojs/taro';
|
||||
import pt from '@/plain-text';
|
||||
import { getUrl } from '.';
|
||||
|
||||
export function updateUserInfo(that: InformPage) {
|
||||
Taro.request({
|
||||
url: getUrl('/user/update'),
|
||||
method: 'POST',
|
||||
data: {
|
||||
token: 'token_test',
|
||||
name: that.state.name,
|
||||
phone: that.state.phone,
|
||||
},
|
||||
})
|
||||
.then(res => {
|
||||
console.log(res.data);
|
||||
that.setState({
|
||||
isLoading: false,
|
||||
});
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.submitText.success,
|
||||
type: 'success',
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
that.setState({
|
||||
isLoading: false,
|
||||
});
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.submitText.error + err.toString(),
|
||||
type: 'error',
|
||||
});
|
||||
});
|
||||
}
|
||||
Loading…
Reference in New Issue