Commit ea06387f authored by Edwise's avatar Edwise 🍷

1234

parent bb292df6
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -2,6 +2,7 @@ import { RES } from "../module/RES"; ...@@ -2,6 +2,7 @@ import { RES } from "../module/RES";
import resCanvasList from "../resCanvasList" import resCanvasList from "../resCanvasList"
import { SCENETYPE } from "./Enum"; import { SCENETYPE } from "./Enum";
import { GDispatcher } from "./Main";
import { sendTbNet, TbNetName } from "./TaoBaoNet"; import { sendTbNet, TbNetName } from "./TaoBaoNet";
/**记录全局信息与全局方法 */ /**记录全局信息与全局方法 */
export class Ins { export class Ins {
...@@ -36,15 +37,16 @@ export class Ins { ...@@ -36,15 +37,16 @@ export class Ins {
} }
public static showToast(msg?:any){ public static showToast(msg?:any){
FYGE.GDispatcher.dispatchEvent("toast",msg); console.log("发出message",msg)
GDispatcher.dispatchEvent({type:"toast"},msg);
} }
public static showLoading(){ public static showLoading(){
FYGE.GDispatcher.dispatchEvent("loading"); GDispatcher.dispatchEvent("loading");
} }
public static hideLoading(){ public static hideLoading(){
FYGE.GDispatcher.dispatchEvent("hideloading"); GDispatcher.dispatchEvent("hideloading");
} }
/**删除一个lottie的所有tween,停止动效 */ /**删除一个lottie的所有tween,停止动效 */
......
...@@ -10,5 +10,5 @@ export const ResJson = { ...@@ -10,5 +10,5 @@ export const ResJson = {
"name": "startScene" "name": "startScene"
} }
], ],
"path": "https://yun.duiba.com.cn/db_games/activity/babycare_xiaoxiao/1600930613/resource/" "path": "https://yun.duiba.com.cn/db_games/activity/babycare_xiaoxiao/1600936371/resource/"
} }
\ No newline at end of file
...@@ -15,8 +15,7 @@ export enum TbNetName { ...@@ -15,8 +15,7 @@ export enum TbNetName {
/** /**
* 猫咪互动 * 猫咪互动
*/ */
interaction = "tamllCat.interaction", interaction = "tmallCat.interaction",
/** /**
* 埋点统计 到时改名字 * 埋点统计 到时改名字
* activityId params elemType * activityId params elemType
......
...@@ -27,6 +27,7 @@ import { CATTYPE, MSG, CAT_ACTTYPEP } from "../Enum"; ...@@ -27,6 +27,7 @@ import { CATTYPE, MSG, CAT_ACTTYPEP } from "../Enum";
import { Ins } from "../Ins"; import { Ins } from "../Ins";
import { sendTbNet, TbNetName } from "../TaoBaoNet"; import { sendTbNet, TbNetName } from "../TaoBaoNet";
import { showToast } from "../../module/ctrls"; import { showToast } from "../../module/ctrls";
import { GDispatcher } from "../Main";
export class Cat extends Module { export class Cat extends Module {
/**1:蓝猫,2:橘猫,3:三花,4:暹罗 */ /**1:蓝猫,2:橘猫,3:三花,4:暹罗 */
...@@ -210,9 +211,9 @@ export class Cat extends Module { ...@@ -210,9 +211,9 @@ export class Cat extends Module {
break; break;
} }
console.log(actType); console.log(actType);
sendTbNet(TbNetName.interaction, {type:type,scene:Ins.curScene}, (s, r) => { sendTbNet(TbNetName.interaction, {type:type,sence:Ins.curScene}, (s, r) => {
if (s) { if (s) {
FYGE.GDispatcher.dispatchEvent(MSG.UPDATE_USERINFO); GDispatcher.dispatchEvent(MSG.UPDATE_USERINFO);
that.actRunning = true; that.actRunning = true;
switch (actType) { switch (actType) {
case CAT_ACTTYPEP.SLEEP: case CAT_ACTTYPEP.SLEEP:
......
...@@ -92,12 +92,14 @@ export class MainScene extends Scene { ...@@ -92,12 +92,14 @@ export class MainScene extends Scene {
var that = this; var that = this;
that.cat = new Cat({ type: Ins.userInfo.catType }); that.cat = new Cat({ type: Ins.userInfo.catType });
that.addChild(that.cat); that.addChild(that.cat);
that.letter = new FYGE.Lottie(letter);
that.addChild(that.letter);
that.letter.play();
that.letter.visible = false;
if (Ins.catIsOut) { if (Ins.catIsOut) {
that.cat.visible = false; that.cat.visible = false;
//当猫出走的时候,隐藏猫咪,创建信封 //当猫出走的时候,隐藏猫咪,创建信封
that.letter = new FYGE.Lottie(letter); that.letter.visible = true;
that.addChild(that.letter);
that.letter.play();
} }
} }
...@@ -165,11 +167,12 @@ export class MainScene extends Scene { ...@@ -165,11 +167,12 @@ export class MainScene extends Scene {
changeMainScene(type: SCENETYPE) { changeMainScene(type: SCENETYPE) {
console.log("切换到" + type) console.log("切换到" + type)
var that = this; var that = this;
Ins.curScene = type; Ins.curScene = type>3?3:type;
that.sceneBg.texture = RES.getRes(resCanvasList[that.bgUUID[type-1]].url) that.sceneBg.texture = RES.getRes(resCanvasList[that.bgUUID[type-1]].url)
//切换场景时判断猫在不在,后面要改成与接口值判断 //切换场景时判断猫在不在,后面要改成与接口值判断
if (Ins.catIsOut) { if (Ins.catIsOut) {
that.cat.visible = false; that.cat.visible = false;
that.cat.stopCatAct();
} else { } else {
if ((type) == Ins.userInfo.sence) { if ((type) == Ins.userInfo.sence) {
that.cat.visible = true; that.cat.visible = true;
...@@ -201,16 +204,40 @@ export class MainScene extends Scene { ...@@ -201,16 +204,40 @@ export class MainScene extends Scene {
that.mainUi.changeBtnByUiType(type); that.mainUi.changeBtnByUiType(type);
} }
/**更新用户信息时更新场景信息 */
updateSceneInfo(){
}
/**更新用户相关信息 */ /**更新用户相关信息 */
updateUserInfo() { updateUserInfo() {
console.log("刷新用户信息")
var that = this; var that = this;
sendTbNet(TbNetName.getUserInfo, {}, (s, r) => { sendTbNet(TbNetName.getUserInfo, {}, (s, r) => {
if (s) { if (s) {
Ins.userInfo = r.data; Ins.userInfo = r.data;
if(r.data.sence>3){
Ins.catIsOut = true;
that.cat.visible = false;
that.cat.stopCatAct();
that.mainUi.changeBtnByCatIsOuT(Ins.curScene)
if(Ins.curScene==3){
that.letter.visible = true;
}
}else{
if(Ins.catIsOut){
that.cat.visible = true;
that.letter.visible = false;
}
Ins.catIsOut = false;
}
that.setEnergy(); that.setEnergy();
that.mainUi.updateUserInfo(); that.mainUi.updateUserInfo();
} else { } else {
showToast(r.message)
Ins.showToast(r.message)
} }
}) })
} }
...@@ -223,7 +250,7 @@ export class MainScene extends Scene { ...@@ -223,7 +250,7 @@ export class MainScene extends Scene {
that.mxqBtn.addEventListener(FYGE.MouseEvent.CLICK, () => { that.changeMainScene(SCENETYPE.PLAYGROUND) }, that); that.mxqBtn.addEventListener(FYGE.MouseEvent.CLICK, () => { that.changeMainScene(SCENETYPE.PLAYGROUND) }, that);
that.letter && that.letter.addEventListener(FYGE.MouseEvent.CLICK, that.openLetter, that); that.letter && that.letter.addEventListener(FYGE.MouseEvent.CLICK, that.openLetter, that);
FYGE.GDispatcher.addEventListener(MSG.CHANGE_SCENE, () => { that.changeMainScene(SCENETYPE.BEADROOM) }, that); FYGE.GDispatcher.addEventListener(MSG.CHANGE_SCENE, () => { that.changeMainScene(SCENETYPE.BEADROOM) }, that);
FYGE.GDispatcher.addEventListener(MSG.UPDATE_USERINFO, that.updateUserInfo, that); GDispatcher.addEventListener(MSG.UPDATE_USERINFO, that.updateUserInfo, that);
} }
removeEvents() { removeEvents() {
...@@ -233,6 +260,6 @@ export class MainScene extends Scene { ...@@ -233,6 +260,6 @@ export class MainScene extends Scene {
that.mxqBtn.removeEventListener(FYGE.MouseEvent.CLICK, () => { that.changeMainScene(SCENETYPE.PLAYGROUND) }, that); that.mxqBtn.removeEventListener(FYGE.MouseEvent.CLICK, () => { that.changeMainScene(SCENETYPE.PLAYGROUND) }, that);
that.letter && that.letter.removeEventListener(FYGE.MouseEvent.CLICK, that.openLetter, that); that.letter && that.letter.removeEventListener(FYGE.MouseEvent.CLICK, that.openLetter, that);
FYGE.GDispatcher.removeEventListener(MSG.CHANGE_SCENE, () => { that.changeMainScene(SCENETYPE.BEADROOM) }, that); FYGE.GDispatcher.removeEventListener(MSG.CHANGE_SCENE, () => { that.changeMainScene(SCENETYPE.BEADROOM) }, that);
FYGE.GDispatcher.removeEventListener(MSG.UPDATE_USERINFO, that.updateUserInfo, that); GDispatcher.removeEventListener(MSG.UPDATE_USERINFO, that.updateUserInfo, that);
} }
} }
\ No newline at end of file
...@@ -199,6 +199,24 @@ export class MainSceneBtnUi extends Module { ...@@ -199,6 +199,24 @@ export class MainSceneBtnUi extends Module {
} }
} }
changeBtnByCatIsOuT(type){
var that = this;
that.hideAllActBtn();
switch (type) {
case SCENETYPE.BEADROOM:
that.catRecall.visible = true;
break;
case SCENETYPE.CLASSROOM:
that.returnBtn.visible = true;
break;
case SCENETYPE.PLAYGROUND:
that.returnBtn.visible = true;
break;
default: console.log("改变场景ui时设置uiType错误");
break;
}
}
/**触摸事件 */ /**触摸事件 */
touchHandler(e: FYGE.MouseEvent) { touchHandler(e: FYGE.MouseEvent) {
console.log(e.target); console.log(e.target);
...@@ -248,6 +266,7 @@ export class MainSceneBtnUi extends Module { ...@@ -248,6 +266,7 @@ export class MainSceneBtnUi extends Module {
/**补充精力 */ /**补充精力 */
getEnergy() { getEnergy() {
console.log("补充精力"); console.log("补充精力");
Ins.showModule("taskModal");
} }
/**返回到寝室 */ /**返回到寝室 */
...@@ -283,7 +302,8 @@ export class MainSceneBtnUi extends Module { ...@@ -283,7 +302,8 @@ export class MainSceneBtnUi extends Module {
/**打开攻略 */ /**打开攻略 */
openStrategy() { openStrategy() {
console.log("打开攻略"); console.log("打开攻略");
showPanel(RulePanel); // showPanel(RulePanel);
Ins.showModule("catruleModal");
} }
/**打开奖品页面 */ /**打开奖品页面 */
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
left: 18rpx; left: 18rpx;
top: 392rpx; top: 392rpx;
position: absolute; position: absolute;
transform-origin: 0rpx 0rpx 0rpx; transform-origin: 50% 50% 0rpx;
display: block; display: block;
} }
.catrule .catrulebg { .catrule .catrulebg {
......
<view class="catrule"> <view class="catrule modal-animate-zoom-in">
<image class="catrulebg" src={{resList['716ced79-de7f-40ca-ac98-46a5adf13db0'].url}} /> <image class="catrulebg" src={{resList['716ced79-de7f-40ca-ac98-46a5adf13db0'].url}} />
<image class="catrulep" src={{resList['617927a2-2dd6-456a-9d92-1f607a137dbc'].url}} /> <image class="catrulep" src={{resList['617927a2-2dd6-456a-9d92-1f607a137dbc'].url}} />
<view class="catrulelabel" onTouchMove="touchMove" > <view class="catrulelabel" onTouchMove="touchMove" >
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
<view class="popcontainer" a:if="{{catnameModalVisible}}" ><catname-modal selectType="{{catType}}" onModalClose="closeCatnameModal" onSelectCatOk="selectCatOk" /></view> <view class="popcontainer" a:if="{{catnameModalVisible}}" ><catname-modal selectType="{{catType}}" onModalClose="closeCatnameModal" onSelectCatOk="selectCatOk" /></view>
<view class="popcontainer" a:if="{{recallcatModalVisible}}"><recallcat-modal onRecallCat="recallCat" onModalClose="closeRecallcatModal"></recallcat-modal></view> <view class="popcontainer" a:if="{{recallcatModalVisible}}"><recallcat-modal onRecallCat="recallCat" onModalClose="closeRecallcatModal"></recallcat-modal></view>
<view class="popcontainer" a:if="{{getcatModalVisible}}"><getcat-modal selectType="{{catType}}" catName="{{catName}}" onPostSelectCat="postSelectCat" onModalClose="closeGetcatModal"></getcat-modal></view> <view class="popcontainer" a:if="{{getcatModalVisible}}"><getcat-modal selectType="{{catType}}" catName="{{catName}}" onPostSelectCat="postSelectCat" onModalClose="closeGetcatModal"></getcat-modal></view>
<view class="popcontainer" a:if="{{catbackbedModalVisible}}"><catbackbed-modal mydata="{{getcatModalData}}" recallCatInfo="{{recallCatInfo}}" onUpdateUserInfo="updateUserInfo" onModalClose="closeCatbackModal"></catbackbed-modal></view> <view class="popcontainer" a:if="{{catbackbedModalVisible}}"><catbackbed-modal mydata="{{recallcatModalData}}" recallCatInfo="{{recallCatInfo}}" onUpdateUserInfo="updateUserInfo" onModalClose="closeCatbackModal"></catbackbed-modal></view>
<task-modal a:if="{{taskModalVisible}}" onModalClose="closeTaskModal"></task-modal> <task-modal a:if="{{taskModalVisible}}" onModalClose="closeTaskModal"></task-modal>
<view class="popcontainer" a:if="{{catruleModalVisible}}"><catrule-modal onModalClose="closeCatruleModal"></catrule-modal></view> <view class="popcontainer" a:if="{{catruleModalVisible}}"><catrule-modal onModalClose="closeCatruleModal"></catrule-modal></view>
...@@ -38,6 +38,7 @@ Page({ ...@@ -38,6 +38,7 @@ Page({
selectcatModalVisible: false, selectcatModalVisible: false,
catnameModalVisible: false, catnameModalVisible: false,
recallcatModalVisible: false, recallcatModalVisible: false,
recallcatModalData:{},
getcatModalVisible: false, getcatModalVisible: false,
getcatModalData: {}, getcatModalData: {},
catbackbedModalVisible: false, catbackbedModalVisible: false,
...@@ -115,7 +116,7 @@ Page({ ...@@ -115,7 +116,7 @@ Page({
app.canvasMain = this.main; app.canvasMain = this.main;
this.main.addGlobalEvent("onMessage", self.onMessage, self); this.main.addGlobalEvent("onMessage", self.onMessage, self);
this.main.addGlobalEvent("toast", self.showToast, self); this.main.addGlobalEvent("toast", self.showToastHandler, self);
this.main.addGlobalEvent("loading", self.showLoadingHandler, self); this.main.addGlobalEvent("loading", self.showLoadingHandler, self);
this.main.addGlobalEvent("hideloading", self.hideLoadingHandler, self); this.main.addGlobalEvent("hideloading", self.hideLoadingHandler, self);
} }
...@@ -135,6 +136,7 @@ Page({ ...@@ -135,6 +136,7 @@ Page({
}, },
showToastHandler(e) { showToastHandler(e) {
console.log("接受到消息展示canvas的toast")
my.showToast({ my.showToast({
content: e.data || "网络异常,请稍后重试~", content: e.data || "网络异常,请稍后重试~",
duration: 2000 duration: 2000
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment