41 lines
945 B
TypeScript
41 lines
945 B
TypeScript
import InformPage from '@/pages/user/inform/inform';
|
|
import Taro from '@tarojs/taro';
|
|
import pt from '@/plain-text';
|
|
import wechatUser from '@/wechat';
|
|
import { getUrl } from '.';
|
|
|
|
export function updateUserInfo(that: InformPage) {
|
|
that.setState({
|
|
isLoading: true,
|
|
});
|
|
Taro.request({
|
|
url: getUrl('/user/update'),
|
|
method: 'POST',
|
|
data: {
|
|
token: wechatUser.getToken(),
|
|
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.errMsg);
|
|
that.setState({
|
|
isLoading: false,
|
|
});
|
|
Taro.atMessage({
|
|
message: pt.get().button.submitText.error + err.errMsg.toString(),
|
|
type: 'error',
|
|
});
|
|
});
|
|
}
|