// 拦截 buy-service 的 API 请求/响应，看实际数据结构
const { chromium } = require('playwright');
(async () => {
  const browser = await chromium.launch({ headless: true });
  const page = await (await browser.newContext({viewport:{width:1280,height:900}})).newPage();
  page.on('response', async (resp) => {
    const url = resp.url();
    if (url.includes('get-buy-service-info')) {
      console.log('=== buy-service API 响应 ===');
      console.log('状态:', resp.status());
      try {
        const body = await resp.text();
        console.log('body:', body.slice(0, 700));
      } catch(e) { console.log('读 body 失败'); }
    }
  });
  page.on('pageerror', e => console.log('PAGEERR:', e.message.slice(0,150)));
  page.on('console', m => { if (m.text().startsWith('data:') || m.text().includes('RangeError')) console.log('CONSOLE:', m.text().slice(0,200)); });
  await page.goto('http://127.0.0.1:8099/buy-service/1/pos', { waitUntil: 'load' }).catch(()=>{});
  await page.waitForTimeout(8000);
  await browser.close();
})();
