Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
weixin_sdk_release
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
JIRA
JIRA
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
open
weixin_sdk_release
Commits
16935593
提交
16935593
authored
8月 15, 2018
作者:
王进
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加授权按钮功能
上级
c3699830
全部展开
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
346 行增加
和
4 行删除
+346
-4
SDK.ts
20180814_1115/SDK.ts
+10
-4
Platform.ts
20180815_1049/Platform.ts
+99
-0
SDK.ts
20180815_1049/SDK.ts
+0
-0
platform.js
20180815_1049/platform.js
+237
-0
没有找到文件。
20180814_1115/SDK.ts
浏览文件 @
16935593
...
...
@@ -22,15 +22,23 @@ class WechatSDK {
that
.
ReportParams
.
productCode
=
that
.
sdkParams
.
product_code
=
Config
.
productCode
that
.
sdkParams
.
appid
=
Config
.
appid
that
.
sdkParams
.
version
=
Config
.
sdkVersion
const
p1
=
platform
.
onShow
().
then
(
res
=>
{
const
p1
=
platform
.
getLaunchOptionsSync
().
then
(
res
=>
{
let
queryObj
=
res
.
referrerInfo
&&
res
.
referrerInfo
.
extraData
&&
Object
.
keys
(
res
.
referrerInfo
.
extraData
).
length
>
0
?
res
.
referrerInfo
.
extraData
:
{}
res
=
that
.
deepCopy
({},
res
.
query
,
queryObj
)
that
.
printf
(
"SDK -> p1:"
,
0
)
that
.
printf
(
res
,
0
)
that
.
ReportParams
.
from
=
res
.
from
||
''
that
.
ReportParams
.
tag
=
res
.
tag
||
''
that
.
ReportParams
.
fromOpenId
=
res
.
fromId
||
''
},
err
=>
{
console
.
log
(
err
)
})
const
p2
=
platform
.
getNetworkType
().
then
(
res
=>
{
that
.
printf
(
"SDK -> p2:"
,
0
)
that
.
printf
(
res
,
0
)
that
.
ReportParams
.
networkType
=
res
.
networkType
},
err
=>
{
console
.
log
(
err
)
})
const
p3
=
platform
.
getSystemInfo
().
then
(
res
=>
{
that
.
printf
(
"SDK -> p3:"
,
0
)
that
.
printf
(
res
,
0
)
that
.
ReportParams
.
model
=
that
.
sdkParams
.
equipmentname
=
res
.
model
that
.
ReportParams
.
screenWidth
=
res
.
screenWidth
that
.
ReportParams
.
screenHeight
=
res
.
screenHeight
...
...
@@ -38,10 +46,9 @@ class WechatSDK {
that
.
ReportParams
.
system
=
that
.
sdkParams
.
equipmentos
=
res
.
system
that
.
ReportParams
.
version
=
res
.
version
},
err
=>
{
console
.
log
(
err
)
})
that
.
printf
(
"SDK -> 统计参数:"
,
0
)
that
.
printf
(
that
.
ReportParams
,
0
)
// 同步完所有参数后调用getUserOpenId
Promise
.
all
([
p1
,
p2
,
p3
]).
then
(
res
=>
{
console
.
log
(
"队列结束...."
)
that
.
getUserOpenId
()
},
err
=>
{
console
.
log
(
err
)
})
}
...
...
@@ -267,7 +274,6 @@ class WechatSDK {
let
keys
=
Object
.
keys
(
obj
).
sort
();
let
key_url
=
""
;
for
(
let
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
obj
[
keys
[
i
]]
=
encodeURI
(
obj
[
keys
[
i
]])
if
(
keys
[
i
]
!=
'sign'
)
key_url
+=
keys
[
i
]
+
'='
+
obj
[
keys
[
i
]]
+
'&'
}
key_url
=
key_url
+
Config
.
productKey
...
...
20180815_1049/Platform.ts
0 → 100644
浏览文件 @
16935593
/**
* 平台数据接口。
* 由于每款游戏通常需要发布到多个平台上,所以提取出一个统一的接口用于开发者获取平台数据信息
* 推荐开发者通过这种方式封装平台逻辑,以保证整体结构的稳定
* 由于不同平台的接口形式各有不同,白鹭推荐开发者将所有接口封装为基于 Promise 的异步形式
*/
declare
interface
Platform
{
getUserInfo
():
Promise
<
any
>
;
login
():
Promise
<
any
>
getNetworkType
():
Promise
<
any
>
getSystemInfo
():
Promise
<
any
>
onShow
():
Promise
<
any
>
request
(
uri
,
data
,
method
):
Promise
<
any
>
showModal
(
obj
):
Promise
<
any
>
share
(
obj
):
Promise
<
any
>
pay
(
params
):
Promise
<
any
>
shareInit
():
Promise
<
any
>
addShareEvent
(
params
):
Promise
<
any
>
customer
(
params
):
Promise
<
any
>
navigateToMiniProgram
(
params
):
Promise
<
any
>
showToast
(
params
):
Promise
<
any
>
showMsg
(
str
):
Promise
<
any
>
exitWechatApp
():
Promise
<
any
>
getLaunchOptionsSync
():
Promise
<
any
>
createUserInfoButton
():
Promise
<
any
>
}
class
DebugPlatform
implements
Platform
{
async
getUserInfo
()
{}
async
login
()
{}
async
getNetworkType
(){}
async
getSystemInfo
(){}
async
onShow
()
{}
async
request
(
uri
,
data
,
method
){}
async
showModal
(
obj
)
{}
async
share
(
obj
)
{}
async
pay
(
params
)
{}
async
shareInit
()
{}
async
addShareEvent
(
params
)
{}
async
customer
(
params
)
{}
async
navigateToMiniProgram
(
params
)
{}
async
showToast
(
params
)
{}
async
showMsg
(
str
)
{}
async
exitWechatApp
()
{}
async
getLaunchOptionsSync
()
{}
async
createUserInfoButton
()
{}
}
if
(
!
window
.
platform
)
{
window
.
platform
=
new
DebugPlatform
();
}
declare
let
platform
:
Platform
;
declare
interface
Window
{
platform
:
Platform
}
\ No newline at end of file
20180815_1049/SDK.ts
0 → 100644
浏览文件 @
16935593
差异被折叠。
点击展开。
20180815_1049/platform.js
0 → 100644
浏览文件 @
16935593
/**
* 请在白鹭引擎的Main.ts中调用 platform.login() 方法调用至此处。
*/
class
WxgamePlatform
{
name
=
'wxgame'
login
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
login
({
success
:
(
res
)
=>
{
resolve
(
res
)
},
fail
:
(
res
)
=>
{
reject
(
res
)
}
})
}).
catch
((
error
)
=>
{
console
.
error
(
error
);
})
}
getUserInfo
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
getUserInfo
({
withCredentials
:
true
,
success
:
function
(
res
)
{
resolve
(
res
);
},
fail
:
function
(
res
)
{
reject
(
res
)
}
})
}).
catch
((
error
)
=>
{
console
.
error
(
error
);
})
}
getSystemInfo
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
getSystemInfo
({
success
:
(
res
)
=>
{
resolve
(
res
);
}
})
}).
catch
((
error
)
=>
{
console
.
error
(
error
);
})
}
getNetworkType
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
getNetworkType
({
success
:
(
res
)
=>
{
resolve
(
res
);
}
})
}).
catch
((
error
)
=>
{
console
.
error
(
error
);
})
}
request
(
URI
,
DATA
,
METHOD
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
request
({
url
:
URI
,
method
:
METHOD
,
data
:
DATA
,
header
:
{
'Content-Type'
:
'json'
},
success
:
resolve
,
fail
:
reject
})
}).
catch
((
error
)
=>
{
reject
(
error
)
})
}
showModal
(
DATA
)
{
wx
.
showModal
(
Object
.
assign
({},
DATA
,
{
cancelText
:
'取消'
,
confirmText
:
'确认'
}))
}
showMsg
(
str
)
{
wx
.
showToast
({
title
:
str
,
duration
:
1500
})
}
share
(
DATA
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
shareAppMessage
(
Object
.
assign
(
DATA
,
{
success
:
function
(
res
)
{
resolve
(
res
)
},
fail
:
function
(
res
)
{
reject
(
res
)
},
complete
()
{}
}))
})
}
shareInit
()
{
wx
.
showShareMenu
({
withShareTicket
:
true
,
success
:
()
=>
{},
fail
:
()
=>
{},
complete
:
()
=>
{}
})
}
addShareEvent
(
DATA
)
{
wx
.
onShareAppMessage
(()
=>
{
return
Object
.
assign
(
DATA
,
{
success
:
function
()
{},
fail
:
function
()
{},
complete
()
{}
})
})
}
getLaunchOptionsSync
()
{
return
new
Promise
((
resolve
)
=>
{
const
options
=
wx
.
getLaunchOptionsSync
()
if
(
Object
.
keys
(
options
.
query
).
length
>
0
||
Object
.
keys
(
options
.
referrerInfo
).
length
>
0
)
{
const
obj
=
{}
Object
.
assign
(
obj
,
options
.
query
,
options
.
referrerInfo
.
extraData
)
// 合并数据
resolve
(
obj
)
}
else
{
resolve
(
options
)
}
})
}
pay
(
params
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
requestMidasPayment
(
Object
.
assign
(
params
,
{
success
:
function
(
res
)
{
resolve
(
res
)
},
fail
:
function
(
res
)
{
reject
(
res
)
},
complete
:
function
()
{
console
.
log
(
"Rechare"
)
}
}))
})
}
customer
(
params
)
{
wx
.
openCustomerServiceConversation
(
params
)
}
navigateToMiniProgram
(
params
)
{
wx
.
navigateToMiniProgram
(
params
)
}
exitWechatApp
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
exitMiniProgram
({
success
:
function
(
res
)
{
console
.
log
(
'退出成功'
)
resolve
(
res
)
},
fail
:
function
(
res
)
{
console
.
log
(
'退出失败'
)
reject
(
res
)
}
})
})
}
createUserInfoButton
()
{
const
UserInfoButton
=
wx
.
createUserInfoButton
({
type
:
'text'
,
text
:
' '
,
style
:
{
left
:
0
,
top
:
0
,
width
:
800
,
height
:
1200
,
backgroundColor
:
'rgba(0, 0, 0, 0)'
,
color
:
'#ffffff'
}
})
return
UserInfoButton
}
openDataContext
=
new
WxgameOpenDataContext
();
}
class
WxgameOpenDataContext
{
createDisplayObject
(
type
,
width
,
height
)
{
const
bitmapdata
=
new
egret
.
BitmapData
(
sharedCanvas
);
bitmapdata
.
$deleteSource
=
false
;
const
texture
=
new
egret
.
Texture
();
texture
.
_setBitmapData
(
bitmapdata
);
const
bitmap
=
new
egret
.
Bitmap
(
texture
);
bitmap
.
width
=
width
;
bitmap
.
height
=
height
;
if
(
egret
.
Capabilities
.
renderMode
==
"webgl"
)
{
const
renderContext
=
egret
.
wxgame
.
WebGLRenderContext
.
getInstance
();
const
context
=
renderContext
.
context
;
////需要用到最新的微信版本
////调用其接口WebGLRenderingContext.wxBindCanvasTexture(number texture, Canvas canvas)
////如果没有该接口,会进行如下处理,保证画面渲染正确,但会占用内存。
if
(
!
context
.
wxBindCanvasTexture
)
{
egret
.
startTick
((
timeStarmp
)
=>
{
egret
.
WebGLUtils
.
deleteWebGLTexture
(
bitmapdata
.
webGLTexture
);
bitmapdata
.
webGLTexture
=
null
;
return
false
;
},
this
);
}
}
return
bitmap
;
}
postMessage
(
data
)
{
const
openDataContext
=
wx
.
getOpenDataContext
();
openDataContext
.
postMessage
(
data
);
}
}
window
.
platform
=
new
WxgamePlatform
();
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论