v1.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace zin;
  3. class thinkResult extends wg
  4. {
  5. /**
  6. * @var mixed[]
  7. */
  8. protected static $defineProps = array(
  9. 'wizard: object', // 模型数据
  10. 'mode?: string="view"', // 模型展示模式。 preview 后台设计预览 | view 前台结果展示
  11. 'blocks: array', // 模型节点
  12. 'conclusion: string', // 分析结论
  13. 'previewKey?: int', // 区域组预览的键值
  14. );
  15. public static function getPageCSS()
  16. {
  17. return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css');
  18. }
  19. public static function getPageJS()
  20. {
  21. return file_get_contents(__DIR__ . DS . 'js' . DS . 'v1.js');
  22. }
  23. /**
  24. * @return \zin\wg|mixed[]
  25. */
  26. protected function buildModel()
  27. {
  28. list($wizard, $mode, $blocks, $previewKey) = $this->prop(array('wizard', 'mode', 'blocks', 'previewKey'));
  29. $model = $wizard->model;
  30. $wgMap = array('swot' => 'thinkSwot', 'pffa' => 'thinkPffa', 'pest' => 'thinkPestel', 'pestel' => 'thinkPestel', '4p' => 'think4p', '4p2' => 'think4p', '3c' => 'think3c', 'ansoff' => 'thinkAnsoff', 'appeals' => 'thinkAppeals', 'bcg' => 'thinkBcg', 'scp' => 'thinkAppeals');
  31. if(!isset($wgMap[$model])) return array();
  32. return createWg($wgMap[$model], array(set::mode($mode), set::blocks($blocks), set::wizard($wizard), set::previewKey($previewKey)));
  33. }
  34. protected function build()
  35. {
  36. global $app, $lang;
  37. $app->loadLang('thinkwizard');
  38. list($wizard, $mode, $conclusion) = $this->prop(array('wizard', 'mode', 'conclusion'));
  39. $introduction = $mode == 'preview' ? $lang->thinkwizard->introduction : '';
  40. $introduction = $wizard->introduction ? $wizard->introduction : $introduction;
  41. $suggestion = $mode == 'preview' ? $lang->thinkwizard->suggestion : '';
  42. $suggestion = $wizard->suggestion ? htmlspecialchars_decode($wizard->suggestion) : $suggestion;
  43. $modelClass = $mode == 'preview' ? 'w-full' : '';
  44. return div
  45. (
  46. $mode == 'view' ? on::init()->call('initThinkResult') : null,
  47. setClass('think-result-content col items-center px-8 py-6 gap-4 mx-auto'),
  48. div
  49. (
  50. setClass('w-full flex items-center justify-center text-left'),
  51. setStyle(array('font-size' => '20px')),
  52. set::title($wizard->introduction),
  53. $introduction
  54. ),
  55. div
  56. (
  57. setClass('think-model-content', $modelClass, 'is-' . $mode),
  58. setStyle('min-height', '200px'),
  59. $this->buildModel(),
  60. div(setClass('mt-4 text-center font-bold text-gray-950 text-3xl'), $wizard->name)
  61. ),
  62. div
  63. (
  64. setClass('w-full text-left text-base py-2.5 leading-5'),
  65. html($suggestion)
  66. ),
  67. div
  68. (
  69. setClass('w-full text-left text-base leading-5'),
  70. $conclusion
  71. )
  72. );
  73. }
  74. }