Toggle navigation
Toggle navigation
This project
Loading...
Sign in
public_service
/
public-js-doc
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
xuguohong
2021-03-19 17:42:47 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
487fc689c01e660b26829ca922fd6b29defea7d6
487fc689
1 parent
c90d43cf
修改wegame
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
2 deletions
wegame/sdk/commonH5SDK.js
wegame/sdk/wxgame_sdk.js
wegame/sdk/commonH5SDK.js
View file @
487fc68
import
commonH5Proxy
from
"./commonH5Proxy.js"
;
import
commonH5Utils
from
"./commonH5Utils.js"
;
window
.
commonH5SDK
=
{
sdk_isShowLog
:
!
1
,
code
:{
INIT_SUCCESS
:
1
,
INIT_FAIL
:
-
1
,
LOGIN_SUCCESS
:
10
,
LOGIN_FAIL
:
-
10
,
LOGOUT_SUCCESS
:
100
,
LOGOUT_FAIL
:
-
100
,
SWITCH_SUCCESS
:
1
e3
,
SWITCH_FAIL
:
-
1
e3
,
PAY_SUCCESS
:
2
,
PAY_FAIL
:
-
2
,
PAY_CANCEL
:
-
3
,
EXIT_SUCCESS
:
4
,
EXIT_CANCEL
:
-
4
},
type
:{
arriveServerSelectPage
:
1
,
createRole
:
2
,
enterGame
:
3
,
upRoleLevel
:
4
,
arriveEntrance
:
5
,
enterServer
:
6
,
arriveFirstScene
:
7
,
arriveLoadingFinish
:
8
,
arriveLoadingZero
:
9
,
arriveCreateRolePage
:
10
,
newcomerFinish
:
11
,
checkpointStart
:
12
,
checkpointEnd
:
13
,
selectRole
:
14
,
renameRole
:
15
,
newcomerStart
:
16
},
expansion_type
:{
gameSetting
:
100
,
downloadMicroClent
:
101
,
share
:
102
,
focus
:
103
,
save2Desktop
:
104
,
realVerify
:
105
,
back2Game
:
106
,
bindPhone
:
107
,
msgSecCheck
:
108
,
checkBalance
:
109
,
showAd
:
110
,
score
:
111
,
kefu
:
112
,
queryProductsInfo
:
113
,
userCenter
:
114
,
eventTrack
:
115
,
realNameVerify
:
116
,
mulShare
:
117
,
blueVip
:
118
,
blueVipBuy
:
119
,
whatsNewSubscriptionsSetting
:
120
,
subscribeWhatsNew
:
121
,
firstEnterGameScene
:
122
,
msgSubscribe
:
123
},
callback
:{},
h5Proxy
:
""
,
init
:
function
(
n
,
t
){
this
.
callback
=
t
;
var
i
=
this
,
r
=
{
onCheckConfigSuccess
:
function
(){
i
.
h5Proxy
=
new
commonH5Proxy
;
i
.
h5Proxy
.
init
({});
i
.
h5Proxy
.
hasInit
||
t
(
commonH5SDK
.
code
.
INIT_SUCCESS
,
"初始化成功"
)},
onCheckConfigFail
:
function
(){
console
.
log
(
"onCheckConfigFail"
);
i
.
callback
(
i
.
code
.
INIT_FAIL
,
"初始化错误"
)}};
commonH5Utils
.
getInstance
().
configCheck
(
n
,
r
)},
login
:
function
(
n
){
commonH5Utils
.
getInstance
().
submitInfo
(
"event:openSDKLogin"
,
null
);
this
.
h5Proxy
.
loginExt
=
n
;
this
.
h5Proxy
.
login
(
n
)},
pay
:
function
(
n
){
this
.
h5Proxy
.
createOrder
(
n
)},
hasLogout
:
function
(){
return
this
.
h5Proxy
.
hasLogout
},
logout
:
function
(){
this
.
h5Proxy
.
logout
()},
hasSwitchAccount
:
function
(){
return
this
.
h5Proxy
.
hasSwitchAccount
},
switchAccount
:
function
(){
return
this
.
h5Proxy
.
switchAccount
()},
hasShowExitDialog
:
function
(){
return
this
.
h5Proxy
.
hasExitDialog
},
showExitDialog
:
function
(){
this
.
h5Proxy
.
showExitDialog
()},
exitGame
:
function
(){
this
.
h5Proxy
.
exitGame
()},
submitData
:
function
(
n
,
t
){
console
.
log
(
"submitData type:"
+
n
);
switch
(
n
){
case
this
.
type
.
enterGame
:
commonH5Utils
.
getInstance
().
submitInfo
(
"enter"
,
t
)}
this
.
h5Proxy
.
submitData
(
n
,
t
)},
getParamValueByKey
:
function
(
n
){
return
commonH5Utils
.
getInstance
().
sdkInfo
[
n
]},
expansionInterface
:
function
(
n
,
t
,
i
){
this
.
h5Proxy
.
expansionInterface
(
n
,
t
,
i
)},
statistics
:
function
(
n
,
t
){
var
i
=
{
onStatisticsSuccess
:
function
(){
t
.
onStatisticsSuccess
()},
onStatisticsFail
:
function
(){
t
.
onStatisticsFail
()}};
commonH5Utils
.
getInstance
().
statistics
(
n
,
i
)}};
module
{}.
exports
=
window
.
commonH5SDK
\ No newline at end of file
import
commonH5Proxy
from
"./commonH5Proxy.js"
;
import
commonH5Utils
from
"./commonH5Utils.js"
;
window
.
commonH5SDK
=
{
sdk_isShowLog
:
!
1
,
code
:{
INIT_SUCCESS
:
1
,
INIT_FAIL
:
-
1
,
LOGIN_SUCCESS
:
10
,
LOGIN_FAIL
:
-
10
,
LOGOUT_SUCCESS
:
100
,
LOGOUT_FAIL
:
-
100
,
SWITCH_SUCCESS
:
1
e3
,
SWITCH_FAIL
:
-
1
e3
,
PAY_SUCCESS
:
2
,
PAY_FAIL
:
-
2
,
PAY_CANCEL
:
-
3
,
EXIT_SUCCESS
:
4
,
EXIT_CANCEL
:
-
4
},
type
:{
arriveServerSelectPage
:
1
,
createRole
:
2
,
enterGame
:
3
,
upRoleLevel
:
4
,
arriveEntrance
:
5
,
enterServer
:
6
,
arriveFirstScene
:
7
,
arriveLoadingFinish
:
8
,
arriveLoadingZero
:
9
,
arriveCreateRolePage
:
10
,
newcomerFinish
:
11
,
checkpointStart
:
12
,
checkpointEnd
:
13
,
selectRole
:
14
,
renameRole
:
15
,
newcomerStart
:
16
},
expansion_type
:{
gameSetting
:
100
,
downloadMicroClent
:
101
,
share
:
102
,
focus
:
103
,
save2Desktop
:
104
,
realVerify
:
105
,
back2Game
:
106
,
bindPhone
:
107
,
msgSecCheck
:
108
,
checkBalance
:
109
,
showAd
:
110
,
score
:
111
,
kefu
:
112
,
queryProductsInfo
:
113
,
userCenter
:
114
,
eventTrack
:
115
,
realNameVerify
:
116
,
mulShare
:
117
,
blueVip
:
118
,
blueVipBuy
:
119
,
whatsNewSubscriptionsSetting
:
120
,
subscribeWhatsNew
:
121
,
firstEnterGameScene
:
122
,
msgSubscribe
:
123
},
callback
:{},
h5Proxy
:
""
,
init
:
function
(
n
,
t
){
this
.
callback
=
t
;
var
i
=
this
,
r
=
{
onCheckConfigSuccess
:
function
(){
i
.
h5Proxy
=
new
commonH5Proxy
;
i
.
h5Proxy
.
init
({});
i
.
h5Proxy
.
hasInit
||
t
(
commonH5SDK
.
code
.
INIT_SUCCESS
,
"初始化成功"
)},
onCheckConfigFail
:
function
(){
console
.
log
(
"onCheckConfigFail"
);
i
.
callback
(
i
.
code
.
INIT_FAIL
,
"初始化错误"
)}};
commonH5Utils
.
getInstance
().
configCheck
(
n
,
r
)},
login
:
function
(
n
){
commonH5Utils
.
getInstance
().
submitInfo
(
"event:openSDKLogin"
,
null
);
this
.
h5Proxy
.
loginExt
=
n
;
this
.
h5Proxy
.
login
(
n
)},
pay
:
function
(
n
){
this
.
h5Proxy
.
createOrder
(
n
)},
hasLogout
:
function
(){
return
this
.
h5Proxy
.
hasLogout
},
logout
:
function
(){
this
.
h5Proxy
.
logout
()},
hasSwitchAccount
:
function
(){
return
this
.
h5Proxy
.
hasSwitchAccount
},
switchAccount
:
function
(){
return
this
.
h5Proxy
.
switchAccount
()},
hasShowExitDialog
:
function
(){
return
this
.
h5Proxy
.
hasExitDialog
},
showExitDialog
:
function
(){
this
.
h5Proxy
.
showExitDialog
()},
exitGame
:
function
(){
this
.
h5Proxy
.
exitGame
()},
submitData
:
function
(
n
,
t
){
console
.
log
(
"submitData type:"
+
n
);
switch
(
n
){
case
this
.
type
.
enterGame
:
commonH5Utils
.
getInstance
().
submitInfo
(
"enter"
,
t
)}
this
.
h5Proxy
.
submitData
(
n
,
t
)},
getParamValueByKey
:
function
(
n
){
return
commonH5Utils
.
getInstance
().
sdkInfo
[
n
]},
expansionInterface
:
function
(
n
,
t
,
i
){
this
.
h5Proxy
.
expansionInterface
(
n
,
t
,
i
)},
statistics
:
function
(
n
,
t
){
var
i
=
{
onStatisticsSuccess
:
function
(){
t
.
onStatisticsSuccess
()},
onStatisticsFail
:
function
(){
t
.
onStatisticsFail
()}};
commonH5Utils
.
getInstance
().
statistics
(
n
,
i
)}};
module
.
exports
=
window
.
commonH5SDK
\ No newline at end of file
...
...
wegame/sdk/wxgame_sdk.js
View file @
487fc68
function
wxNetworkRequest
(
n
,
t
,
i
,
r
){
wx
.
request
({
url
:
"https://sdk.xizhai2021.com"
+
n
,
data
:
t
,
header
:{
"content-type"
:
r
},
method
:
"POST"
,
success
(
n
){
console
.
log
(
n
.
data
);
i
&&
i
(
1
,
n
.
data
)},
fail
(
n
){
console
.
log
(
n
);
i
&&
i
(
0
,
"network request error"
)}})}
function
loginDataHandler
(
n
,
t
){
var
u
=
n
;
if
(
u
.
code
==
0
){
var
i
=
u
.
msg
,
f
=
i
.
open_id
,
e
=
i
.
login_key
,
s
=
i
.
token
,
h
=
i
.
pay_channel_id
,
r
=
i
.
wechat
,
o
=
r
.
openid
,
c
=
r
.
unionid
,
l
=
r
.
session_key
,
a
=
i
.
share_str
,
v
=
i
.
share_pic
,
y
=
i
.
timestamp
;
try
{
wx
.
setStorageSync
(
"common_sdkOpenId"
,
f
+
""
);
wx
.
setStorageSync
(
"common_wxOpenId"
,
o
);
wx
.
setStorageSync
(
"common_wxUnionid"
,
c
);
wx
.
setStorageSync
(
"common_sdkLoginKey"
,
e
);
wx
.
setStorageSync
(
"common_sdkPayChannelId"
,
h
);
wx
.
setStorageSync
(
"common_wxSessionKey"
,
l
);
wx
.
setStorageSync
(
"common_wxShareTitle"
,
a
);
wx
.
setStorageSync
(
"common_wxShareImage"
,
v
)}
catch
(
p
){}
t
(
1
,{
openId
:
f
,
loginKey
:
e
,
token
:
s
,
wxOpenId
:
o
,
timestamp
:
y
})}
else
console
.
log
(
"loginResult:"
,
n
),
t
(
0
,
"server callback error"
)}
function
commonSdkLogin
(
n
,
t
){
console
.
log
(
"commonSdkLogin1111"
);
wx
.
setStorageSync
(
"common_sdkAppId"
,
n
);
console
.
log
(
"commonSdkLogin"
);
wx
.
login
({
success
(
i
){
if
(
i
.
code
){
var
r
=
"code="
+
i
.
code
+
"&app_id="
+
n
;
wxNetworkRequest
(
"/sdk/login?format=json&type=7&mk="
,
r
,
function
(
n
,
i
){
n
==
1
?
loginDataHandler
(
i
,
t
):
t
(
0
,
"login fail"
)},
"application/x-www-form-urlencoded"
)}
else
t
&&
t
(
0
,
i
.
errMsg
)}})}
function
wxMenuShareInit
(
n
){
wxMenuShareInit2
(
wx
.
getStorageSync
(
"common_wxShareTitle"
),
wx
.
getStorageSync
(
"common_wxShareImage"
),
n
)}
function
wxMenuShareInit2
(
n
,
t
,
i
){
wx
.
showShareMenu
({
withShareTicket
:
!
0
});
wx
.
onShareAppMessage
(
function
(){
return
{
title
:
n
,
imageUrl
:
t
,
query
:
i
}})}
function
wxSdkShareContent
(
n
){
wxSdkShareContent2
(
wx
.
getStorageSync
(
"common_wxShareTitle"
),
wx
.
getStorageSync
(
"common_wxShareImage"
),
n
)}
function
wxSdkShareContent2
(
n
,
t
,
i
){
wx
.
shareAppMessage
({
title
:
n
,
imageUrl
:
t
,
query
:
i
})}
function
wxMenuShareTimelineInit
(
n
){
wxMenuShareTimelineInit2
(
wx
.
getStorageSync
(
"common_wxShareTitle"
),
wx
.
getStorageSync
(
"common_wxShareImage"
),
n
)}
function
wxMenuShareTimelineInit2
(
n
,
t
,
i
){
wx
.
showShareMenu
({
withShareTicket
:
!
0
});
wx
.
onShareTimeline
(
function
(){
return
{
title
:
n
,
imageUrl
:
t
,
query
:
i
}})}
function
wxUserCloudStorage
(
n
,
t
){
var
i
=
{
wxgame
:{
score
:
parseInt
(
t
),
update_time
:
Date
.
parse
(
new
Date
)
/
1
e3
}},
r
=
{
key
:
n
,
value
:
JSON
.
stringify
(
i
)};
wx
.
setUserCloudStorage
({
KVDataList
:[
r
]})}
function
sdkConfirmOrderRequest
(){}
function
sdkCreateOrderRequest
(
n
,
t
){
var
i
=
"role_name="
+
n
.
roleName
;
i
+=
"&encode=0"
;
i
+=
"&login_key="
+
wx
.
getStorageSync
(
"common_sdkLoginKey"
);
i
+=
"&pay_channel_id="
+
wx
.
getStorageSync
(
"common_sdkPayChannelId"
);
i
+=
"&productid="
+
n
.
productId
;
i
+=
"&money="
+
n
.
amount
;
i
+=
"&open_id="
+
wx
.
getStorageSync
(
"common_sdkOpenId"
);
i
+=
"&role_id="
+
n
.
roleId
;
i
+=
"&callback="
+
n
.
orderId
;
i
+=
"&game_amount="
+
n
.
exchage
*
n
.
amount
;
i
+=
"&serverid="
+
n
.
serverId
;
i
+=
"&app_id="
+
wx
.
getStorageSync
(
"common_sdkAppId"
);
i
+=
"&wx_open_id="
+
wx
.
getStorageSync
(
"common_wxOpenId"
);
wxNetworkRequest
(
"/sdk/pay?format=json"
,
i
,
t
,
"application/x-www-form-urlencoded"
)}
function
wxSdkPay
(
n
){
sdkCreateOrderRequest
(
n
,
function
(
n
,
t
){
console
.
log
(
"create order result:"
+
t
)})}
module
{}.
exports
=
{
login
:
commonSdkLogin
,
menuShareInit
:
wxMenuShareInit
,
menuShareInit2
:
wxMenuShareInit2
,
sdkShareContent
:
wxSdkShareContent
,
menuShareTimeline
:
wxMenuShareTimelineInit
,
menuShareTimeline2
:
wxMenuShareTimelineInit2
,
sdkUserCloudStorage
:
wxUserCloudStorage
,
sdkPay
:
wxSdkPay
}
\ No newline at end of file
function
wxNetworkRequest
(
n
,
t
,
i
,
r
){
wx
.
request
({
url
:
"https://sdk.xizhai2021.com"
+
n
,
data
:
t
,
header
:{
"content-type"
:
r
},
method
:
"POST"
,
success
(
n
){
console
.
log
(
n
.
data
);
i
&&
i
(
1
,
n
.
data
)},
fail
(
n
){
console
.
log
(
n
);
i
&&
i
(
0
,
"network request error"
)}})}
function
loginDataHandler
(
n
,
t
){
var
u
=
n
;
if
(
u
.
code
==
0
){
var
i
=
u
.
msg
,
f
=
i
.
open_id
,
e
=
i
.
login_key
,
s
=
i
.
token
,
h
=
i
.
pay_channel_id
,
r
=
i
.
wechat
,
o
=
r
.
openid
,
c
=
r
.
unionid
,
l
=
r
.
session_key
,
a
=
i
.
share_str
,
v
=
i
.
share_pic
,
y
=
i
.
timestamp
;
try
{
wx
.
setStorageSync
(
"common_sdkOpenId"
,
f
+
""
);
wx
.
setStorageSync
(
"common_wxOpenId"
,
o
);
wx
.
setStorageSync
(
"common_wxUnionid"
,
c
);
wx
.
setStorageSync
(
"common_sdkLoginKey"
,
e
);
wx
.
setStorageSync
(
"common_sdkPayChannelId"
,
h
);
wx
.
setStorageSync
(
"common_wxSessionKey"
,
l
);
wx
.
setStorageSync
(
"common_wxShareTitle"
,
a
);
wx
.
setStorageSync
(
"common_wxShareImage"
,
v
)}
catch
(
p
){}
t
(
1
,{
openId
:
f
,
loginKey
:
e
,
token
:
s
,
wxOpenId
:
o
,
timestamp
:
y
})}
else
console
.
log
(
"loginResult:"
,
n
),
t
(
0
,
"server callback error"
)}
function
commonSdkLogin
(
n
,
t
){
console
.
log
(
"commonSdkLogin1111"
);
wx
.
setStorageSync
(
"common_sdkAppId"
,
n
);
console
.
log
(
"commonSdkLogin"
);
wx
.
login
({
success
(
i
){
if
(
i
.
code
){
var
r
=
"code="
+
i
.
code
+
"&app_id="
+
n
;
wxNetworkRequest
(
"/sdk/login?format=json&type=7&mk="
,
r
,
function
(
n
,
i
){
n
==
1
?
loginDataHandler
(
i
,
t
):
t
(
0
,
"login fail"
)},
"application/x-www-form-urlencoded"
)}
else
t
&&
t
(
0
,
i
.
errMsg
)}})}
function
wxMenuShareInit
(
n
){
wxMenuShareInit2
(
wx
.
getStorageSync
(
"common_wxShareTitle"
),
wx
.
getStorageSync
(
"common_wxShareImage"
),
n
)}
function
wxMenuShareInit2
(
n
,
t
,
i
){
wx
.
showShareMenu
({
withShareTicket
:
!
0
});
wx
.
onShareAppMessage
(
function
(){
return
{
title
:
n
,
imageUrl
:
t
,
query
:
i
}})}
function
wxSdkShareContent
(
n
){
wxSdkShareContent2
(
wx
.
getStorageSync
(
"common_wxShareTitle"
),
wx
.
getStorageSync
(
"common_wxShareImage"
),
n
)}
function
wxSdkShareContent2
(
n
,
t
,
i
){
wx
.
shareAppMessage
({
title
:
n
,
imageUrl
:
t
,
query
:
i
})}
function
wxMenuShareTimelineInit
(
n
){
wxMenuShareTimelineInit2
(
wx
.
getStorageSync
(
"common_wxShareTitle"
),
wx
.
getStorageSync
(
"common_wxShareImage"
),
n
)}
function
wxMenuShareTimelineInit2
(
n
,
t
,
i
){
wx
.
showShareMenu
({
withShareTicket
:
!
0
});
wx
.
onShareTimeline
(
function
(){
return
{
title
:
n
,
imageUrl
:
t
,
query
:
i
}})}
function
wxUserCloudStorage
(
n
,
t
){
var
i
=
{
wxgame
:{
score
:
parseInt
(
t
),
update_time
:
Date
.
parse
(
new
Date
)
/
1
e3
}},
r
=
{
key
:
n
,
value
:
JSON
.
stringify
(
i
)};
wx
.
setUserCloudStorage
({
KVDataList
:[
r
]})}
function
sdkConfirmOrderRequest
(){}
function
sdkCreateOrderRequest
(
n
,
t
){
var
i
=
"role_name="
+
n
.
roleName
;
i
+=
"&encode=0"
;
i
+=
"&login_key="
+
wx
.
getStorageSync
(
"common_sdkLoginKey"
);
i
+=
"&pay_channel_id="
+
wx
.
getStorageSync
(
"common_sdkPayChannelId"
);
i
+=
"&productid="
+
n
.
productId
;
i
+=
"&money="
+
n
.
amount
;
i
+=
"&open_id="
+
wx
.
getStorageSync
(
"common_sdkOpenId"
);
i
+=
"&role_id="
+
n
.
roleId
;
i
+=
"&callback="
+
n
.
orderId
;
i
+=
"&game_amount="
+
n
.
exchage
*
n
.
amount
;
i
+=
"&serverid="
+
n
.
serverId
;
i
+=
"&app_id="
+
wx
.
getStorageSync
(
"common_sdkAppId"
);
i
+=
"&wx_open_id="
+
wx
.
getStorageSync
(
"common_wxOpenId"
);
wxNetworkRequest
(
"/sdk/pay?format=json"
,
i
,
t
,
"application/x-www-form-urlencoded"
)}
function
wxSdkPay
(
n
){
sdkCreateOrderRequest
(
n
,
function
(
n
,
t
){
console
.
log
(
"create order result:"
+
t
)})}
module
.
exports
=
{
login
:
commonSdkLogin
,
menuShareInit
:
wxMenuShareInit
,
menuShareInit2
:
wxMenuShareInit2
,
sdkShareContent
:
wxSdkShareContent
,
menuShareTimeline
:
wxMenuShareTimelineInit
,
menuShareTimeline2
:
wxMenuShareTimelineInit2
,
sdkUserCloudStorage
:
wxUserCloudStorage
,
sdkPay
:
wxSdkPay
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment