diff --git a/components/mip-ad/example/mip-ad-fd.html b/components/mip-ad/example/mip-ad-fd.html index ad0a56d4..0ba96552 100644 --- a/components/mip-ad/example/mip-ad-fd.html +++ b/components/mip-ad/example/mip-ad-fd.html @@ -17,7 +17,9 @@ width="100" height="30" type="ad-fd" - data-id="143"> + data-id="143" + data-dep="54,12" + data-dis="12100"> diff --git a/components/mip-ad/mip-ad-fd.js b/components/mip-ad/mip-ad-fd.js index 9303104d..a24a18ba 100644 --- a/components/mip-ad/mip-ad-fd.js +++ b/components/mip-ad/mip-ad-fd.js @@ -12,15 +12,36 @@ export default function render (el) { el.classList.add('__customer_place') if (window.CUSTOMER) { - loadSubScript(el) + setConditions(el) } else { window.require(['https://img.familydoctor.com.cn/component/common/scripts/gg_main.min'], function (CUSTOMER) { window.CUSTOMER = CUSTOMER - loadSubScript(el) + setConditions(el) }) } } +/** + * 设置定向条件 + * + * @param {HTMLElement} el 当前 mip-ad 组件的 DOM 元素 + */ +function setConditions (el) { + let dep = el.getAttribute('data-dep') + let dis = el.getAttribute('data-dis') + + if (dep) { + dep = dep.split(',') + window.CUSTOMER.setDep(...dep) + } + + if (dis) { + window.CUSTOMER.setDis(dis) + } + + loadSubScript(el) +} + /** * 加载广告位 js * diff --git a/components/mip-ad/mip-ad-fd.md b/components/mip-ad/mip-ad-fd.md index c9346bc3..bd70b84b 100644 --- a/components/mip-ad/mip-ad-fd.md +++ b/components/mip-ad/mip-ad-fd.md @@ -19,7 +19,9 @@ mip 广告组件 `` 的一种类型:家庭医生在线提供的广告 width="100" height="30" type="ad-fd" - data-id="143"> + data-id="143" + data-dep="54,12" + data-dis="12100"> ``` @@ -41,4 +43,20 @@ mip 广告组件 `` 的一种类型:家庭医生在线提供的广告 **必选项**:是 +**类型**:数字 + +### data-dep + +**说明**:按科室编号投放。可分两种情况:示例1、投放到一级科室 data-dep="54";示例2、投放到一级科室和二级科室 data-dep="54,12"。 + +**必选项**:否 + +**类型**:数字 + +### data-dis + +**说明**:按疾病编号投放。 + +**必选项**:否 + **类型**:数字 \ No newline at end of file