开发流程
概述
第三方平台代开发与普通开发在前后端上均有所区别,其所拥有的各项 API 以及详细说明请查看代授权小程序业务部分,其余部分请阅读下文。
第三方平台代开发小程序具有一定的复杂性,首先需要明确三个概念:
- 授权小程序(extAppid):由普通用户创建在字节小程序开发者平台的。在授权给第三方平台后,具体内容由第三方服务商代为开发设置。
- 第三方平台(thirdparty):由服务商在字节小程序第三方平台创建的。创建完后,可以绑定开发小程序作为模版,然后代客户进行开发。
- 开发小程序(thirdpartyDevAppid):由服务商在字节小程序开发者平台创建的,并且绑定在第三方平台上的小程序,用于开发小程序模板。如下图所示,该第三方平台绑定了两个开发小程序:

第三方平台相关的小程序开发需要做一些特殊的处理:
- 小程序模板的开发
- 小程序模板结合 extAppid 的开发调试
开发者工具(IDE)创建项目
与开发普通小程序一致,在开发者工具创建项目时 AppId 填入第三方平台的开发小程序 thirdpartyDevAppid,设定项目名称和选择项目目录即可创建项目。
对于第三方平台的开发小程序,可以在详情页卡查看到相关的 thirdparty 信息以及当前第三方的 thirdpartyDevAppid,如若项目配置了相关的 extAppid,那么项目页卡中也会有相关信息。如下图所示。

小程序模板开发
与开发普通小程序一致,开发者在开发工具上开发好相关的业务逻辑之后,在项目页卡中点击预览按钮,即可以在抖音等客户端中查看小程序的真实表现。
有所不同的是,第三方平台的开发小程序提交上传是上传至该第三方平台帐号下的草稿箱中,需要该平台的管理员将该草稿添加至模版库之后,才能调用代授权小程序上传、提审等接口,更多请参考代授权小程序业务。
extAppid 的开发调试
为了方便第三方平台的开发者引入 extAppid 的开发调试工作,需要引入 ext.json 的概念。 ext.json 是一个配置文件,放置在小程序项目的根目录下。
ext.json 中的配置字段分为两种
- 特有的字段
- 同 app.json 相同的字段
特有的字段
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
extEnable | bool | 是 | 当前配置 ext.json 是否生效 |
extAppid | string | 是 | 授权小程序 appid |
ext | object | 否 | 开发者自定义的数据字段 在小程序中可以通过 tt.getExtConfigSync 或者 tt.getExtConfig 获取到这些配置信息。 |
extPages | object | 否 | 单独设置每个页面的 json 对象中的每个 key 应该是该小程序模板 app.json 中定义的页面,每个 key 对应的 value 是 page.json 中所规定的各项配置。 |
同 app.json 相同的字段
当 ext.json 中的字段同 app.json 中一致时,ext.json 的字段会覆盖 app.json 中的对应字段,例如以下的 ext.json:
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "Ext Demo",
"navigationBarTextStyle":"black"
}
那么该小程序最终的 navigationBarTitleText 应该是 Ext Demo 。
示例
以下是一个包含了所有配置选项的 ext.json:
{
"extEnable": true,
"extAppid": "tt1bbd6d008497a3ef",
"extPages": {
"pages/index/index": {
"navigationBarTitleText": "index ext tab"
},
"pages/home/index": {
"navigationBarTitleText": "home ext tab"
}
},
"ext": {
"authAppid": "tt1bbd6d008497a3ef"
},
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "Demo",
"navigationBarTextStyle":"black"
},
"pages": [
"pages/home/index",
"pages/index/index"
],
"networkTimeout": {
"request": 80000,
},
"tabBar": {
"selectedColor": "#3227af",
"backgroundColor": "#dddddd",
"list": [
{
"pagePath": "pages/home/index",
"text": "home",
"iconPath": "static/tabBar/old.png",
"selectedIconPath": "static/tabBar/new.png"
},
{
"pagePath": "pages/index/index",
"text": "index",
"iconPath": "static/tabBar/old.png",
"selectedIconPath": "static/tabBar/new.png"
}
]
}
}
相比平时 app.json 配置:
{
"window": {
"navigationBarTitleText": "app Demo",
"navigationBarTextStyle": "yellow",
"disableScroll": true
},
"pages": ["pages/index/index"],
"networkTimeout": {
"connectSocket": 60000,
"request": 10000
},
"tabBar": {
"color": "#f335f2",
"selectedColor": "#32f7a3",
"list": [
{
"pagePath": "pages/index/index",
"text": "index",
"iconPath": "static/tabBar/old.png",
"selectedIconPath": "static/tabBar/new.png"
},
{
"pagePath": "pages/home/index",
"text": "home",
"iconPath": "static/tabBar/old.png",
"selectedIconPath": "static/tabBar/new.png"
}
]
}
}
所以,ext.json 与 app.json 最终处理结果:
{
"window": {
"disableScroll": true,
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "app Demo",
"navigationBarTextStyle": "yello"
},
"networkTimeout": {
"connectSocket": 60000,
"request": 80000
},
"pages": ["pages/home/index", "pages/index/index"],
"tabBar": {
"color": "#f335f2",
"selectedColor": "#3227af",
"backgroundColor": "#dddddd",
"list": [
{
"pagePath": "pages/home/index",
"text": "home",
"iconPath": "static/tabBar/old.png",
"selectedIconPath": "static/tabBar/new.png"
},
{
"pagePath": "pages/index/index",
"text": "index",
"iconPath": "static/tabBar/old.png",
"selectedIconPath": "static/tabBar/new.png"
}
]
}
}