跳转至

文档 1.0

该文档已废弃

oauthapp 1.0.js 文件封装了所有接口,可直接引入到项目文件中,进行开发。

应用初始化

先去 创建应用 ,然后替换 {{appid}}

<script id="appcore" src="https://www.oauthapp.com/lib/sdk/oauthapp.1.0.0.js" data-appid="{{appid}}"></script>

框架已集成如下脚本库,无需再次引入。

名称 版本 说明
jquery 3.5.0 https://github.com/jquery/jquery
fingerprintjs2 2.1.0 https://github.com/Valve/fingerprintjs2.git
js-cookie 2.1.2 https://github.com/js-cookie/js-cookie
jweixin 1.6.0 http://res2.wx.qq.com/open/js/jweixin-1.6.0.js

用户

获取应用、用户信息

    $(async () => {
         // 自动注册用户
         await AppOnReady(true);
         // 只获取应用数据 await AppOnReady();
         console.log(App);
         console.log(AppUser);
    })

更新用户资料

参数为自定义的json对象。

     PutProfile({a:1,b:2,c:3}).then(x =>{
        console.log(x)
    });

排行榜

榜单集合

    AppRanks().then(x=>{
        console.log(x)
    });

单个榜单数据

    AppRank({{rankKey}}, {{platform}}, {{take}}).then(x=>{
        console.log(x)
    });
参数 必传 说明
rankKey 自定义的榜单key字符串
platform 默认为:web,可自定义
take 默认为:10

提交分数

    AppRankPostScore({{rankKey}}, {{data}}).then(x=>{
        console.log(x)
    });
参数 必传 说明
rankKey 自定义的榜单key字符串
data JSON类型,字段如下:
 {
   unionID: AppUser.unionID,
   avatar: AppUser.avatar,
   nickName: AppUser.nickName,
   platform: 'web',
   score: 100,
   data: JSON.stringify({ a: 1, b: 2, c: 3, d: 4 })  // 自定义数据
 }

我的排名

    AppRankMyIndex({{rankKey}}, {{platform}}, {{unionid}}).then(x=>{
        console.log(x)
    })
参数 必传 说明
rankKey 自定义的榜单key字符串
platform 默认为:web,可自定义
unionid 用户的unionid

数据库

数据表集合

    AppStorageTables().then(x=>{
        console.log(x)
    })

查询数据

    AppStorage({{tableName}}, {{filter}}, {{sort}},{{take}},{{skip}}).then(x=>{
        console.log(x)
    })
参数 必传 说明
tableName 自定义的榜单key字符串
filter json格式,如{id:"1"}
sort json格式,如{id:true}
take 拉取数据条数,默认10
skip 跳过数据条数,默认0

添加数据

    AppStoragePost({{tableName}}, {{jsonStr}}).then(x=>{
        console.log(x)
    })
参数 必传 说明
tableName 自定义的榜单key字符串
jsonStr json字符串

删除数据

    AppStorageDelete({{id}}).then(x=>{
        console.log(x)
    })
参数 必传 说明
id 数据的ID

更新数据

    AppStoragePut({{id}}, {{jsonStr}}).then(x=>{
        console.log(x)
    })
参数 必传 说明
id 数据的ID
jsonStr json字符串

属性

AppData

应用数据(需在AppOnReady方法后使用)

AppUser

用户数据(需在AppOnReady方法后使用)


最后更新: July 31, 2023