v1.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. namespace zin;
  3. requireWg('thinkModel');
  4. /**
  5. * 思引师$APPEALS模型部件类。
  6. * thinmory $APPEALS model widget class.
  7. */
  8. class thinkAppeals extends thinkModel
  9. {
  10. public static function getPageCSS()
  11. {
  12. return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css');
  13. }
  14. public static function getPageJS()
  15. {
  16. return file_get_contents(__DIR__ . DS . 'js' . DS . 'v1.js');
  17. }
  18. protected function getIndicator()
  19. {
  20. $blocks = $this->prop('blocks');
  21. $indicator = array();
  22. foreach($blocks['steps'] as $key => $step)
  23. {
  24. $indicator[] = array('name' => $step->title, 'color'=> '#64758B', 'axisLabel' => $key == 0 ? array('show' => true) : null);
  25. }
  26. return $indicator;
  27. }
  28. protected function buildEcharts()
  29. {
  30. $blocks = $this->prop('blocks');
  31. $color = array('#29AA93', '#FF9F46');
  32. $legendConfig = array(
  33. 'data' => $blocks['legend'],
  34. 'icon' => 'circle',
  35. 'itemGap' => 90,
  36. 'itemWidth' => 14,
  37. 'itemHeight' => 14,
  38. 'bottom' => 20,
  39. 'textStyle' => array('color' => '#64758B', 'fontSize' => 20, 'padding' => array(0, 0, 0, 16))
  40. );
  41. if(isset($blocks['configureObjects']['enableCompetitor']) && $blocks['configureObjects']['enableCompetitor'] == 0)
  42. {
  43. $color = array('#2294FB', '#22C98D', '#8166EE', '#EC4899', '#FF9F46', '#FBD34D');
  44. $legendConfig = array_merge($legendConfig, array(
  45. 'itemWidth' => 400,
  46. 'itemGap' => 20,
  47. 'textStyle' => array(
  48. 'color' => '#64758B',
  49. 'fontSize' => 20,
  50. 'padding' => array(0, 0, 0, -180),
  51. 'rich' => array('bolder' => array('fontSize' => 20, 'fontWeight' => 'bold'))
  52. ),
  53. 'formatter' => jsRaw('formatLegend')
  54. ));
  55. }
  56. return echarts
  57. (
  58. set::animationDuration(0),
  59. set::width('1600px'),
  60. set::height('1100px'),
  61. set::color($color),
  62. set::legend(array($legendConfig)),
  63. set::radar(array(
  64. 'nameGap' => 32,
  65. 'splitArea' => array('areaStyle' => array('color' => array('#EAF5FF'))),
  66. 'splitLine' => array('lineStyle' => array('color' => '#CFE7FE', 'width' => 3)),
  67. 'axisLine' => array('lineStyle' => array('color' => '#CFE7FE', 'width' => 3)),
  68. 'axisLabel' => array('color' => '#9EA3B0', 'textStyle' => array('fontSize' => 24)),
  69. 'name' => array('textStyle' => array('fontSize' => 24)),
  70. 'indicator' => $this->getIndicator()
  71. )),
  72. set::series
  73. (
  74. array(
  75. array(
  76. 'symbolSize' => 10,
  77. 'type' => 'radar',
  78. 'data' => $blocks['seriesData'],
  79. 'label' => array('normal' => array(
  80. 'show' => true,
  81. 'formatter' => jsRaw('formatSeriesLabel'),
  82. 'textStyle' => array('fontSize' => 24)
  83. ))
  84. )
  85. )
  86. )
  87. );
  88. }
  89. protected function buildBody()
  90. {
  91. global $lang;
  92. list($mode, $wizard) = $this->prop(array('mode', 'wizard'));
  93. $wizard->config = is_string($wizard->config) ? json_decode($wizard->config, true) : (array) $wizard->config;
  94. $configureObjects = json_decode($wizard->config['configureObjects']);
  95. $enableCompetitor = !isset($configureObjects->enableCompetitor) || $configureObjects->enableCompetitor == '1';
  96. $objectName = $configureObjects->type == 'product' ? $lang->thinkwizard->objects->product : $lang->thinkwizard->objects->typeList['RDA'][$configureObjects->type];
  97. if($mode == 'preview')
  98. {
  99. $count = $wizard->config['configureDimension']['count'];
  100. return div
  101. (
  102. setClass('flex justify-center relative'),
  103. img(set::src("data/thinmory/wizardsetting/rda/dimension$count.svg")),
  104. div(setClass('absolute flex object-green text-sm'), $enableCompetitor ? ($lang->thinkwizard->dimension->actuallyObject[0] . $objectName) : $lang->thinkwizard->dimension->defaultObject[0]),
  105. div(setClass('absolute flex object-orange text-sm'), $enableCompetitor ? ($lang->thinkwizard->dimension->actuallyObject[1] . $objectName) : $lang->thinkwizard->dimension->defaultObject[1])
  106. );
  107. }
  108. return div
  109. (
  110. setClass('appleals-chart-content'),
  111. div(setClass('appleals-chart'), $this->buildEcharts()),
  112. on::inited()->call('initedAppealsChart')
  113. );
  114. }
  115. protected function build()
  116. {
  117. return div(setClass('model-appeals my-1 flex col flex-wrap justify-between'), $this->buildBody());
  118. }
  119. }