# -*- coding: utf-8 -*- """票 12 补验:contact/search + customer/search 真请求(只读端点)""" import io, json, sys sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') from playwright.sync_api import sync_playwright URL = 'file:///E:/code/crm-backend-matt/.scratch/customer-demo-ref/demo/index.html' errors = [] out = {} with sync_playwright() as p: b = p.chromium.launch() pg = b.new_page(viewport={'width': 1720, 'height': 1080}) pg.on('pageerror', lambda e: errors.append(str(e))) pg.goto(URL) pg.wait_for_timeout(600) pg.fill('#uidInput', '739564171091247104') pg.evaluate('loginByUid()') pg.wait_for_timeout(2500) # contact/search:keyword=张关键(seed 联系人) r1 = pg.evaluate('''async () => { const arr = await api('/api/customer/contact/search?keyword=' + encodeURIComponent('张关键') + '&limit=20'); return { n: (arr || []).length, first: arr && arr[0] ? { name: arr[0].name, phone: arr[0].phone, customerName: arr[0].customerName, source: arr[0].source } : null }; }''') out['contact_search'] = r1 # customer/search:keyword=e2c 三维模糊 + excludeCustomerIds 重复键 r2 = pg.evaluate('''async () => { const d = await api('/api/customer/search', { method: 'POST', body: 'keyword=e2c&archiveStatus=1&excludeCustomerIds=750844487390986240' }); return { total: d && d.total, row0: d && d.content && d.content[0] ? { customerNo: d.content[0].customerNo, ownerName: d.content[0].ownerName, customerStage: d.content[0].customerStage } : null }; }''') out['customer_search'] = r2 b.close() out['pageerror'] = errors print(json.dumps(out, ensure_ascii=False, indent=1))