voc-validation-ch3-pricing.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // ==============================================================================
  2. // VOC 验证报告 · Ch3 定价调研 · 4 子章(快照模式)
  3. // 详见 ch2-package.js 头部说明。
  4. // ==============================================================================
  5. const fs = require('fs');
  6. const path = require('path');
  7. let _snapshot = null;
  8. function getSnapshot() {
  9. if (!_snapshot) {
  10. _snapshot = JSON.parse(fs.readFileSync(
  11. path.join(__dirname, '..', '_slides-snapshot.json'), 'utf8',
  12. ));
  13. }
  14. return _snapshot;
  15. }
  16. function fromSnapshot(id, slideNum) {
  17. const sec = getSnapshot()[id];
  18. if (!sec) {
  19. return `<section class="report-section" id="${id}" data-slide-num="${slideNum}"><div class="section-inner"><h2 class="text-h1">[Missing] ${id}</h2></div></section>`;
  20. }
  21. return sec.html.replace(/data-slide-num="[^"]+"/, `data-slide-num="${slideNum}"`);
  22. }
  23. function renderPricing1Channel({ slideNum } = {}) { return fromSnapshot('pricing-1', slideNum); }
  24. function renderPricing2SpecBand({ slideNum } = {}) { return fromSnapshot('pricing-2', slideNum); }
  25. function renderPricing3Competitor({ slideNum } = {}) { return fromSnapshot('pricing-3', slideNum); }
  26. function renderPricing4Value({ slideNum } = {}) { return fromSnapshot('pricing-4', slideNum); }
  27. module.exports = {
  28. renderPricing1Channel,
  29. renderPricing2SpecBand,
  30. renderPricing3Competitor,
  31. renderPricing4Value,
  32. };