import {
  request
} from '../_utils/request';
import {
  getStorage
} from '~/utils/storage'

/** 获取个人中心信息 */
export function fetchUserCenter() {
  const userData = getStorage('userInfo');
  return new Promise((resolve, reject) => {
    request({
      url: `CustomerApi/getCustomerDetails?CustomerGuid=` + userData?.customerGuid,
      method: 'GET',
      success: function (res) {
        let userInfo = res.data;
        let data = {
          userInfo: {
            avatarUrl: userInfo.customerAvatar,
            nickName: userInfo.customerNickname,
            phoneNumber: userInfo.customerMobilePhoneNumber,
          }
        };
        resolve(data);
      },
      fail: function (error) {
        reject(error);
      }
    });
  });
}