const getServiceList = (item) => {
  const { serviceList = [] } = item;
  return serviceList;
};

const getExtInfo = (item) => {
  const { componentExtInfo } = item;
  return componentExtInfo || {};
};

const getMode = (item) => {
  const { styleMode } = getExtInfo(item);
  return styleMode || 'a';
};

/*
* 获取列表数据限制2行
* */
const getRows = (item) => {
  const {
    mode = 'a',
    showMore = 'Y',
  } = getExtInfo(item);
  const modeMap = {
    a: showMore === 'Y' ? 7 : 8,
    b: showMore === 'Y' ? 9 : 10,
  };
  return modeMap[mode];
};

const getList = (item) => {
  const {
    allPage = false,
  } = getExtInfo(item);
  const end = getRows(item);
  const list = getServiceList(item);
  return allPage ? list : list.slice(0, end);
};

/*
* 是否显示更多按钮
* */
const geShowAll = (item) => {
  const {
    showMore = 'Y',
    allPage = false,
  } = getExtInfo(item);
  return allPage ? false : showMore === 'Y';
};

const getAllPageClass = (item) => {
  const {
    allPage = false,
  } = getExtInfo(item);
  return allPage ? ' general-services-all' : '';
};

const getUrl = (url, imgSrcPrefix) => {
  url = url || '';
  return url.length === 32 ? imgSrcPrefix + url : url;
};

export default {
  getUrl,
  getMode,
  getList,
  geShowAll,
  getAllPageClass,
};

