Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
middleLayer_for_NJ_lite
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
template admin
middleLayer_for_NJ_lite
Commits
51e6f98e
Commit
51e6f98e
authored
Dec 08, 2022
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 版本切面,IOS支付功能
parent
2db66ac2
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
8598 additions
and
178 deletions
+8598
-178
middleLayer_for_NJ_lite.fire
...iddleLayer_for_NJ_lite/scene/middleLayer_for_NJ_lite.fire
+8375
-174
air.js
assets/middleLayer_for_NJ_lite/script/air.js
+11
-0
middleLayer.ts
assets/middleLayer_for_NJ_lite/script/middleLayer.ts
+175
-3
util.ts
assets/middleLayer_for_NJ_lite/script/util.ts
+1
-1
mi.png
assets/middleLayer_for_NJ_lite/textures/mi.png
+0
-0
mi.png.meta
assets/middleLayer_for_NJ_lite/textures/mi.png.meta
+36
-0
No files found.
assets/middleLayer_for_NJ_lite/scene/middleLayer_for_NJ_lite.fire
View file @
51e6f98e
This diff is collapsed.
Click to expand it.
assets/middleLayer_for_NJ_lite/script/air.js
View file @
51e6f98e
...
@@ -34,6 +34,7 @@ export function initAir(_this) {
...
@@ -34,6 +34,7 @@ export function initAir(_this) {
takePictureCallBack
:
null
,
takePictureCallBack
:
null
,
configurationPortraitCallback
:
null
,
configurationPortraitCallback
:
null
,
configurationLandscapeCallback
:
null
,
configurationLandscapeCallback
:
null
,
startBuyToAppStoreCallBack
:
null
,
recognitionCameraCallBack
:
null
,
recognitionCameraCallBack
:
null
,
testCallBack
:
null
,
testCallBack
:
null
,
recordCallBack
:
null
,
recordCallBack
:
null
,
...
@@ -290,6 +291,14 @@ export function initAir(_this) {
...
@@ -290,6 +291,14 @@ export function initAir(_this) {
};
};
window
.
courseware
.
callOcMethod
(
"
onConfigurationLandscape
"
,
params
);
window
.
courseware
.
callOcMethod
(
"
onConfigurationLandscape
"
,
params
);
},
},
startBuyToAppStore
(
params
=
{},
callback
)
{
// 苹果支付
_this
.
log
(
`===成功调用startBuyToAppStore===`
);
window
.
air
.
startBuyToAppStoreCallBack
=
(
res
)
=>
{
callback
&&
callback
(
res
);
};
window
.
courseware
.
callOcMethod
(
"
startBuyToAppStore
"
,
params
);
},
callOcMethod
(
method
,
param
)
{
callOcMethod
(
method
,
param
)
{
const
paramStr
=
JSON
.
stringify
(
param
);
const
paramStr
=
JSON
.
stringify
(
param
);
_this
.
log
(
`===成功调用原生方法
${
method
}
===参数==
${
paramStr
}
`
);
_this
.
log
(
`===成功调用原生方法
${
method
}
===参数==
${
paramStr
}
`
);
...
@@ -309,6 +318,8 @@ export function initAir(_this) {
...
@@ -309,6 +318,8 @@ export function initAir(_this) {
}
else
if
(
method
==
'
startRecord
'
)
{
}
else
if
(
method
==
'
startRecord
'
)
{
}
else
if
(
method
==
'
stopRecord
'
)
{
}
else
if
(
method
==
'
stopRecord
'
)
{
window
.
air
.
recordCallBack
(
recordMockData
);
window
.
air
.
recordCallBack
(
recordMockData
);
}
else
if
(
method
==
'
startBuyToAppStore
'
)
{
window
.
air
.
startBuyToAppStoreCallBack
({
productid
:
1
,
puid
:
22
,
receiptData
:
"
HelloWorld
"
});
}
else
{
}
else
{
console
.
error
(
`
${
method
}
方法还没有Mock数据,请联系技术支持人员添加`
);
console
.
error
(
`
${
method
}
方法还没有Mock数据,请联系技术支持人员添加`
);
}
}
...
...
assets/middleLayer_for_NJ_lite/script/middleLayer.ts
View file @
51e6f98e
...
@@ -111,12 +111,92 @@ export default class NewClass extends middleLayerBase {
...
@@ -111,12 +111,92 @@ export default class NewClass extends middleLayerBase {
tipsLayer
.
active
=
false
;
tipsLayer
.
active
=
false
;
});
});
}
}
hideBuyLoading
()
{
cc
.
find
(
`middleLayer/iosActiveLayer/buyloading`
).
active
=
false
;
cc
.
find
(
`middleLayer/iosActiveLayer/buy_status_win`
).
active
=
false
;
}
// 购买
async
buy
(
product
)
{
// 苹果支付
cc
.
find
(
`middleLayer/iosActiveLayer/buyloading`
).
active
=
true
;
const
statusWin
=
cc
.
find
(
`middleLayer/iosActiveLayer/buy_status_win`
);
statusWin
.
active
=
true
;
const
kidInfo
=
await
this
.
getUserBaseInfo
();
const
userId
=
kidInfo
.
parent_id
;
cc
.
find
(
`buy_status_text`
,
statusWin
).
getComponent
(
cc
.
Label
).
string
=
"
支付中,请勿关闭App
"
;
(
<
any
>
window
).
courseware
.
startBuyToAppStore
({
productid
:
product
.
id
,
puid
:
userId
,
ios_product_str
:
product
.
ios_product_str
},
async
(
res
)
=>
{
if
(
typeof
(
res
)
==
'
string
'
)
{
res
=
JSON
.
parse
(
res
);
}
const
orderData
:
any
=
await
this
.
asyncCallNetworkApiPost
(
`/api/oxford/v1/paid/ios/order/save`
,
{
productid
:
res
.
productid
,
puid
:
res
.
puid
,
iospaidcode
:
res
.
receiptData
});
if
(
orderData
.
code
!=
200
)
{
cc
.
find
(
`buy_status_text`
,
statusWin
).
getComponent
(
cc
.
Label
).
string
=
`支付失败[
${
orderData
.
code
}
]`
;
cc
.
find
(
`buy_status_sub_text`
,
statusWin
).
getComponent
(
cc
.
Label
).
string
=
`请联系客服`
;
cc
.
find
(
`buy_status_sub_text`
,
statusWin
).
active
=
true
;
return
;
}
cc
.
find
(
`buy_status_text`
,
statusWin
).
getComponent
(
cc
.
Label
).
string
=
`购买成功!`
;
cc
.
find
(
`buy_status_sub_text`
,
statusWin
).
getComponent
(
cc
.
Label
).
string
=
`快去探索绘玩绘拼自然拼读世界吧!`
;
cc
.
find
(
`buy_status_sub_text`
,
statusWin
).
active
=
true
;
cc
.
find
(
`buy_result_text`
,
statusWin
).
getComponent
(
cc
.
Label
).
string
=
`新获得:
${
product
.
name
}
探索时间
${
product
.
days
}
天`
;
cc
.
find
(
`buy_result_text`
,
statusWin
).
active
=
true
;
cc
.
find
(
`active_btn`
,
statusWin
).
active
=
true
;
})
}
async
showActiveWindow
()
{
async
showActiveWindow
()
{
if
(
this
.
IS_BUNDLE_LOADING
)
{
if
(
this
.
IS_BUNDLE_LOADING
)
{
return
;
return
;
}
}
const
tipsLayer
=
cc
.
find
(
'
middleLayer/activeLayer
'
);
// if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
tipsLayer
.
active
=
true
;
if
(
true
)
{
const
tipsLayer
=
cc
.
find
(
'
middleLayer/iosActiveLayer
'
);
cc
.
find
(
`loading`
,
tipsLayer
).
active
=
true
;
tipsLayer
.
active
=
true
;
const
token
=
cc
.
sys
.
localStorage
.
getItem
(
'
token
'
);
const
res
:
any
=
await
this
.
asyncCallNetworkApiGet
(
'
/api/oxford/v1/product/list
'
,
{
token
});
const
products
=
JSON
.
parse
(
res
).
rows
;
let
index
=
1
;
for
(
let
i
=
0
;
i
<
products
.
length
;
i
++
)
{
const
pd
=
products
[
i
];
if
(
pd
.
type_
==
1
)
{
cc
.
find
(
`active_bg/1_5_product/card/label`
,
tipsLayer
).
getComponent
(
cc
.
Label
).
string
=
pd
.
name
;
cc
.
find
(
`active_bg/1_5_product/card/price`
,
tipsLayer
).
getComponent
(
cc
.
Label
).
string
=
pd
.
price
;
cc
.
find
(
`active_bg/1_5_product/card/buy`
,
tipsLayer
).
attr
({
product
:
pd
});
}
else
{
const
cardNode
=
cc
.
find
(
`active_bg/one_level_product`
,
tipsLayer
);
const
levelNode
=
cc
.
find
(
`level
${
index
}
`
,
cardNode
);
cc
.
find
(
`label`
,
levelNode
).
getComponent
(
cc
.
Label
).
string
=
pd
.
name
;
cc
.
find
(
`price`
,
levelNode
).
getComponent
(
cc
.
Label
).
string
=
pd
.
price
;
cc
.
find
(
`buy`
,
levelNode
).
attr
({
product
:
pd
});
const
endDate
=
pd
.
syll_end_date
;
if
(
endDate
)
{
cc
.
find
(
`buy/text`
,
levelNode
).
getComponent
(
cc
.
Label
).
string
=
"
续费
"
;
cc
.
find
(
`tips`
,
levelNode
).
getComponent
(
cc
.
Label
).
string
=
`有效期至
${
endDate
.
split
(
"
T
"
)[
0
].
trim
()}
`
;
}
else
{
cc
.
find
(
`buy/text`
,
levelNode
).
getComponent
(
cc
.
Label
).
string
=
"
购买
"
;
cc
.
find
(
`tips`
,
levelNode
).
getComponent
(
cc
.
Label
).
string
=
"
未购买
"
;
}
index
++
;
}
}
cc
.
find
(
`loading`
,
tipsLayer
).
active
=
false
;
}
else
{
const
tipsLayer
=
cc
.
find
(
'
middleLayer/activeLayer
'
);
tipsLayer
.
active
=
true
;
}
}
}
version
=
null
;
version
=
null
;
...
@@ -636,10 +716,20 @@ export default class NewClass extends middleLayerBase {
...
@@ -636,10 +716,20 @@ export default class NewClass extends middleLayerBase {
cc
.
sys
.
localStorage
.
setItem
(
'
token
'
,
token
);
cc
.
sys
.
localStorage
.
setItem
(
'
token
'
,
token
);
}
}
// 处理苹果支付的异常回调
(
<
any
>
window
).
air
.
startBuyToAppStoreCallBack
=
async
(
res
)
=>
{
if
(
typeof
(
res
)
==
'
string
'
)
{
res
=
JSON
.
parse
(
res
);
}
await
this
.
asyncCallNetworkApiPost
(
`/v1/paid/ios/order/save`
,
{
productid
:
res
.
productid
,
puid
:
res
.
puid
,
iospaidcode
:
res
.
receiptData
});
}
this
.
showWaitingLetters
();
this
.
showWaitingLetters
();
this
.
onMiddleLayerLoadingFinish
();
this
.
onMiddleLayerLoadingFinish
();
const
token
=
cc
.
sys
.
localStorage
.
getItem
(
'
token
'
);
const
token
=
cc
.
sys
.
localStorage
.
getItem
(
'
token
'
);
const
kidDataStr
=
await
this
.
asyncCallNetworkApiGet
(
'
/api/oxford/v1/kid/info
'
,
{
const
kidDataStr
=
await
this
.
asyncCallNetworkApiGet
(
'
/api/oxford/v1/kid/info
'
,
{
token
:
token
token
:
token
...
@@ -762,6 +852,88 @@ export default class NewClass extends middleLayerBase {
...
@@ -762,6 +852,88 @@ export default class NewClass extends middleLayerBase {
}
}
});
});
// IOS 激活窗口事件绑定
const
iosActiveWin
=
cc
.
find
(
'
middleLayer/iosActiveLayer
'
);
buttonOnClick
(
cc
.
find
(
'
close
'
,
iosActiveWin
),
()
=>
{
iosActiveWin
.
active
=
false
;
});
buttonOnClick
(
cc
.
find
(
'
active_bg/input_book_code/active
'
,
iosActiveWin
),
async
()
=>
{
const
input
=
cc
.
find
(
'
active_bg/input_book_code/active_input
'
,
iosActiveWin
).
getComponent
(
cc
.
EditBox
);
const
activeCode
=
input
.
textLabel
.
string
;
const
kidInfo
=
await
this
.
getUserInfo
();
if
(
!
kidInfo
)
{
return
;
}
const
res
=
await
this
.
asyncCallNetworkApiPost
(
`/api/oxford/v1/user/bind`
,
{
kid_id
:
kidInfo
.
id
,
book_code
:
activeCode
,
token
:
cc
.
sys
.
localStorage
.
getItem
(
'
token
'
)
});
if
(
res
&&
res
.
code
==
200
)
{
this
.
showTips
(
res
.
msg
);
iosActiveWin
.
active
=
false
;
input
.
textLabel
.
string
=
""
;
await
this
.
getUserInfo
();
this
.
reloadBundle
();
}
else
{
this
.
showTips
(
res
.
msg
);
}
});
buttonOnClick
(
cc
.
find
(
'
active_bg/buy1_5
'
,
iosActiveWin
),
()
=>
{
cc
.
find
(
'
active_bg/1_5_product
'
,
iosActiveWin
).
active
=
true
;
cc
.
find
(
'
active_bg/one_level_product
'
,
iosActiveWin
).
active
=
false
;
cc
.
find
(
'
active_bg/input_book_code
'
,
iosActiveWin
).
active
=
false
;
});
buttonOnClick
(
cc
.
find
(
'
active_bg/buy_one
'
,
iosActiveWin
),
()
=>
{
cc
.
find
(
'
active_bg/1_5_product
'
,
iosActiveWin
).
active
=
false
;
cc
.
find
(
'
active_bg/one_level_product
'
,
iosActiveWin
).
active
=
true
;
cc
.
find
(
'
active_bg/input_book_code
'
,
iosActiveWin
).
active
=
false
;
});
buttonOnClick
(
cc
.
find
(
'
active_bg/buy_book_code
'
,
iosActiveWin
),
()
=>
{
cc
.
find
(
'
active_bg/1_5_product
'
,
iosActiveWin
).
active
=
false
;
cc
.
find
(
'
active_bg/one_level_product
'
,
iosActiveWin
).
active
=
false
;
cc
.
find
(
'
active_bg/input_book_code
'
,
iosActiveWin
).
active
=
true
;
});
buttonOnClick
(
cc
.
find
(
'
active_bg/1_5_product/card/buy
'
,
iosActiveWin
),
(
btn
)
=>
{
this
.
buy
(
btn
.
product
);
});
buttonOnClick
(
cc
.
find
(
'
active_bg/one_level_product/level1/buy
'
,
iosActiveWin
),
(
btn
)
=>
{
this
.
buy
(
btn
.
product
);
});
buttonOnClick
(
cc
.
find
(
'
active_bg/one_level_product/level2/buy
'
,
iosActiveWin
),
(
btn
)
=>
{
this
.
buy
(
btn
.
product
);
});
buttonOnClick
(
cc
.
find
(
'
active_bg/one_level_product/level3/buy
'
,
iosActiveWin
),
(
btn
)
=>
{
this
.
buy
(
btn
.
product
);
});
buttonOnClick
(
cc
.
find
(
'
active_bg/one_level_product/level4/buy
'
,
iosActiveWin
),
(
btn
)
=>
{
this
.
buy
(
btn
.
product
);
});
buttonOnClick
(
cc
.
find
(
'
active_bg/one_level_product/level5/buy
'
,
iosActiveWin
),
(
btn
)
=>
{
this
.
buy
(
btn
.
product
);
});
buttonOnClick
(
cc
.
find
(
'
buy_status_win/active_btn
'
,
iosActiveWin
),
(
btn
)
=>
{
cc
.
find
(
`buy_status_win/buy_status_text`
,
iosActiveWin
).
getComponent
(
cc
.
Label
).
string
=
""
;
cc
.
find
(
`buy_status_win/buy_status_sub_text`
,
iosActiveWin
).
getComponent
(
cc
.
Label
).
string
=
""
;
cc
.
find
(
`buy_status_win/buy_status_sub_text`
,
iosActiveWin
).
active
=
false
;
cc
.
find
(
`buy_status_win/buy_result_text`
,
iosActiveWin
).
active
=
false
;
btn
.
active
=
false
;
cc
.
find
(
`buy_status_win`
,
iosActiveWin
).
active
=
false
;
cc
.
find
(
`buyloading`
,
iosActiveWin
).
active
=
false
;
iosActiveWin
.
active
=
false
;
this
.
loadOnlineBundle
(
'
NJ_YouLeChang
'
);
});
};
};
playLocalAudio
(
audioName
)
{
playLocalAudio
(
audioName
)
{
...
...
assets/middleLayer_for_NJ_lite/script/util.ts
View file @
51e6f98e
...
@@ -532,7 +532,7 @@ export function buttonOnClick(button: cc.Node, callback: Function, scale = 1.0)
...
@@ -532,7 +532,7 @@ export function buttonOnClick(button: cc.Node, callback: Function, scale = 1.0)
.
to
(
0.1
,
{
scale
:
scale
*
1.1
})
.
to
(
0.1
,
{
scale
:
scale
*
1.1
})
.
to
(
0.1
,
{
scale
:
scale
})
.
to
(
0.1
,
{
scale
:
scale
})
.
call
(()
=>
{
.
call
(()
=>
{
callback
&&
callback
();
callback
&&
callback
(
button
);
button
[
'
cantClick
'
]
=
false
;
button
[
'
cantClick
'
]
=
false
;
})
})
.
start
();
.
start
();
...
...
assets/middleLayer_for_NJ_lite/textures/mi.png
0 → 100644
View file @
51e6f98e
653 Bytes
assets/middleLayer_for_NJ_lite/textures/mi.png.meta
0 → 100644
View file @
51e6f98e
{
"ver": "2.3.5",
"uuid": "57d6176e-9dea-43a8-b2e0-c7691cf7d677",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 32,
"height": 32,
"platformSettings": {},
"subMetas": {
"mi": {
"ver": "1.0.4",
"uuid": "6cc989ef-5980-4fcb-a791-c5744ae155d5",
"rawTextureUuid": "57d6176e-9dea-43a8-b2e0-c7691cf7d677",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 1,
"offsetY": 0,
"trimX": 6,
"trimY": 2,
"width": 22,
"height": 28,
"rawWidth": 32,
"rawHeight": 32,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
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