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',
      });
    });
}
