Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
llewan-weixin-sdk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
llewan
llewan-weixin-sdk
Commits
735b4bdf
Commit
735b4bdf
authored
Oct 10, 2018
by
liuxinjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加注释以及跳转小程序方法加上跳转环境参数
parent
fe8d29ce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
25 deletions
+50
-25
sdk.js
assets/llewan-weixin-sdk/sdk.js
+50
-25
No files found.
assets/llewan-weixin-sdk/sdk.js
View file @
735b4bdf
...
...
@@ -66,19 +66,25 @@ var sdk = {
/**
* @apiGroup A
* @apiName init
* @api {初始化sdk} 使用sdk前,必须先初始化一次才能使用 init(初始化sdk)
*
* @apiParam {Boolean} [debug=false] 是否开启调试
* @apiParam {int} [userid] 用户的id(兼容旧游戏,新游戏废弃)
* 从v1.006版本的sdk已经废弃改方法,只需要调用sdk.WeChatLogin方法就可以了
*
* @apiSuccessExample {json} 示例:
* //.初始化游戏
* sdk.init({
* debug: true, //.是否开启调试
* userid: 56032607 //.用户的id(兼容旧游戏,新游戏废弃)
* }, (res)=>{
* console.log('sdk初始化结果:', res)
* })
* sdk.WeChatLogin((d)=>{
* var config1 = sdk.getConfig1();
* if(config1.hz2==1)
* {
* //显示
* xxx.active = true;
* xxx.addClickListener(() => {
* var d = sdk.getButtonConfig('hz2');
* //跳转到对应的小程序或者游戏
* sdk.navigateToMiniProgram(d);
* });
* }else
* {
* //隐藏
* }
*
* });
*/
init
(
args
,
callback
){
var
self
=
this
;
...
...
@@ -186,12 +192,26 @@ var sdk = {
* @apiGroup C
* @apiName WeChatLogin
* @api {新增、授权、登陆} 微信登录 WeChatLogin 对外提供新增、授权、登陆调用以及初始化
* 注意v1.006版本sdk 只需要调用登录就可以了不在需要调用init了,sdk内部已经做了init操作了
*
* @apiSuccessExample {json} 示例:
* sdk.WeChatLogin((d)=>{
* console.log("用户信息:", d)
* // 登录成功:返回用户信息;
* // 登录失败:返回false
* var config1 = sdk.getConfig1();
* var config1 = sdk.getConfig1();
* if(config1.hz2==1)
* {
* //显示
* xxx.active = true;
*
* xxx.addClickListener(() => {
* var d = sdk.getButtonConfig('hz2');
* //跳转到对应的小程序或者游戏
* sdk.navigateToMiniProgram(d);
* });
* }else
* {
* //隐藏
* }
*
* });
*
*/
...
...
@@ -1542,9 +1562,12 @@ var sdk = {
* @apiName setToServer
* @api {setToServer} 数据存储 setToServer(存)
* @apiParam {String} dataKey 键
* @apiParam {String} dataType 数据类型
* @apiParam {String} dataType 数据类型
,首字母大学的驼峰形式,例如:ShareGroup 或者 ShareLimit
* @apiParam {String} data 需要保存的数据
* @apiParam {String} expireTime 过期时间 单位(秒),0:默认一天;-1:永不失效(10年);
*
* 注意:dataKey和dataType共同确定一个数据的key值,也就是说 如果同样传递key111但是如果dataType不一样,sdk会认为是不同的两个数据key
*
* var data = {'key3':'test'};
* sdk.setToServer("testKeyttt3","TestData",data,3600);
*
...
...
@@ -1578,7 +1601,7 @@ var sdk = {
* @apiName getFromServer
* @api {getFromServer} 数据存储 getFromServer(获取)
* @apiParam {String} dataKey 键
* @apiParam {String} dataType 数据类型
* @apiParam {String} dataType 数据类型
首字母大学的驼峰形式,例如:ShareGroup 或者 ShareLimit
* @apiParam {String} data 特殊情况下需要传递额外数据状况,一般不传递
* @apiParam {String} callback 回调
*
...
...
@@ -1948,10 +1971,10 @@ var sdk = {
* @apiGroup C
* @apiName getButtonConfig
* @api {数据存储} 数据存储 getButtonConfig(取)
* @apiParam {String} buttonKey
键
* @apiParam {String} buttonKey
按钮的键值 比如 hz2 hz3
*
* @apiSuccessExample {json} 示例:
* var
nick = sdk.getButtonConfig("send_pic")
* var
d = sdk.getButtonConfig("hz2");
*/
getButtonConfig
(
buttonKey
){
...
...
@@ -1993,13 +2016,14 @@ var sdk = {
* @apiGroup C
* @apiName navigateToMiniProgram
* @api 跳转到小程序或者小游戏注意有时间限定 navigateToMiniProgram
* @apiParam {json} config json包含app_id,path,extraData
* @apiParam {json} config json包含app_id,path,extraData
,env_version
* @apiParam {fucntion} success 成功返回
* @apiParam {fucntion} fail 失败返回
* @apiParam {fucntion} complete 完成返回
*
* @apiSuccessExample {json} 示例:
* var nick = sdk.setOnClickListener("send_pic")
* var d = sdk.getButtonConfig('hz2');
* sdk.navigateToMiniProgram(d);
*/
navigateToMiniProgram
(
config
,
success
,
fail
,
complete
)
...
...
@@ -2008,9 +2032,10 @@ var sdk = {
if
(
nowTime
>=
config
.
s_time
&&
nowTime
<=
config
.
e_time
)
{
wx
.
navigateToMiniProgram
({
appId
:
config
.
app_id
,
//string 要打开的小程序appId
path
:
config
.
path
,
//string 打开的页面路径,如果为空则打开首页
extraData
:
config
.
extra
,
//object 需要传递给目标小程序的数据
appId
:
config
.
app_id
,
// 要打开的小程序appId
path
:
config
.
path
,
// 打开的页面路径,如果为空则打开首页
extraData
:
config
.
extra
,
// 需要传递给目标小程序的数据
envVersion
:
config
.
env_version
,
//特殊情况下需要跳转到对应小程序的开发版本
success
:
success
,
fail
:
fail
,
complete
:
complete
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment