接口約定
- 使用https
- restful風格
- 用戶端:https://{域名}/api/{接口版本號}/{resource}/{resource_id}/{sub_resource}/{sub_resource_id}/{action}?{query_string}
- 管理端:https://{域名}/admin/api/{接口版本號}/{resource}/{resource_id}/{sub_resource}/{sub_resource_id}/{action}?{query_string}
- 測試環境域名babieta.xivan.cn
- 正式環境域名待定
- 公共參數放在header,如userid,session_key,unionid,version等
- resource: homepage
接口
GET /homepage
name | cname | type | Description |
---|---|---|---|
用途 | 獲取首頁內容 | ||
方式 | GET | ||
版本號 | v1.0 |
請求數據:
query_string 參數/可選參數
例
curl -i "https://babieta.xivan.cn/api/v1.0/homepage" -H "userid:oslC94mGqAAEz6iWhKhL9dEY5l3o" -H "token:25e8ba0469c6f1c0c6dcd4fe952b8e4e"
wx.request({
"url":"https://babieta.xivan.cn/api/v1.0/homepage",
"method":"GET",
"success": res =>{
console.log(res)
},
"data":{},
"dataType":"json",
"header": { "content-type":"application/x-www-form-urlencoded",
"userid": "oslC94mGqAAEz6iWhKhL9dEY5l3o", "token":"25e8ba0469c6f1c0c6dcd4fe952b8e4e"},
"complete": res => {
console.log(res)
}
})
返回數據:
name | cname | type | Description |
---|---|---|---|
code | int | 返回碼 0成功 非0失敗 | |
msg | string | 錯誤信息 | |
weekly | list<object> | 周進度 | |
daily | object | 日進度 | |
statistics | object | 歷史統計 |
例
{
"msg": "",
"code": 0,
"weekly": [ //周報
{
"date":1537027200, //時間點
"day_week":0, //周天
"score":{ //得分
"obtain":5, //已獲取得分
"max":25 //當日最大可獲取得分
},
"task": {
"express":{"word_count":5, "max_word_count":10},
"soak":{"duration":550, "max_duration":1500},
"communication":{"duration":550, "max_duration":1500}
}
},...
],
"daily": {
"date":1537027200,
"day_week":0,
"score": {
"obtain":5,
"max":25
}
"task": {
"express":{"word_count":5, "max_word_count":10},
"soak":{"duration":550, "max_duration":1500},
"communication":{"duration":550, "max_duration":1500}
}
}
"statistics":{
"express":{ "word_count":54},
"soak":{"duration":60000},
"communication":{"duration":5555}
}
}