开发手册TurboScript

TurboScript 配置 & 调用

接入步骤:

配置TurboScript

  • Dashboard后台Turbo Script中新建Script、配置对应信息

下载TurboBanner脚本代码

  • 配置完 Script后在 Script列表下载对应脚本代码(.txt)

使用脚本代码

  • 1、新建js文件 - 将脚本中压缩代码(下方图片红框以外的代码)添加到js文件中
  • 2、页面中引入新建的js文件
  • 3、将调用代码添加到页面中(下方图片红框内的代码)

  • 调用方式
<script src="path/to/script.js"></script>
<script>
    const oneLinkURL = "https://user1.allapp.link/ctp63s0gpf6risd0b95g";
    const webReferrer = "";
    const turboParameters = [{"key":"utm_source","incomingParams":["old_source"],"defaultVal":"defaultVal"}]
    
    //Call the function after embedding the code through a global parameter on the window object called window.TURBO_SCRIPT.
    //Onelink URL is generated.
    const result = window.TURBO_SCRIPT.generateOneLinkURL({
        oneLinkURL: oneLinkURL,
        turboParameters: turboParameters,
        webReferrer: webReferrer,
        tbid: "you script ID"
    });
 
    console.log(result?.clickURL)
 
    // Here are the platform links
    // console.log(result?.appleURL)
    // console.log(result?.googleURL)
    // console.log(result?.huaweiURL)
    // console.log(result?.xiaomiURL)
    // console.log(result?.samsungURL)
    // console.log(result?.oppoURL)
    // console.log(result?.vivoURL)
 
 
    // if (result) {
    //     /**
    //       * Display QR code method
    //       * @param1 {string} QR code container ID
    //       * @param2 {options} Optional configuration
    //       * @options logo:  Logo address, pay attention to cross domain
    //       * @options codeColor:  QR code color, Format of hexadecimal colors
    //       * @options platform: Platform type, QR code for different platform links, only supports parameters: google apple huawei xiaomi samsung oppo vivo
    //       * @returns void
    //     */
    //     window.TURBO_SCRIPT.displayQrCode("QRCodeContainerID");
    // }
</script>  
  • 链接赋值方式
<a href="" id="linkLabel">应用商店地址</a>
<a href="" id="appleLinkLabel">苹果商店地址</a>
<a href="" id="googleLinkLabel">谷歌商店地址</a>
<a href="" id="huaweiLinkLabel">华为商店地址</a>
<a href="" id="xiaomiLinkLabel">小米商店地址</a>
<a href="" id="samsungLinkLabel">三星商店地址</a>
<a href="" id="oppoLinkLabel">oppo商店地址</a>
<a href="" id="vivoLinkLabel">vivo商店地址</a>
<script src="path/to/script.js"></script>
<script>
    const oneLinkURL = "https://user1.allapp.link/ctp63s0gpf6risd0b95g";
    const webReferrer = "";
    const turboParameters = [{"key":"utm_source","incomingParams":["old_source"],"defaultVal":"defaultVal"}]
   
    const result = window.TURBO_SCRIPT.generateOneLinkURL({
        oneLinkURL: oneLinkURL,
        turboParameters: turboParameters,
        webReferrer: webReferrer,
        tbid: "you script ID"
    });
 
    const { clickURL, appleURL, googleURL, huaweiURL, xiaomiURL, samsungURL, oppoURL, vivoURL } = result || {}
 
    const setLinkHref = (id, url) => {
        const element = document.getElementById(id);
        if (element) {
            element.href = url;
        }
    }
 
    setLinkHref("linkLabel", clickURL)
    setLinkHref("appleLinkLabel", appleURL)
    setLinkHref("googleLinkLabel", googleURL)
    setLinkHref("huaweiLinkLabel", huaweiURL)
    setLinkHref("xiaomiLinkLabel", xiaomiURL)
    setLinkHref("samsungLinkLabel", samsungURL)
    setLinkHref("oppoLinkLabel", oppoURL)
    setLinkHref("vivoLinkLabel", vivoURL)
</script>  

生成二维码

<div id="QRCodeContainerID">
 
<script>
 window.TURBO_SCRIPT.displayQrCode("QRCodeContainerID");
</script>

result数据字段说明

字段名说明类型
clickURL生成的脚本链接string
appleURLiOS平台链接string
googleURLgoogle链接string
huaweiURL华为平台链接string
xiaomiURL小米平台链接string
samsungURL三星平台链接string
oppoURLoppo平台链接string
vivoURLvivo平台链接string

window.TURBO_SCRIPT.displayQrCod方法参数说明

  • 参数1:二维码容器ID

  • 参数2(对象)

参数说明类型必需默认值
logo二维码logo地址,需处理跨域string
codeColor二维码颜色,十六进制颜色格式string
platform不同平台链接的二维码,仅支持参数:google、apple、huawei、xiaomi、samsung、oppo、vivostring