Commit 199cae6d authored by Edwise's avatar Edwise 🍷

1234

parent c0d20f8b
{ {
"success": true, "success": true,
"message":"请稍后重试", "data": {
"data": "aaaa", "tips": "梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛梳毛",
"code": "000" "isUpgrade": true,
"channel": "aliqua",
"strategyCode": "dolore",
"code": "et nostrud adipisicing",
"image": "occaecat aliquip",
"name": "officia et deserunt ut",
"type": 65894870.29773912
},
"code": "culpa eu Ut"
} }
\ No newline at end of file
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"level": "1", "level": "1",
"avatar": "https://yun.duiba.com.cn/spark/assets/a3ae99684afa9a1f8d94f4c95ee6f1ed81de9996.png", "avatar": "https://yun.duiba.com.cn/spark/assets/a3ae99684afa9a1f8d94f4c95ee6f1ed81de9996.png",
"sence": 3, "sence": 3,
"catName": "喵喵喵fuck." "catName": "喵喵喵",
"senceTips":["1说话说话说话说话说话说话说话说话说话说话说话","2说话说话说话说话说话说话说话说话说话说话说话说话","3说话说话说话说话说话说话说话说话说话说话说话说话"]
} }
} }
\ No newline at end of file
/**当前场景对应的类型 */ /**当前场景对应的类型 */
export enum SCENETYPE{ export enum SCENETYPE{
/**教室 */ /**教室 */
CLASSROOM, CLASSROOM=1,
/**操场 */ /**操场 */
PLAYGROUND, PLAYGROUND,
/**寝室 */ /**寝室 */
......
import { RES } from "../module/RES"; import { RES } from "../module/RES";
import resCanvasList from "../resCanvasList" import resCanvasList from "../resCanvasList"
import { SCENETYPE } from "./Enum";
/**记录全局信息与全局方法 */ /**记录全局信息与全局方法 */
export class Ins { export class Ins {
/**舞台宽高 */ /**舞台宽高 */
...@@ -10,6 +11,9 @@ export class Ins { ...@@ -10,6 +11,9 @@ export class Ins {
/**猫咪是否出寝了 */ /**猫咪是否出寝了 */
public static catIsOut:boolean; public static catIsOut:boolean;
/**当前用户所在场景 */
public static curScene:SCENETYPE;
public static userInfo: { public static userInfo: {
"catName": string, //猫咪姓名 "catName": string, //猫咪姓名
"catType": string, //猫咪类型 "catType": string, //猫咪类型
...@@ -20,7 +24,20 @@ export class Ins { ...@@ -20,7 +24,20 @@ export class Ins {
"level": string, //等级 "level": string, //等级
"avatar": string, //头像 "avatar": string, //头像
"sence": number, //场景 "sence": number, //场景
"senceTips":string[] //场景互动文案(猫咪说话)
}
public static showToast(msg?:any){
FYGE.GDispatcher.dispatchEvent("toast",msg);
}
public static showLoading(){
FYGE.GDispatcher.dispatchEvent("loading");
}
public static hideLoading(){
FYGE.GDispatcher.dispatchEvent("hideloading");
} }
/**删除一个lottie的所有tween,停止动效 */ /**删除一个lottie的所有tween,停止动效 */
......
import { showToast, wait, clearWait } from "../module/ctrls"; import { showToast, wait, clearWait } from "../module/ctrls";
import { Ins } from "./Ins";
import { GDispatcher } from "./Main"; import { GDispatcher } from "./Main";
//接口枚举,包括需要调用淘宝的api,用是否含有兑吧区分,或者单独区分 //接口枚举,包括需要调用淘宝的api,用是否含有兑吧区分,或者单独区分
...@@ -168,7 +169,7 @@ export function sendTbNet( ...@@ -168,7 +169,7 @@ export function sendTbNet(
netName: TbNetName, netName: TbNetName,
parameter?: any, parameter?: any,
callback?: (success: boolean, res?: dataOut) => void, callback?: (success: boolean, res?: dataOut) => void,
hideMsg: boolean = false hideMsg: boolean = true
): Promise<dataOut> { ): Promise<dataOut> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
//网络超时 //网络超时
...@@ -215,7 +216,7 @@ export function sendTbNet( ...@@ -215,7 +216,7 @@ export function sendTbNet(
//记录数据 //记录数据
dataRecord[netName] = d; dataRecord[netName] = d;
//统一错误信息提示,d.data为了区分网络超时 //统一错误信息提示,d.data为了区分网络超时
if (!hideMsg && !d.success) showToast(d.message || "网络超时") if (!hideMsg && !d.success) Ins.showToast(d.message || "网络超时")
//执行回调 //执行回调
callback && callback(d.success, d); callback && callback(d.success, d);
resolve(d) resolve(d)
......
...@@ -46,13 +46,17 @@ export class Cat extends Module { ...@@ -46,13 +46,17 @@ export class Cat extends Module {
actRunning: boolean = false; //动效是否进行中,如果动效进行中,无法进行其他动效 actRunning: boolean = false; //动效是否进行中,如果动效进行中,无法进行其他动效
dialog:FYGE.Sprite; //猫咪对话框气泡 dialog:FYGE.Sprite; //猫咪对话框气泡
dialogText:FYGE.TextField; //猫咪对话框气泡文字内容 dialogText:FYGE.TextField; //猫咪对话框气泡文字内容
dialogPos:any[]=[{x:1,y:1}]; //猫咪对话框气泡位置
initUi() { initUi() {
this.initCatLottieArr(); this.initCatLottieArr();
console.log(this.catLottieArr); console.log(this.catLottieArr);
this.initCat(); this.initCat();
this.initDialog(); this.initDialog();
this.setCatAnimShow(0); var tipsArr = Ins.userInfo.senceTips;
var index = Math.floor(Math.random()*tipsArr.length)
this.showDialog(1,tipsArr[index]);
this.setCatAnimShow(1,()=>{this.stopCatAct()});
this.initEvents(); this.initEvents();
} }
...@@ -125,26 +129,38 @@ export class Cat extends Module { ...@@ -125,26 +129,38 @@ export class Cat extends Module {
/**初始化对话框 */ /**初始化对话框 */
initDialog(){ initDialog(){
var that = this; var that = this;
that.dialogPos = [{},{x:280,y:516},{x:320,y:400},{x:280,y:556},{x:280,y:536},{x:370,y:536}]
that.dialog = Ins.initSprite("624e8c63-963f-4b20-9802-b0fb006fbf93"); that.dialog = Ins.initSprite("624e8c63-963f-4b20-9802-b0fb006fbf93");
that.dialog.position.set(280,526) that.dialog.position.set(280,526)
that.addChild(that.dialog); that.addChild(that.dialog);
that.dialogText = Ins.initLabel({size:24,x:30,y:20}); that.dialogText = Ins.initLabel({size:24,x:30,y:20});
that.dialogText.textWidth = 280; that.dialogText.textWidth = 280;
that.dialog.addChild(that.dialogText); that.dialog.addChild(that.dialogText);
that.dialogText.text = "哈哈哈哈哈哈哈哈哈哈哈\n哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈"; that.dialogText.textHeight = 138;
that.dialogText.verticalAlign = FYGE.VERTICAL_ALIGN.MIDDLE
// that.dialogText.text = "哈哈哈哈哈哈哈,哈哈哈\n哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈";
console.log("最大长度为"+that.dialogText.text.length) console.log("最大长度为"+that.dialogText.text.length)
that.dialog.visible = false; console.log("当前文本高度为"+that.dialogText.textHeight);
// that.dialog.visible = false;
that.dialog.alpha = 0;
} }
/**显示对话框 */ /**显示对话框 */
showDialog(msg:string){ showDialog(type,msg:string){
this.dialogText.text = msg; var that = this;
this.dialog.visible = true; msg = msg.length>=11?msg.substring(0,11)+'\n'+msg.substring(11):msg
that.dialog.position.set(that.dialogPos[type].x,that.dialogPos[type].y)
that.dialogText.text = msg;
FYGE.Tween.removeTweens(that.dialog);
that.dialog.alpha = 0;
FYGE.Tween.get(that.dialog).to({alpha:1},400);
// this.dialog.visible = true;
} }
/**隐藏对话框 */ /**隐藏对话框 */
hideDialog(){ hideDialog(){
this.dialog.visible = false; this.dialog.alpha = 0;
FYGE.Tween.removeTweens(this.dialog);
} }
/**根据index显示猫咪动画 /**根据index显示猫咪动画
...@@ -169,13 +185,31 @@ export class Cat extends Module { ...@@ -169,13 +185,31 @@ export class Cat extends Module {
} }
} }
/**猫咪停止互动 */
stopCatAct(){
var that = this;
that.hideDialog();
that.setCatAnimShow(0,null);
}
/**猫咪互动 */ /**猫咪互动 */
catAct(e) { catAct(e) {
if (this.actRunning) return; if (this.actRunning) return;
var that = this; var that = this;
let actType = e.data; let actType = e.data;
var type;
switch(actType){
case 2: type=2;
break;
case 3: type=1;
break;
case 4: type=4;
break;
case 5: type=3;
break;
}
console.log(actType); console.log(actType);
sendTbNet(TbNetName.interaction, {}, (s, r) => { sendTbNet(TbNetName.interaction, {type:type,scene:Ins.curScene}, (s, r) => {
if (s) { if (s) {
FYGE.GDispatcher.dispatchEvent(MSG.UPDATE_USERINFO); FYGE.GDispatcher.dispatchEvent(MSG.UPDATE_USERINFO);
that.actRunning = true; that.actRunning = true;
...@@ -183,15 +217,15 @@ export class Cat extends Module { ...@@ -183,15 +217,15 @@ export class Cat extends Module {
case CAT_ACTTYPEP.SLEEP: case CAT_ACTTYPEP.SLEEP:
break; break;
default: default:
that.showDialog(actType,r.data.tips);
that.setCatAnimShow(actType, () => { that.setCatAnimShow(actType, () => {
that.hideDialog(); that.stopCatAct();
that.setCatAnimShow(0, null)
}); });
break; break;
} }
}else }else
{ {
showToast(r.message) Ins.showToast(r.message)
} }
}) })
} }
......
...@@ -53,10 +53,11 @@ export class MainScene extends Scene { ...@@ -53,10 +53,11 @@ export class MainScene extends Scene {
that.y = (Ins.stageH - 1624) >> 1; that.y = (Ins.stageH - 1624) >> 1;
console.log(that.y); console.log(that.y);
that.mouseChildren = true; that.mouseChildren = true;
Ins.curScene = Ins.userInfo.sence;
//0:教室,1:操场,2:寝室 //0:教室,1:操场,2:寝室
that.bgUUID = ["c6d699b0-b276-4985-b3ea-47bcef13f2ea", "efaf990e-5392-49ad-94d8-25c04f651ede", "b3c8c187-e5c9-4968-9a00-a118d18ab2fc"]; that.bgUUID = ["c6d699b0-b276-4985-b3ea-47bcef13f2ea", "efaf990e-5392-49ad-94d8-25c04f651ede", "b3c8c187-e5c9-4968-9a00-a118d18ab2fc"];
//生成默认场景,后面要改成根据接口值判断 //生成默认场景,后面要改成根据接口值判断
that.sceneBg = Ins.initSprite("b3c8c187-e5c9-4968-9a00-a118d18ab2fc"); that.sceneBg = Ins.initSprite(that.bgUUID[Ins.curScene-1]);
that.addChild(that.sceneBg); that.addChild(that.sceneBg);
that.tlBtn = Ins.initSprite("1f8b040d-2fbc-4ff8-92f9-159773364fae", 0, 640); that.tlBtn = Ins.initSprite("1f8b040d-2fbc-4ff8-92f9-159773364fae", 0, 640);
...@@ -71,7 +72,15 @@ export class MainScene extends Scene { ...@@ -71,7 +72,15 @@ export class MainScene extends Scene {
that.mxqBtn.mouseEnable = true; that.mxqBtn.mouseEnable = true;
that.addChild(that.mxqBtn); that.addChild(that.mxqBtn);
that.mainUi = new MainSceneBtnUi({ uiType: SCENETYPE.BEADROOM }); if(Ins.curScene==SCENETYPE.BEADROOM){
that.tlBtn.visible = true;
that.mxqBtn.visible = true;
}else{
that.tlBtn.visible = false;
that.mxqBtn.visible = false;
}
that.mainUi = new MainSceneBtnUi({ uiType: Ins.curScene });
that.addChild(that.mainUi); that.addChild(that.mainUi);
that.initCat(); that.initCat();
...@@ -158,16 +167,17 @@ export class MainScene extends Scene { ...@@ -158,16 +167,17 @@ export class MainScene extends Scene {
changeMainScene(type: SCENETYPE) { changeMainScene(type: SCENETYPE) {
console.log("切换到" + type) console.log("切换到" + type)
var that = this; var that = this;
that.sceneBg.texture = RES.getRes(resCanvasList[that.bgUUID[type]].url) Ins.curScene = type;
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;
} else { } else {
if ((type + 1) == Ins.userInfo.sence) { if ((type) == Ins.userInfo.sence) {
that.cat.visible = true; that.cat.visible = true;
} else { } else {
that.cat.visible = false; that.cat.visible = false;
that.cat.setCatAnimShow(0); that.cat.stopCatAct();
} }
} }
switch (type) { switch (type) {
......
...@@ -21,7 +21,7 @@ export class StartScene extends Scene { ...@@ -21,7 +21,7 @@ export class StartScene extends Scene {
if(r.data){ if(r.data){
Ins.userInfo = r.data; Ins.userInfo = r.data;
/**判断猫咪是否出寝,只在用户进入游戏时判断,后面要根据接口改写,现在先做测试 */ /**判断猫咪是否出寝,只在用户进入游戏时判断,后面要根据接口改写,现在先做测试 */
if(r.data.happyCoin>2000){ if(r.data.sence==4){
Ins.catIsOut = true; Ins.catIsOut = true;
}else{ }else{
Ins.catIsOut = false; Ins.catIsOut = false;
...@@ -33,7 +33,7 @@ export class StartScene extends Scene { ...@@ -33,7 +33,7 @@ export class StartScene extends Scene {
} }
}else }else
{ {
showToast(r.message) Ins.showToast(r.message)
} }
}) })
......
...@@ -177,21 +177,20 @@ export class MainSceneBtnUi extends Module { ...@@ -177,21 +177,20 @@ export class MainSceneBtnUi extends Module {
case SCENETYPE.BEADROOM: case SCENETYPE.BEADROOM:
if (Ins.catIsOut) { if (Ins.catIsOut) {
that.catRecall.visible = true; that.catRecall.visible = true;
} else { } else if(Ins.userInfo.sence==type){
that.combingBtn.visible = true; that.combingBtn.visible = true;
that.catBtn.visible = true; that.catBtn.visible = true;
} }
break; break;
case SCENETYPE.CLASSROOM: case SCENETYPE.CLASSROOM:
that.returnBtn.visible = true; that.returnBtn.visible = true;
if (!Ins.catIsOut) { if (!Ins.catIsOut&&Ins.userInfo.sence==type) {
that.touchHeadBtn.visible = true; that.touchHeadBtn.visible = true;
} }
break; break;
case SCENETYPE.PLAYGROUND: case SCENETYPE.PLAYGROUND:
that.returnBtn.visible = true; that.returnBtn.visible = true;
if (!Ins.catIsOut) { if (!Ins.catIsOut&&Ins.userInfo.sence==type) {
that.playBtn.visible = true; that.playBtn.visible = true;
} }
break; break;
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
import resList from '../../resconfig/resList'; import resList from '../../resconfig/resList';
Component({ Component({
props: {}, props: {
},
data: { data: {
resList: resList, resList: resList,
curSelect:1 //1:蓝猫,2:三花,3:暹罗,4:橘猫 curSelect:1 //1:蓝猫,2:三花,3:暹罗,4:橘猫
...@@ -24,10 +26,11 @@ Component({ ...@@ -24,10 +26,11 @@ Component({
}, },
selectSure(){ selectSure(){
const {getCatTypeAndOpenNameModal,onModalClose} = this.props; console.log(this.props);
const {closeModal,onModalClose} = this.props;
onModalClose && onModalClose(); onModalClose && onModalClose();
console.log(getCatTypeAndOpenNameModal) console.log(closeModal)
// getCatTypeAndOpenNameModal&&getCatTypeAndOpenNameModal(this.data.curSelect); closeModal&&closeModal();
} }
}, },
......
...@@ -7,5 +7,6 @@ ...@@ -7,5 +7,6 @@
<rule-modal a:if="{{ruleModalVisible}}" onModalClose="closeRuleModal"><text>{{rule}}</text></rule-modal> <rule-modal a:if="{{ruleModalVisible}}" onModalClose="closeRuleModal"><text>{{rule}}</text></rule-modal>
<levelup-modal a:if="{{levelupModalVisible}}" onModalClose="closeLevelupModal"></levelup-modal> <levelup-modal a:if="{{levelupModalVisible}}" onModalClose="closeLevelupModal"></levelup-modal>
<message-modal a:if="{{messageModalVisible}}" mydata="{{messageModalData}}" onModalClose="closeMessageModal"></message-modal> <message-modal a:if="{{messageModalVisible}}" mydata="{{messageModalData}}" onModalClose="closeMessageModal"></message-modal>
<view class="popcontainer" a:if="{{selectcatModalVisible}}"><selectcat-modal getCatTypeAndOpenNameModal="getCatTypeAndOpenNameModal" onModalClose="closeSelectcatModal"></selectcat-modal></view> <view class="popcontainer" a:if="{{selectcatModalVisible}}"><selectcat-modal onModalClose="closeSelectcatModal" closeModal=closeModal></selectcat-modal></view>
<view class="popcontainer" a:if="{{catnameModalVisible}}" ><catname-modal onModalClose="closeCatnameModal"/></view> <view class="popcontainer" a:if="{{catnameModalVisible}}" ><catname-modal onModalClose="closeCatnameModal"/></view>
\ No newline at end of file
'use strict'; 'use strict';
import { import {
Main Main
} from './output'; } from './output';
import API from '../../api'; import API from '../../api';
import mock from '../../mock'; import mock from '../../mock';
const app = getApp(); const app = getApp();
const { const {
tbcc tbcc
} = app; } = app;
const { const {
commonToast, commonToast,
getAuthUserInfo, getAuthUserInfo,
navigateToOutside, navigateToOutside,
getSystemInfo getSystemInfo
} = tbcc.tb; } = tbcc.tb;
const checkSystem = async () => { const checkSystem = async () => {
const { const {
version version
} = await getSystemInfo(); } = await getSystemInfo();
console.log('version', version); console.log('version', version);
return tbcc.utils.versionCompare(version, '9.8.0'); return tbcc.utils.versionCompare(version, '9.8.0');
} }
Page({ Page({
data: { data: {
catType:1, catType: 1,
catName:'', catName: '',
messageModalVisible: false, messageModalVisible: false,
messageModalData: {}, messageModalData: {},
ruleModalVisible: false, ruleModalVisible: false,
levelupModalVisible: false, levelupModalVisible: false,
selectcatModalVisible: false, selectcatModalVisible: false,
catnameModalVisible: false, catnameModalVisible: false,
}, },
onLoad(props) { onLoad(props) {
this.setData({}); this.setData({});
checkSystem().then(r => { checkSystem().then(r => {
if (!r) { if (!r) {
my.showToast({ my.showToast({
content: "请升级最新版本的淘宝", content: "请升级最新版本的淘宝",
duration: 5000 duration: 5000
});
}
}); });
}
});
}, },
onReady() { onReady() {
console.log('on ready') console.log('on ready')
var that = this; var that = this;
setTimeout(()=>{ setTimeout(() => {
var parameter = {name:"selectcatModal"} var parameter = {
var data = {netName:"mine.showModal",parameter} name: "selectcatModal"
that.onMessage({data:data}) }
},2000) var data = {
//授权和登录先搞 netName: "mine.showModal",
// this.getAuth(); parameter
my.__onMessage__ = (e) => { }
this.onMessage(e) that.onMessage({
} data: data
}, })
}, 2000)
//授权和登录先搞
// this.getAuth();
my.__onMessage__ = (e) => {
this.onMessage(e)
}
},
init() { init() {
console.log('do init'); console.log('do init');
this.spark_startEngine(); this.spark_startEngine();
},
spark_startEngine() { },
console.log('spark_startEngine')
var self = this;
my.createCanvas({
id: 'canvas',
success: ccc => {
const dpr = my.getSystemInfoSync().pixelRatio;
const windowWidth = my.getSystemInfoSync().windowWidth;
const windowHeight = my.getSystemInfoSync().windowHeight;
ccc.width = windowWidth * dpr + dpr; //重新修改会有误差
ccc.height = windowHeight * dpr + dpr; spark_startEngine() {
console.log('spark_startEngine')
var self = this;
my.createCanvas({
id: 'canvas',
success: ccc => {
const dpr = my.getSystemInfoSync().pixelRatio;
const windowWidth = my.getSystemInfoSync().windowWidth;
const windowHeight = my.getSystemInfoSync().windowHeight;
ccc.width = windowWidth * dpr + dpr; //重新修改会有误差
if (!this.main) { ccc.height = windowHeight * dpr + dpr;
this.main = new Main(ccc); //添加事件,为了和main里的通信
app.canvasMain = this.main;
this.main.addGlobalEvent("onMessage", self.onMessage, self); if (!this.main) {
this.main.addGlobalEvent("showToast", self.showToast, self); this.main = new Main(ccc); //添加事件,为了和main里的通信
} app.canvasMain = this.main;
}
});
},
onCanvasReady() { this.main.addGlobalEvent("onMessage", self.onMessage, self);
console.log('onCanvasReady') this.main.addGlobalEvent("toast", self.showToast, self);
//授权和登录先搞 this.main.addGlobalEvent("loading", self.showLoadingHandler,self);
checkSystem().then(r => { this.main.addGlobalEvent("hideloading",self.hideLoadingHandler,self);
if (r) { }
this.getAuth(); }
} });
}); },
},
onCanvasReady() {
console.log('onCanvasReady')
//授权和登录先搞
checkSystem().then(r => {
if (r) {
this.getAuth();
}
});
},
showToast(e) { showToastHandler(e) {
my.showToast({ my.showToast({
content: e.data || "网络异常,请稍后重试~", content: e.data || "网络异常,请稍后重试~",
duration: 2000 duration: 2000
}); });
}, },
showLoadingHandler(){
my.showLoading();
},
hideLoadingHandler(){
my.hideLoading();
},
postMessage(netName, data) { postMessage(netName, data) {
this.main && this.main.dispatchGlobalEvent({ this.main && this.main.dispatchGlobalEvent({
type: netName type: netName
}, data); //以防复用事件event串了,就用这种方式 }, data); //以防复用事件event串了,就用这种方式
}, },
//和main通信的方法,接收main的信息 //和main通信的方法,接收main的信息
onMessage(e) { onMessage(e) {
//接口名字 //接口名字
let netName = e.data.netName; //接口参数 let netName = e.data.netName; //接口参数
let parameter = e.data.parameter; //暂时发现3个需要用户操作的接口 let parameter = e.data.parameter; //暂时发现3个需要用户操作的接口
//定制的授权 //定制的授权
if (netName.indexOf("mine") == 0) { if (netName.indexOf("mine") == 0) {
var data = { var data = {
success: true success: true
}; };
switch (netName) { switch (netName) {
case "mine.getAppData": case "mine.getAppData":
//获取信息 //获取信息
data = { data = {
success: true, success: true,
data: { data: {
activityId: app.activityId, activityId: app.activityId,
nickName: app.nickName, nickName: app.nickName,
avatar: app.avatar, avatar: app.avatar,
openId: app.openId openId: app.openId
}
};
break;
case "mine.navigateToPage": //切换page
data = {
success: true,
data: {}
};
my.navigateTo({
url: `/pages/${parameter.name}/${parameter.name}`
});
break;
case "mine.showModal": //切换page
data = {
success: true,
data: {}
};
const key = `${parameter.name}Visible`;
const datakey = `${parameter.name}Data`;
const toSetData = {};
toSetData[key] = true;
toSetData[datakey] = parameter.data;
this.setData(toSetData);
break;
case 'test':
console.log('测试一下', parameter.hint);
break;
} }
};
break;
case "mine.navigateToPage": //切换page
data = {
success: true,
data: {}
};
my.navigateTo({
url: `/pages/${parameter.name}/${parameter.name}`
});
break;
case "mine.showModal": //切换page
data = {
success: true,
data: {}
};
const key = `${parameter.name}Visible`;
const datakey = `${parameter.name}Data`;
const toSetData = {};
toSetData[key] = true;
toSetData[datakey] = parameter.data;
this.setData(toSetData);
break;
case 'test':
console.log('测试一下', parameter.hint);
break;
}
this.postMessage(netName, data); this.postMessage(netName, data);
} else { } else {
const { const {
function: fc function: fc
} = app.cloud; } = app.cloud;
const [myCloudName, handler] = netName.split("."); //待写, const [myCloudName, handler] = netName.split("."); //待写,
if (app.requestType == 'yapi') { if (app.requestType == 'yapi') {
console.log('mock[handler]', mock[handler]) console.log('mock[handler]', mock[handler])
this.postMessage(netName, mock[handler]); this.postMessage(netName, mock[handler]);
return; return;
} }
parameter.activityId = app.activityId; parameter.activityId = app.activityId;
fc.invoke(myCloudName, parameter, handler).then(res => { fc.invoke(myCloudName, parameter, handler).then(res => {
this.postMessage(netName, res); this.postMessage(netName, res);
}); });
} }
}, },
//鼠标事件 //鼠标事件
onMouseEvent(e) { onMouseEvent(e) {
if (this.main) this.main.stage.onMouseEvent(e); if (this.main) this.main.stage.onMouseEvent(e);
}, },
onShow() { onShow() {
// 页面显示 // 页面显示
if (this.main) { if (this.main) {
this.main.run(); this.main.run();
this.main.dispatchGlobalEvent("onShow"); this.main.dispatchGlobalEvent("onShow");
} }
}, },
onHide() { onHide() {
// 页面隐藏 // 页面隐藏
if (this.main) { if (this.main) {
this.main.pause(); this.main.pause();
this.main.dispatchGlobalEvent("onHide"); this.main.dispatchGlobalEvent("onHide");
} }
}, },
/** /**
* 获取用户授权信息 * 获取用户授权信息
*/ */
async getAuth() { async getAuth() {
const userInfo = await getAuthUserInfo().catch(err => { const userInfo = await getAuthUserInfo().catch(err => {
console.log('未授权成功', err); console.log('未授权成功', err);
}); });
if (userInfo) { if (userInfo) {
console.log('userInfo', userInfo); console.log('userInfo', userInfo);
const { const {
nickName, nickName,
avatar avatar
} = userInfo; } = userInfo;
app.nickName = nickName; app.nickName = nickName;
app.avatar = avatar; app.avatar = avatar;
this.init(); this.init();
// this.login(); // this.login();
} }
}, },
/** /**
* 登录接口 * 登录接口
*/ */
async login() { async login() {
const { const {
nickName, nickName,
avatar avatar
} = app; } = app;
const { const {
success success
} = await API.login({ } = await API.login({
userNick: nickName, userNick: nickName,
avatar avatar
}).catch(res => { }).catch(res => {
commonToast(res && res.message); commonToast(res && res.message);
}) || {}; }) || {};
if (success) { if (success) {
this.init(); this.init();
} }
}, },
/**选择猫咪,打开取名弹窗 */ /**选择猫咪,打开取名弹窗 */
getCatTypeAndOpenNameModal(type){ closeModal() {
this.catType = type; // this.catType = type;
console.log("选择了",type) // console.log("选择了", type)
}, },
closeLevelupModal() { closeLevelupModal() {
this.setData({ this.setData({
levelupModalVisible: false levelupModalVisible: false
}); });
}, },
closeRuleModal() { closeRuleModal() {
this.setData({ this.setData({
ruleModalVisible: false ruleModalVisible: false
}); });
}, },
closeMessageModal() { closeMessageModal() {
this.setData({ this.setData({
messageModalVisible: false messageModalVisible: false
}); });
}, },
closeCatnameModal() { closeCatnameModal() {
this.setData({ this.setData({
catnameModalVisible: false catnameModalVisible: false
}) })
}, },
closeSelectcatModal() { closeSelectcatModal() {
this.setData({ this.setData({
selectcatModalVisible: false selectcatModalVisible: false
}) })
}, },
}); });
\ No newline at end of file
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