index.sjs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. const getServiceList = (item) => {
  2. const { serviceList = [] } = item;
  3. return serviceList;
  4. };
  5. const getExtInfo = (item) => {
  6. const { componentExtInfo } = item;
  7. return componentExtInfo || {};
  8. };
  9. const getMode = (item) => {
  10. const { styleMode } = getExtInfo(item);
  11. return styleMode || 'a';
  12. };
  13. /*
  14. * 获取列表数据限制2行
  15. * */
  16. const getRows = (item) => {
  17. const {
  18. mode = 'a',
  19. showMore = 'Y',
  20. } = getExtInfo(item);
  21. const modeMap = {
  22. a: showMore === 'Y' ? 7 : 8,
  23. b: showMore === 'Y' ? 9 : 10,
  24. };
  25. return modeMap[mode];
  26. };
  27. const getList = (item) => {
  28. const {
  29. allPage = false,
  30. } = getExtInfo(item);
  31. const end = getRows(item);
  32. const list = getServiceList(item);
  33. return allPage ? list : list.slice(0, end);
  34. };
  35. /*
  36. * 是否显示更多按钮
  37. * */
  38. const geShowAll = (item) => {
  39. const {
  40. showMore = 'Y',
  41. allPage = false,
  42. } = getExtInfo(item);
  43. return allPage ? false : showMore === 'Y';
  44. };
  45. const getAllPageClass = (item) => {
  46. const {
  47. allPage = false,
  48. } = getExtInfo(item);
  49. return allPage ? ' general-services-all' : '';
  50. };
  51. const getUrl = (url, imgSrcPrefix) => {
  52. url = url || '';
  53. return url.length === 32 ? imgSrcPrefix + url : url;
  54. };
  55. export default {
  56. getUrl,
  57. getMode,
  58. getList,
  59. geShowAll,
  60. getAllPageClass,
  61. };