饿了么开放平台连锁运营渠道场景接入方案对接流程
4.1 key 申请
点此去申请。
4.2 入参准备
总共需要三个入参,数据结构形式为:Map<{token, appkey}, shopId>,给到前端:
shopId(饿了么门店ID):饿了么商家版 - 门店管理 - 门店信息 - 门店号
appKey:商家开放平台管理中心 - 查看应用 - 正式环境 - Key
access_token(对应的授权token):文档中心 - 开发文档 - 授权说明
4.3 页面加载及消息传递
加载UI-SDK页面地址:https://uisdk.faas.ele.me?source=${key}, 其中${key}需要换成 4.1 所申请的key值,如果没有申请,会被拦截
父页面监听子页面准备完成的消息‒ type类型为:ELE_UI_SDK_INITED
window.addEventListener('message', (event) => { const { type } = event.data || {}; if (type && type === 'ELE_UI_SDK_INITED') { // 组装门店信息,并按第3步的描述发送 } });
发送门店列表数据消息
‒ type类型为:ELE_UI_SDK_SHOP_CHANGED
‒ targetWindow为子页面
childWindow.postMessage( { type: "ELE_UI_SDK_SHOP_CHANGED", data: { shopsInfo: [ { // 111,222,333,444共享一个key和token appInfoParam: { appKey: "******", token: "********", }, shopIds: [1111, 2222, 3333, 4444], }, { // 555,666,777,888共享一个key和token appInfoParam: { appKey: "******", token: "********", }, shopIds: [555, 666, 777, 888], }, ], }, }, "*" );