获取小程序列表
此接口暂不支持在CloudGrid里面调试[!TIP|labelVisibility:hidden|iconVisibility:hidden] navigator.miniProgram.getMiniProgramList(options,success,error)
支持平台:
- Android
- iOS
参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
options | Object | 是 | 数据对象 |
success | Function | 是 | 成功回调函数 |
error | Function | 是 | 失败回调函数 |
options
参数为一个对象,其属性包含以下一项或多项:
APPID
(String/必选) --应用ID,对应平台创建的APPID,参考start
(String/可选) --当前页,默认1size
(String/可选) -每页个数,默认20
success
函数会返回一个对象,其属性包含以下一项或多项:
total
(Int) --小程序总数pageNum
(Int) --当前页码pageSize
(Int) --每页的数量size
(Int) --当前页的数量startRow
(Int) --记录起始行endRow
(Int) --记录终止行pages
(Int) --总页数prePage
(Int) --上一页nextPage
(Int) --下一页isFirstPage
(Boolean)--是否是第一页isLastPage
(Boolean) --是否是最后一页hasPreviousPage
(Boolean)--暂未用到hasNextPage
(Boolean)--暂未用到navigatePages
(Int)--暂未用到navigatepageNums
(Array)--暂未用到navigateFirstPage
(Int)--暂未用到navigateLastPage
(Int)--暂未用到list
(Array) --小程序列表信息,数组里面是小程序对象,该对象其属性包含以下一项或多项:id
(Int) --小程序iduniqueCode
(String) --小程序唯一编号name
(String) --小程序名称type
(Int) --小程序类型(0:在线,1:离线)indexUrl
(String) --小程序首页地址logoUrl
(String) --小程序图标remark
(String) --小程序备注scope
(String) --小程序领域offlineUrl
(String) --离线资源地址updateTime
(Int) --更新时间,毫秒remoteUrl
(String) --服务器地址
error
函数会返回一个对象,其属性包含以下一项或多项:
code
(Int) -- 错误码resultDes
(String) --错误描述
错误码说明
错误码 | 说明 |
---|---|
98 | 参数缺失 |
99 | 网络问题 |
101 | 其他错误 |
102 | 参数错误 |
103 | Token超时 |
104 | Token不匹配 |
105 | Token缺失 |
示例代码
// 引用js
<script src='supconit://hcmobile.js'></script>
<script>
// 监听’deviceready‘事件
document.addEventListener('deviceready', onDeviceReady, false)
function onDeviceReady(){
var options = {'APPID':'2'};
navigator.miniProgram.getMiniProgramList(options,
function (success) {
alert(JSON.stringify(success));
},
function (error) {
alert(JSON.stringify(error));
});
}
</script>
响应成功示例代码:
{
"endRow": 1,
"hasNextPage": false,
"pages": 1,
"pageNum": 1,
"navigatepageNums": [
1
],
"isLastPage": true,
"total": 1,
"nextPage": 0,
"navigatePages": 8,
"size": 1,
"hasPreviousPage": false,
"navigateFirstPage": 1,
"startRow": 1,
"navigateLastPage": 1,
"prePage": 0,
"list": [
{
"remark": null,
"indexUrl": "index.html",
"remoteUrl": "http://...",
"id": 140,
"logoUrl": "http://.....png",
"scope": "购物",
"offlineUrl": "http://../.zip",
"updateTime": 1578379102000,
"uniqueCode": "2224249",
"type": 1,
"name": "哈哈哈"
}
],
"isFirstPage": true,
"pageSize": 20
}
响应失败示例代码:
{
"resultDes": "获取应用下小程序失败!不存在应用id是[2]的应用",
"code": 101
}