Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
babycare_xiaoxiao
Project
Project
Details
Activity
Releases
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
翁阳
babycare_xiaoxiao
Commits
e4815058
Commit
e4815058
authored
Jul 23, 2020
by
wjf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
k
parent
2c8b7486
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
141 additions
and
67 deletions
+141
-67
output.js
output.js
+20
-33
output.js.map
output.js.map
+1
-1
handleLot.js
scripts/handleLot.js
+3
-0
handleLotS.js
scripts/handleLotS.js
+76
-0
Main.ts
src/Main.ts
+15
-7
TaoBaoNet.ts
src/TaoBaoNet.ts
+15
-15
LoadingScene.ts
src/scene/LoadingScene.ts
+11
-11
No files found.
output.js
View file @
e4815058
...
...
@@ -1601,10 +1601,7 @@ var Lottie = (function (_super) {
else if (xs.indexOf("cycle") >= 0 && data[data.length - 1].t < this.rawData.op) {
var rr = xs.replace(/[^0-9]/ig, "");
var num = Math.round((this.rawData.op - data[data.length - 1 - rr].t) / (data[data.length - 1].t - data[data.length - 1 - rr].t));
objArr = objArr.slice(-(xs.replace(/[^0-9]/ig, "")));
if (dis["layerData"].nm == "bonus_light_11.png") {
console.log(dis.alpha);
}
objArr = objArr.slice(-rr);
while (--num) {
for (var o = 0; o < objArr.length; o++) {
tween.to(objArr[o].obj, objArr[o].deltaTime);
...
...
@@ -1712,7 +1709,8 @@ var Main = (function () {
FYGE.Tween.flush();
stage.flush();
}
self.requestID = FYGE.getRequestAnimationFrame()(loop);
my ? self.requestID = canvas.requestAnimationFrame(loop) :
self.requestID = window.requestAnimationFrame(loop);
}
}
Main.prototype.onAddToStage = function () {
...
...
@@ -1737,10 +1735,12 @@ var Main = (function () {
};
Main.prototype.run = function () {
this._pause = false;
exports.GDispatcher.dispatchEvent(G_EVENT_1.G_EVENT.ON_SHOW);
FYGE.Tween._lastTime = null;
exports.GDispatcher.dispatchEvent({ type: G_EVENT_1.G_EVENT.ON_SHOW });
};
Main.prototype.pause = function () {
exports.GDispatcher.dispatchEvent(G_EVENT_1.G_EVENT.ON_HIDE);
this._pause = true;
exports.GDispatcher.dispatchEvent({ type: G_EVENT_1.G_EVENT.ON_HIDE });
};
Main.prototype.addGlobalEvent = function (name, fun, thisObj, once) {
if (once === void 0) { once = false; }
...
...
@@ -1759,7 +1759,8 @@ var Main = (function () {
};
Main.prototype.destroy = function () {
FYGE.Tween.removeAllTweens();
FYGE.getCancelAnimationFrame()(this.requestID);
my ? canvas.cancelAnimationFrame(this.requestID) :
window.cancelAnimationFrame(this.requestID);
layers_1.destroyLayers();
ctrls_1.destroyAllCtrls();
this.stage.destroy();
...
...
@@ -11307,7 +11308,6 @@ var fc;
function sendTbNet(netName, parameter, callback, hideMsg) {
if (hideMsg === void 0) { hideMsg = false; }
return new Promise(function (resolve, reject) {
var waitObj;
if (!my) {
var url = "../../mock/miniTb/" + netName + ".json";
fetchAsync(url)
...
...
@@ -11327,7 +11327,6 @@ function sendTbNet(netName, parameter, callback, hideMsg) {
return;
}
var fun = function (e) {
ctrls_1.clearWait(waitObj);
Main_1.GDispatcher.removeEventListener(netName, fun);
var d = e.data;
dataRecord[netName] = d;
...
...
@@ -11342,16 +11341,6 @@ function sendTbNet(netName, parameter, callback, hideMsg) {
+ "%cDATA : %o \n", "" + (d.success ? 'color:green' : 'color:red'), d.success, parameter, "" + (d.success ? 'color:green' : 'color:red'), d);
};
Main_1.GDispatcher.addEventListener(netName, fun);
waitObj = ctrls_1.wait(function () {
if (netName != TbNetName.favorShop &&
netName != TbNetName.getUserAddress &&
netName != TbNetName.authorize &&
netName != TbNetName.getAdoptName &&
netName != TbNetName.trackingReport &&
netName != TbNetName.reportAnalytics) {
fun({ type: netName, data: { success: false } });
}
}, 10000);
Main_1.GDispatcher.dispatchEvent({ type: "onMessage" }, { netName: netName, parameter: parameter });
});
}
...
...
@@ -18201,7 +18190,6 @@ var Scene_1 = __webpack_require__(/*! ../../module/views/Scene */ "./module/view
var Tools_1 = __webpack_require__(/*! ../Tools */ "./src/Tools.ts");
var ProgressBarS_1 = __webpack_require__(/*! ../common/ProgressBarS */ "./src/common/ProgressBarS.ts");
var RES_1 = __webpack_require__(/*! ../../module/RES */ "./module/RES.ts");
var Main_1 = __webpack_require__(/*! ../Main */ "./src/Main.ts");
var TaoBaoNet_1 = __webpack_require__(/*! ../TaoBaoNet */ "./src/TaoBaoNet.ts");
var ctrls_1 = __webpack_require__(/*! ../../module/ctrls */ "./module/ctrls/index.ts");
var MapScene_1 = __webpack_require__(/*! ./map/MapScene */ "./src/scene/map/MapScene.ts");
...
...
@@ -18279,20 +18267,20 @@ var LoadingScene = (function (_super) {
switch (_a.label) {
case 0:
_super.prototype.start.call(this);
Main_1.GDispatcher
.addEventListener(FYGE.Event.PROGRESS, this.progressEvent, this);
Main_1.GDispatcher
.dispatchEvent(FYGE.Event.PROGRESS, 0.2);
this
.addEventListener(FYGE.Event.PROGRESS, this.progressEvent, this);
this
.dispatchEvent(FYGE.Event.PROGRESS, 0.2);
return [4, TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.getAppData)];
case 1:
data = (_a.sent()).data;
Tools_1.Tools.globalData = data;
Main_1.GDispatcher
.dispatchEvent(FYGE.Event.PROGRESS, 0.3);
this
.dispatchEvent(FYGE.Event.PROGRESS, 0.3);
Tools_1.Tools.checkPermission();
return [4, Tools_1.Tools.getIndex()];
case 2:
getIndexSuccesss = _a.sent();
if (!getIndexSuccesss)
return [2];
Main_1.GDispatcher
.dispatchEvent(FYGE.Event.PROGRESS, 0.3);
this
.dispatchEvent(FYGE.Event.PROGRESS, 0.3);
return [4, TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.getActivityBaseInfoById)];
case 3:
baseInfo = _a.sent();
...
...
@@ -18301,7 +18289,7 @@ var LoadingScene = (function (_super) {
for (k in Tools_1.Tools.baseInfo.levelPrize) {
Tools_1.Tools.baseInfo.prizeLevels.push(+k.split('_')[1]);
}
Main_1.GDispatcher
.dispatchEvent(FYGE.Event.PROGRESS, 0.5);
this
.dispatchEvent(FYGE.Event.PROGRESS, 0.5);
return [4, Promise.all([
'map',
'mapCrabEffect',
...
...
@@ -18313,7 +18301,7 @@ var LoadingScene = (function (_super) {
}))];
case 4:
_a.sent();
Main_1.GDispatcher
.dispatchEvent(FYGE.Event.PROGRESS, 1);
this
.dispatchEvent(FYGE.Event.PROGRESS, 1);
return [2];
}
});
...
...
@@ -18321,11 +18309,12 @@ var LoadingScene = (function (_super) {
};
LoadingScene.prototype.progressEvent = function (e) {
var _this = this;
var pro = e.data;
FYGE.Tween.get(this.progressBar, null, null, true)
.to({ value:
e.data
}, 2000)
.to({ value:
pro
}, 2000)
.call(function () {
if (
e.data
>= 1) {
Main_1.GDispatcher
.removeEventListener(FYGE.Event.PROGRESS, _this.progressEvent, _this);
if (
pro
>= 1) {
_this
.removeEventListener(FYGE.Event.PROGRESS, _this.progressEvent, _this);
ctrls_1.changeScene(MapScene_1.MapScene, { from: "loading" });
}
});
...
...
@@ -22730,11 +22719,9 @@ var Tool = (function () {
Tool.indexToRcMap10 = [];
Tool.indexPositions10 = [];
Tool.ExplosiveMatchArr = [
[0, -2],
[-1, -1], [0, -1], [1, -1],
[-
2, 0], [-1, 0], [1, 0], [2
, 0],
[-
1, 0], [1
, 0],
[-1, 1], [0, 1], [1, 1],
[0, 2],
];
return Tool;
}());
output.js.map
View file @
e4815058
This source diff could not be displayed because it is too large. You can
view the blob
instead.
scripts/handleLot.js
View file @
e4815058
var
fs
=
require
(
"fs"
);
var
iconv
=
require
(
'iconv-lite'
);
//暂时用作测试用
return
var
data
=
iconv
.
decode
(
fs
.
readFileSync
(
"./lotties/bb.json"
),
"utf-8"
);
//GBK
//反序列化
data
=
JSON
.
parse
(
data
);
...
...
scripts/handleLotS.js
0 → 100644
View file @
e4815058
var
fs
=
require
(
"fs"
);
var
iconv
=
require
(
'iconv-lite'
);
var
path
=
require
(
'path'
);
//用于处理带base64图片的lottie文件,取出图片,同名lottie文件夹,写入代码"./src/lotties/"中;
var
pathName
=
"./lottiesT"
//读文件夹
var
files
=
fs
.
readdirSync
(
pathName
);
//对每个json文件作处理
files
.
forEach
(
function
(
lottiesFileName
)
{
//后缀不是json的,不处理
if
(
path
.
extname
(
lottiesFileName
).
indexOf
(
".json"
)
<
0
)
return
;
//读数据
var
data
=
iconv
.
decode
(
fs
.
readFileSync
(
pathName
+
"/"
+
lottiesFileName
),
"utf-8"
);
//GBK
//反序列化
data
=
JSON
.
parse
(
data
);
//存图片
var
assets
=
data
.
assets
;
if
(
!
assets
||
!
assets
.
length
)
return
;
//删除属性
delete
data
.
assets
;
var
imgOutPath
=
pathName
+
"/"
+
data
.
nm
//建文件夹data.nm
if
(
!
fs
.
existsSync
(
imgOutPath
))
fs
.
mkdirSync
(
imgOutPath
);
assets
.
forEach
((
e
)
=>
{
//没有base64数据
if
(
!
e
.
p
)
return
let
id
=
e
.
id
;
let
uuid
=
guid
();
//存图片
var
base64
=
e
.
p
.
replace
(
/^data:image
\/\w
+;base64,/
,
""
);
//去掉图片base64码前面部分data:image/png;base64
var
dataBuffer
=
new
Buffer
(
base64
,
'base64'
);
//把base64码转成buffer对象,
fs
.
writeFile
(
imgOutPath
+
"/"
+
uuid
+
".png"
,
dataBuffer
);
//修改用到id的所有refId
data
.
layers
.
forEach
((
l
)
=>
{
l
.
refId
===
id
&&
(
l
.
refId
=
uuid
)
})
})
//开始删东西
delete
data
.
ddd
;
//遍历删除图层东西
for
(
var
i
=
0
;
i
<
data
.
layers
.
length
;
i
++
)
{
var
l
=
data
.
layers
[
i
];
//是否3d,后缀,sr,ap,开始时间,混合模式,特效
[
"ddd"
,
"cl"
,
"sr"
,
"ao"
,
"st"
,
"bm"
,
"ef"
].
forEach
((
e
)
=>
{
delete
l
[
e
];
});
//ks删除
[
"o"
,
"r"
,
"p"
,
"a"
,
"s"
].
forEach
((
e
)
=>
{
var
d
=
l
.
ks
[
e
];
//ix不知道干嘛用,删了
delete
d
.
ix
;
//删除k里数据
if
(
d
.
k
.
length
&&
typeof
d
.
k
[
0
]
==
"object"
)
{
d
.
k
.
forEach
((
ee
)
=>
{
[
"i"
,
"o"
,
"ti"
,
"to"
].
forEach
((
eee
)
=>
{
delete
ee
[
eee
];
})
})
}
})
}
//导出代码到src的lotties文件夹,名字就是lottie动画名字,资源名字临时处理了,首页加载动画用图层的nm,bonustime用refid
var
endPath
=
'./src/lotties'
;
if
(
!
fs
.
existsSync
(
endPath
))
fs
.
mkdirSync
(
endPath
);
//导出对象直接用lottie动画名字
var
endFile
=
`export const
${
data
.
nm
}
=
${
JSON
.
stringify
(
data
,
""
,
"
\
t"
)}
`
//文件名字用lottie动画名字
fs
.
writeFileSync
(
endPath
+
"/"
+
data
.
nm
+
".ts"
,
endFile
);
})
function
guid
()
{
return
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
.
replace
(
/
[
xy
]
/g
,
function
(
c
)
{
var
r
=
Math
.
random
()
*
16
|
0
,
v
=
c
==
'x'
?
r
:
(
r
&
0x3
|
0x8
);
return
v
.
toString
(
16
);
});
}
src/Main.ts
View file @
e4815058
...
...
@@ -25,6 +25,7 @@ export class Main {
stage
:
FYGE
.
Stage
;
private
requestID
;
private
_pause
:
boolean
;
private
canvas
:
HTMLCanvasElement
constructor
(
canvas
:
HTMLCanvasElement
)
{
var
sysInfo
;
//@ts-ignore 存在my就初始化
...
...
@@ -44,6 +45,7 @@ export class Main {
FYGE
.
RENDERER_TYPE
.
CANVAS
);
this
.
stage
=
stage
;
this
.
canvas
=
canvas
;
//赋值下,为了下面的destroy的cancelAnimationFrame
//开始循环
// FYGE.Stage.flushAll();
//stage初始化
...
...
@@ -62,7 +64,10 @@ export class Main {
// stats.end();
}
//@ts-ignore
self
.
requestID
=
FYGE
.
getRequestAnimationFrame
()(
loop
);
// self.requestID = FYGE.getRequestAnimationFrame()(loop);
//为了兼容多page的canvas
my
?
self
.
requestID
=
canvas
.
requestAnimationFrame
(
loop
)
:
self
.
requestID
=
window
.
requestAnimationFrame
(
loop
);
}
}
...
...
@@ -107,16 +112,16 @@ export class Main {
//在小程序显示时调用onShow
run
()
{
this
.
_pause
=
false
this
.
_pause
=
false
;
//@ts-ignore Tween计时清零
// FYGE.Tween._lastTime = null //下面的_pause 不执行,先去掉,试试有没有问题
FYGE
.
Tween
.
_lastTime
=
null
;
GDispatcher
.
dispatchEvent
(
G_EVENT
.
ON_SHOW
);
GDispatcher
.
dispatchEvent
(
{
type
:
G_EVENT
.
ON_SHOW
}
);
}
//在小程序隐藏时调用onHide
pause
()
{
// this._pause = true;//先去掉吧
GDispatcher
.
dispatchEvent
(
G_EVENT
.
ON_HIDE
);
this
.
_pause
=
true
;
GDispatcher
.
dispatchEvent
(
{
type
:
G_EVENT
.
ON_HIDE
}
);
}
/**
...
...
@@ -158,7 +163,10 @@ export class Main {
FYGE
.
Tween
.
removeAllTweens
()
// removeAllTimeoutId();//这个再看,尽量用tween的修改
//停掉计时器
FYGE
.
getCancelAnimationFrame
()(
this
.
requestID
);
// FYGE.getCancelAnimationFrame()(this.requestID);
//@ts-ignore 为了兼容多page的canvas
my
?
this
.
canvas
.
cancelAnimationFrame
(
this
.
requestID
)
:
window
.
cancelAnimationFrame
(
this
.
requestID
);
//层级销毁
destroyLayers
()
//销毁控制器
...
...
src/TaoBaoNet.ts
View file @
e4815058
...
...
@@ -177,7 +177,7 @@ export function sendTbNet(
):
Promise
<
dataOut
>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
//网络超时
let
waitObj
;
//
let waitObj;
//@ts-ignore 本地开发,直接取数据
if
(
!
my
)
{
var
url
=
"../../mock/miniTb/"
+
netName
+
".json"
;
...
...
@@ -212,7 +212,7 @@ export function sendTbNet(
let
fun
=
function
(
e
:
{
type
:
string
,
data
:
dataOut
})
{
//清除超时记录
clearWait
(
waitObj
)
//
clearWait(waitObj)
//移除事件
GDispatcher
.
removeEventListener
(
netName
,
fun
);
...
...
@@ -240,19 +240,19 @@ export function sendTbNet(
//添加事件接收接口返回信息
GDispatcher
.
addEventListener
(
netName
,
fun
);
//网络超时
waitObj
=
wait
(()
=>
{
//是用户操作,不设置超时
if
(
netName
!=
TbNetName
.
favorShop
&&
//关注店铺用户操作
netName
!=
TbNetName
.
getUserAddress
&&
// 获取地址
netName
!=
TbNetName
.
authorize
&&
// 授权
netName
!=
TbNetName
.
getAdoptName
&&
//领养名字获取
netName
!=
TbNetName
.
trackingReport
&&
//埋点接口也不考虑超时
netName
!=
TbNetName
.
reportAnalytics
//淘宝自定义埋点也不考虑超时
)
{
fun
({
type
:
netName
,
data
:
{
success
:
false
}
})
}
},
10000
)
//网络超时
,已经可以返回云函数调用失败,有机会把这删了,不需要了
//
waitObj = wait(() => {
//
//是用户操作,不设置超时
//
if (netName != TbNetName.favorShop &&//关注店铺用户操作
//
netName != TbNetName.getUserAddress && // 获取地址
//
netName != TbNetName.authorize && // 授权
//
netName != TbNetName.getAdoptName && //领养名字获取
//
netName != TbNetName.trackingReport && //埋点接口也不考虑超时
//
netName != TbNetName.reportAnalytics //淘宝自定义埋点也不考虑超时
//
) {
//
fun({ type: netName, data: { success: false } })
//
}
//
}, 10000)
//用事件方式吧,派发事件发接口,,,,注意很多独有的事件名别重了,onHide,onShow,onMessage等 放到最后,因为有同步的情况
GDispatcher
.
dispatchEvent
({
type
:
"onMessage"
},
{
netName
,
parameter
})
...
...
src/scene/LoadingScene.ts
View file @
e4815058
...
...
@@ -2,7 +2,6 @@ import { Scene } from "../../module/views/Scene";
import
{
Tools
}
from
"../Tools"
;
import
{
ProgressBarS
}
from
"../common/ProgressBarS"
;
import
{
RES
}
from
"../../module/RES"
;
import
{
GDispatcher
}
from
"../Main"
;
import
{
sendTbNet
,
TbNetName
}
from
"../TaoBaoNet"
;
import
{
changeScene
}
from
"../../module/ctrls"
;
import
{
MapScene
}
from
"./map/MapScene"
;
...
...
@@ -93,14 +92,14 @@ export class LoadingScene extends Scene {
async
start
()
{
super
.
start
()
GDispatcher
.
addEventListener
(
FYGE
.
Event
.
PROGRESS
,
this
.
progressEvent
,
this
)
this
.
addEventListener
(
FYGE
.
Event
.
PROGRESS
,
this
.
progressEvent
,
this
)
//首次进度一点
GDispatcher
.
dispatchEvent
(
FYGE
.
Event
.
PROGRESS
,
0.2
)
this
.
dispatchEvent
(
FYGE
.
Event
.
PROGRESS
,
0.2
)
//获取app数据
const
{
data
}
=
await
sendTbNet
(
TbNetName
.
getAppData
);
Tools
.
globalData
=
data
;
GDispatcher
.
dispatchEvent
(
FYGE
.
Event
.
PROGRESS
,
0.3
)
this
.
dispatchEvent
(
FYGE
.
Event
.
PROGRESS
,
0.3
)
//询问读取权限,不阻止进程
Tools
.
checkPermission
();
//获取首页数据
...
...
@@ -108,7 +107,7 @@ export class LoadingScene extends Scene {
//失败不进入
if
(
!
getIndexSuccesss
)
return
;
GDispatcher
.
dispatchEvent
(
FYGE
.
Event
.
PROGRESS
,
0.3
);
this
.
dispatchEvent
(
FYGE
.
Event
.
PROGRESS
,
0.3
);
// 游戏基本信息
const
baseInfo
=
await
sendTbNet
(
TbNetName
.
getActivityBaseInfoById
);
...
...
@@ -118,7 +117,7 @@ export class LoadingScene extends Scene {
Tools
.
baseInfo
.
prizeLevels
.
push
(
+
k
.
split
(
'_'
)[
1
]);
}
GDispatcher
.
dispatchEvent
(
FYGE
.
Event
.
PROGRESS
,
0.5
);
this
.
dispatchEvent
(
FYGE
.
Event
.
PROGRESS
,
0.5
);
//首次进入,地图页面需要引导
// if (Tools.gameData.isFristLogin) {
...
...
@@ -134,17 +133,18 @@ export class LoadingScene extends Scene {
return
RES
.
loadGroup
(
e
)
}))
GDispatcher
.
dispatchEvent
(
FYGE
.
Event
.
PROGRESS
,
1
);
this
.
dispatchEvent
(
FYGE
.
Event
.
PROGRESS
,
1
);
}
// private lastP=0
progressEvent
(
e
:
FYGE
.
Event
)
{
let
pro
=
e
.
data
;
FYGE
.
Tween
.
get
(
this
.
progressBar
,
null
,
null
,
true
)
.
to
({
value
:
e
.
data
},
2000
/**(p-this.lastP)*/
)
.
to
({
value
:
pro
},
2000
/**(p-this.lastP)*/
)
.
call
(()
=>
{
if
(
e
.
data
>=
1
)
{
GDispatcher
.
removeEventListener
(
FYGE
.
Event
.
PROGRESS
,
this
.
progressEvent
,
this
);
changeScene
(
MapScene
,
{
from
:
"loading"
})
if
(
pro
>=
1
)
{
this
.
removeEventListener
(
FYGE
.
Event
.
PROGRESS
,
this
.
progressEvent
,
this
);
changeScene
(
MapScene
,
{
from
:
"loading"
})
}
})
// this.lastP=p
...
...
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