import {AdwareLinkType, AdwareParams} from "@/api";
import Taro from "@tarojs/taro";

/** 拼接完整路径 */
export function jumpAdware(advert_link: AdwareLinkType) {
  if (advert_link.path && advert_link.param) {
    let url = advert_link.path + "?"
    const params: AdwareParams[] = JSON.parse(advert_link.param)
    params.forEach((d, index) => {
      url += d.key + "=" + d.value
      if (index !== params.length - 1) {
        url += "&"
      }
    })
    Taro.navigateTo({url})
  }
}
