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";
import resCanvasList from "../resCanvasList"
import { SCENETYPE } from "./Enum";
import { GDispatcher } from "./Main";
import { sendTbNet, TbNetName } from "./TaoBaoNet";
/**记录全局信息与全局方法 */
export class Ins {
......@@ -36,15 +37,16 @@ export class Ins {
}
public static showToast(msg?:any){
FYGE.GDispatcher.dispatchEvent("toast",msg);
console.log("发出message",msg)
GDispatcher.dispatchEvent({type:"toast"},msg);
}
public static showLoading(){
FYGE.GDispatcher.dispatchEvent("loading");
GDispatcher.dispatchEvent("loading");
}
public static hideLoading(){
FYGE.GDispatcher.dispatchEvent("hideloading");
GDispatcher.dispatchEvent("hideloading");
}
/**删除一个lottie的所有tween,停止动效 */
......
......@@ -10,5 +10,5 @@ export const ResJson = {
"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 {
/**
* 猫咪互动
*/
interaction = "tamllCat.interaction",
interaction = "tmallCat.interaction",
/**
* 埋点统计 到时改名字
* activityId params elemType
......
......@@ -27,6 +27,7 @@ import { CATTYPE, MSG, CAT_ACTTYPEP } from "../Enum";
import { Ins } from "../Ins";
import { sendTbNet, TbNetName } from "../TaoBaoNet";
import { showToast } from "../../module/ctrls";
import { GDispatcher } from "../Main";
export class Cat extends Module {
/**1:蓝猫,2:橘猫,3:三花,4:暹罗 */
......@@ -210,9 +211,9 @@ export class Cat extends Module {
break;
}
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) {
FYGE.GDispatcher.dispatchEvent(MSG.UPDATE_USERINFO);
GDispatcher.dispatchEvent(MSG.UPDATE_USERINFO);
that.actRunning = true;
switch (actType) {
case CAT_ACTTYPEP.SLEEP:
......
......@@ -92,12 +92,14 @@ export class MainScene extends Scene {
var that = this;
that.cat = new Cat({ type: Ins.userInfo.catType });
that.addChild(that.cat);
that.letter = new FYGE.Lottie(letter);
that.addChild(that.letter);
that.letter.play();
that.letter.visible = false;
if (Ins.catIsOut) {
that.cat.visible = false;
//当猫出走的时候,隐藏猫咪,创建信封
that.letter = new FYGE.Lottie(letter);
that.addChild(that.letter);
that.letter.play();
that.letter.visible = true;
}
}
......@@ -165,11 +167,12 @@ export class MainScene extends Scene {
changeMainScene(type: SCENETYPE) {
console.log("切换到" + type)
var that = this;
Ins.curScene = type;
Ins.curScene = type>3?3:type;
that.sceneBg.texture = RES.getRes(resCanvasList[that.bgUUID[type-1]].url)
//切换场景时判断猫在不在,后面要改成与接口值判断
if (Ins.catIsOut) {
that.cat.visible = false;
that.cat.stopCatAct();
} else {
if ((type) == Ins.userInfo.sence) {
that.cat.visible = true;
......@@ -201,16 +204,40 @@ export class MainScene extends Scene {
that.mainUi.changeBtnByUiType(type);
}
/**更新用户信息时更新场景信息 */
updateSceneInfo(){
}
/**更新用户相关信息 */
updateUserInfo() {
console.log("刷新用户信息")
var that = this;
sendTbNet(TbNetName.getUserInfo, {}, (s, r) => {
if (s) {
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.mainUi.updateUserInfo();
} else {
showToast(r.message)
Ins.showToast(r.message)
}
})
}
......@@ -223,7 +250,7 @@ export class MainScene extends Scene {
that.mxqBtn.addEventListener(FYGE.MouseEvent.CLICK, () => { that.changeMainScene(SCENETYPE.PLAYGROUND) }, 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.UPDATE_USERINFO, that.updateUserInfo, that);
GDispatcher.addEventListener(MSG.UPDATE_USERINFO, that.updateUserInfo, that);
}
removeEvents() {
......@@ -233,6 +260,6 @@ export class MainScene extends Scene {
that.mxqBtn.removeEventListener(FYGE.MouseEvent.CLICK, () => { that.changeMainScene(SCENETYPE.PLAYGROUND) }, 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.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 {
}
}
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) {
console.log(e.target);
......@@ -248,6 +266,7 @@ export class MainSceneBtnUi extends Module {
/**补充精力 */
getEnergy() {
console.log("补充精力");
Ins.showModule("taskModal");
}
/**返回到寝室 */
......@@ -283,7 +302,8 @@ export class MainSceneBtnUi extends Module {
/**打开攻略 */
openStrategy() {
console.log("打开攻略");
showPanel(RulePanel);
// showPanel(RulePanel);
Ins.showModule("catruleModal");
}
/**打开奖品页面 */
......
......@@ -5,7 +5,7 @@
left: 18rpx;
top: 392rpx;
position: absolute;
transform-origin: 0rpx 0rpx 0rpx;
transform-origin: 50% 50% 0rpx;
display: block;
}
.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="catrulep" src={{resList['617927a2-2dd6-456a-9d92-1f607a137dbc'].url}} />
<view class="catrulelabel" onTouchMove="touchMove" >
......
......@@ -11,6 +11,6 @@
<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="{{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>
<view class="popcontainer" a:if="{{catruleModalVisible}}"><catrule-modal onModalClose="closeCatruleModal"></catrule-modal></view>
......@@ -38,6 +38,7 @@ Page({
selectcatModalVisible: false,
catnameModalVisible: false,
recallcatModalVisible: false,
recallcatModalData:{},
getcatModalVisible: false,
getcatModalData: {},
catbackbedModalVisible: false,
......@@ -115,7 +116,7 @@ Page({
app.canvasMain = this.main;
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("hideloading", self.hideLoadingHandler, self);
}
......@@ -135,6 +136,7 @@ Page({
},
showToastHandler(e) {
console.log("接受到消息展示canvas的toast")
my.showToast({
content: e.data || "网络异常,请稍后重试~",
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