aos-entity
v1.0.5
Published
restfulApi remote Data and do callback operation,store data cache,remember operation,auth logic
Downloads
5
Readme
##activityApi Model##
Entity 构建生成
npm install
gulp build --env qa 测试环境 debug模式
gulp build --env pro 产线版本
gulp build --env dev dev 环境 debug模式
生成dist目录 Entity.js
env 环境
prod
qa
dev
支持 api 请求 回调函数
auth
login
activity
signUp
reached
gifts
draw
energy
user
ecg
healthservice
[api detail]
`auth h5 页面 entity初始化`
Window.baseApi.setConfig({
userId:'876382025',
appId:'10400203',
security:'2gTO2MDN2gDNxYCMEhTQ0gzNClTMzkTL0IUO00yMCJDOtMkQGRTLzgTMFZDMwkjJ1IDMygzM2cDO'
});
`h5 页面auth 获取`
Window.Entity.auth.fetch(suc,fail)
`本地auth` 获取
console.log(Window.baseApi.getLocalAuthorization())
`后台管理系统登录初始化`
Window.baseApi.setConfig({
appId:'20100101',
userId:'',
security:''
});
`登录接口`
Window.Entity.login.fetch(suc,fail)
`华米医疗接口`
Window.Entity.medical.fetch(data,suc,fail)
Window.Entity.medical.detail(data,suc,fail)
`小米运动训练中心健康接口`
Window.Entity.healthservice.detail(data,suc,fail)
[活动类接口]
`抽奖`
Window.Entity.draw.fetch(suc,fail)
`用户信息接口`
Window.Entity.user.fetch(suc,fail)
`活动接口`
Window.Entity.activity.fetch(suc,fail)
`奖品接口`
Window.Entity.gifts.fetch(suc,fail)
`报名`
Window.Entity.signUp.fetch(suc,fail)
`达标`
Window.Entity.reached.fetch(suc,fail)
baseApi 基础类
支持 amd cmd
auth (baseApi.prototype.auth) --- baseApi 基础类方法
`Entity.reached.auth(callBackSuccess,callBackFail)`
`Entity.gifts.auth(callBackSuccess,callBackFail)`
Entity.auth.fetch(callBackSuccess,callBackFail)
get activity restful request
`Entity.reached.fetch(callBackSuccess,callBackFail)`
.....
`Entity.gifts.fetch(callBackSuccess,callBackFail)`
.....
`Entity.signUp.fetch(callBackSuccess,callBackFail)`
.....
`Entity.user.fetch(callBackSuccess,callBackFail)`
.....
`Entity.activity.fetch(callBackSuccess,callBackFail)`
缓存结果集
baseApi.request 静态
baseApi.joinIn 静态
Window.baseApi.getLocalAuthorization() 获取本地auth
组件初始化
baseApi.setConfig(config);
config{
appId; 设置活动id
userid; 设置用户id
security; 设置秘钥
}
记录操作
baseApi.hasReqApiErrList 记录获取数据失败的操作列表 静态
exp:
[
["activity",callBackSuccess,callBackFail],
["reached",callBackSuccess,callBackFail],
["user",callBackSuccess,callBackFail]
]
baseApi.hasReqApiErrMap 记录获取数据失败操作列表 map对象
exp:
{
activity : ["activity",callBackSuccess,callBackFail],
reached : ["reached",callBackSuccess,callBackFail],
user : ["user",callBackSuccess,callBackFail]
}
baseApi.hasReqApiList 记录获取数据成功操作的方法列表 静态
exp: ["activity", "user", "reached"]
entity 用于各个接口apiModel的配置,初始化; 继承于 baseApi
活动,用户基础数据
app_key
key
token
auth
baseApi.getCommonParams()
Entity.auth.getUser()
do_Operation 重新发起请求
exp:
Entity.activity.do_Operation(["activity",callBackSuccess,callBackFail])
Entity.activity.do_Operation(baseApi.hasReqApiErrList.pop())
互斥登录异常处理,重新发起上一次请求
auth成功后 发起 hasReqApiErrList 队列中未成功的最后一条操作