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 data = {
          userInfo: {
            avatarUrl: res.data.customerAvatar,
            nickName: res.data.customerNickname,
            phoneNumber: res.data.customerMobilePhoneNumber,
          },
          collectData: {
            collectCount: res.data.collectCount,
            historyCount: res.data.historyCount,
          }
        };
        resolve(data);
      },
      fail: function (error) {
        reject(error);
      }
    });
  });
}