Commit 487bbcb5 authored by Edwise's avatar Edwise 🍷

1234

parent f2a8884a
{
"success": true,
"data": 1500,
"code": "culpa eu Ut"
}
\ No newline at end of file
......@@ -4,13 +4,16 @@
"data": {
"catType": 2,
"userNick": "Edwise",
"energy": 100,
"energy": 1000,
"happyCoin":1000,
"experience": 50,
"experience": 80,
"level": "1",
"avatar": "https://yun.duiba.com.cn/spark/assets/a3ae99684afa9a1f8d94f4c95ee6f1ed81de9996.png",
"sence": 4,
"catName": "哈哈哈",
"senceTips":["1说话说话说话说话说话说话说话说话说话说话说话","2说话说话说话说话说话说话说话说话说话说话说话说话","3说话说话说话说话说话说话说话说话说话说话说话说话"]
"senceTips":["1说话说话说话说话说话说话说话说话说话说话说话","2说话说话说话说话说话说话说话说话说话说话说话说话","3说话说话说话说话说话说话说话说话说话说话说话说话"],
"energyMax":2000,
"experienceMax":100
}
}
\ No newline at end of file
{
"success": true,
"data": null,
"code": "culpa eu Ut"
}
\ No newline at end of file
......@@ -658,6 +658,36 @@ const resCanvasList = {
ext: '.png',
url: 'https://yun.duiba.com.cn/spark/assets/catTalkDialog.6fa85b0929d7d8e0d42d0d30587cdbdc33059a8f.png',
uuid: '624e8c63-963f-4b20-9802-b0fb006fbf93'
},
'8b0d746a-524e-4dc5-984a-2da2f7f6f862': {
name: 'avatarBg',
ext: '.png',
url: 'https://yun.duiba.com.cn/spark/assets/avatarBg.ab4622741c93fb3b2a08f0f8f01c8c4b31ae5cb0.png',
uuid: '8b0d746a-524e-4dc5-984a-2da2f7f6f862'
},
'60d6bb5e-5af1-459d-8a0f-ac7a3edcb703': {
name: 'exLoadingBg',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/exLoadingBg.a9104e208e4d425d0dc3fef446acae78d3e2753f.png',
uuid: '60d6bb5e-5af1-459d-8a0f-ac7a3edcb703'
},
'f2a39dcf-acc3-4cc8-9dd1-e82e915048db': {
name: 'exLoadingFront',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/exLoadingFront.a21f9697486f4433973e5f521ff9d6a978098503.png',
uuid: 'f2a39dcf-acc3-4cc8-9dd1-e82e915048db'
},
'3e9351dd-787d-4dca-bbf3-793d129c6332': {
name: 'shapGoBtn',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/shapGoBtn.78caf5d5af696b5510dd675e626089a320a5c3f1.png',
uuid: '3e9351dd-787d-4dca-bbf3-793d129c6332'
},
'dba58651-57a3-4b75-9447-0e4d498dd8cd': {
name: 'shapGoBtn1',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/shapGoBtn1.d4d2cbdd9ab87642e34600c20ca627c9a377ffb7.png',
uuid: 'dba58651-57a3-4b75-9447-0e4d498dd8cd'
}
};
export default resCanvasList;
......@@ -16,6 +16,9 @@ export class Ins {
/**当前用户所在场景 */
public static curScene:SCENETYPE;
/**多长时间恢复精力(ms) */
public static recoverEnergy:number = 5*60*1000;
public static userInfo: {
"catName": string, //猫咪姓名
"catType": number, //猫咪类型
......@@ -26,7 +29,9 @@ export class Ins {
"level": string, //等级
"avatar": string, //头像
"sence": number, //场景
"senceTips":string[] //场景互动文案(猫咪说话)
"senceTips":string[], //场景互动文案(猫咪说话)
"energyMax":number,
"experienceMax":number
}
......@@ -36,17 +41,23 @@ export class Ins {
})
}
public static navigateToPage(name:string,data?){
sendTbNet(TbNetName.navigateToPage, { name: name, data: data?data:{} }, (s, res) => {
console.log('showModal ruleModal, success,res', s, res)
})
}
public static showToast(msg?:any){
console.log("发出message",msg)
GDispatcher.dispatchEvent({type:"toast"},msg);
}
public static showLoading(){
GDispatcher.dispatchEvent("loading");
GDispatcher.dispatchEvent({type:"loading"});
}
public static hideLoading(){
GDispatcher.dispatchEvent("hideloading");
GDispatcher.dispatchEvent({type:"hideloading"});
}
/**删除一个lottie的所有tween,停止动效 */
......
......@@ -4,8 +4,8 @@ import { GDispatcher } from "./Main";
//接口枚举,包括需要调用淘宝的api,用是否含有兑吧区分,或者单独区分
export enum TbNetName {
navigateToPage = "mine.navigateToPage",
showModal = "mine.showModal",
navigateToPage = "mine.navigateToPage",
showModal = "mine.showModal",
/**
* 获取用户领养信息
......@@ -16,65 +16,25 @@ export enum TbNetName {
* 猫咪互动
*/
interaction = "tmallCat.interaction",
/**
* 埋点统计 到时改名字
* activityId params elemType
*/
trackingReport = "squirrelsAdoptRest2c.trackingReport",
getActivityBaseInfoById= "bubbleSurviva.getActivityBaseInfoById",
/**
* 获取游戏信息
* activityId
*/
getGameInfo = "babycare.getGameInfo",
/**
* 消耗道具 ,会返回剩余所有道具数量
* activityId type
*/
consumerTools = "babycare.consumerTools",
/**
* 提交分数
* activityId level score stars isVisitSuccess(是否通关)
*/
gameOver = "babycare.gameOver",
/**
* 领取任务奖励
* activityId taskType
*/
receiveTaskRewards = "babycare.receiveTaskRewards",
/**
* 积分兑换道具和体力
* activityId type credits
* 恢复精力
*/
exchange = "babycare.exchange",
/**
* 根据等级获取奖品列表
* activityId level
*/
getPrizesByLevel = "babycare.getPrizesByLevel",
/**
* 查询用户积分
* activityId
*/
queryCredits = "babycare.queryCredits",
/**
* 开始闯关,会返回体力值
* activityId level
*/
dojoin = "babycare.dojoin",
recoverEnergy = "tmallCat.recoverEnergy",
/**
* 完成任务(浏览商品详情页, 关注店铺)
* activityId taskType
* 获取精力值
*/
completeTask = "babycare.completeTask",
getUserEnergy = "tmallCat.getUserEnergy",
/**
* 任务列表
* activityId
* 埋点统计 到时改名字
* activityId params elemType
*/
getTaskList = "babycare.getTaskList",
trackingReport = "squirrelsAdoptRest2c.trackingReport",
getActivityBaseInfoById = "bubbleSurviva.getActivityBaseInfoById",
///////////////////前端调用接口都加个mine
......
......@@ -37,6 +37,7 @@ export class MainScene extends Scene {
private energy: number; //当前精力值
private energyImgW: number; //精力条宽度
private maxEnergy: number = 1500; //最大精力值
private recoverEnergyHandler: any; //恢复精力的定时器,用于保存下来方便清空
/**猫咪等级 */
private level: number = 0;
......@@ -57,7 +58,7 @@ export class MainScene extends Scene {
//0:教室,1:操场,2:寝室
that.bgUUID = ["c6d699b0-b276-4985-b3ea-47bcef13f2ea", "efaf990e-5392-49ad-94d8-25c04f651ede", "b3c8c187-e5c9-4968-9a00-a118d18ab2fc"];
//生成默认场景,后面要改成根据接口值判断
that.sceneBg = Ins.initSprite(that.bgUUID[Ins.curScene==4?2:Ins.curScene-1]);
that.sceneBg = Ins.initSprite(that.bgUUID[Ins.curScene == 4 ? 2 : Ins.curScene - 1]);
that.addChild(that.sceneBg);
that.tlBtn = Ins.initSprite("1f8b040d-2fbc-4ff8-92f9-159773364fae", 0, 640);
......@@ -72,19 +73,20 @@ export class MainScene extends Scene {
that.mxqBtn.mouseEnable = true;
that.addChild(that.mxqBtn);
if(Ins.curScene==SCENETYPE.BEADROOM||Ins.curScene==4){
if (Ins.curScene == SCENETYPE.BEADROOM || Ins.curScene == 4) {
that.tlBtn.visible = true;
that.mxqBtn.visible = true;
}else{
} else {
that.tlBtn.visible = false;
that.mxqBtn.visible = false;
}
that.mainUi = new MainSceneBtnUi({ uiType: Ins.curScene==4?3:Ins.curScene });
that.mainUi = new MainSceneBtnUi({ uiType: Ins.curScene == 4 ? 3 : Ins.curScene });
that.addChild(that.mainUi);
that.initCat();
that.initEnergy();
that.energyUp();
}
/**初始化猫咪 */
......@@ -107,7 +109,7 @@ export class MainScene extends Scene {
openLetter() {
console.log("打开信封弹窗")
if (this.letter && this.letter.visible) {
Ins.showModule('messageModal',{ catName: Ins.userInfo.catName })
Ins.showModule('messageModal', { catName: Ins.userInfo.catName })
}
}
......@@ -152,6 +154,7 @@ export class MainScene extends Scene {
setEnergy() {
var that = this;
that.energy = Ins.userInfo.energy;
that.maxEnergy = Ins.userInfo.energyMax;
that.energyImg.scaleX = (that.energy / that.maxEnergy);
that.energyDeco.x = that.energyImgW * that.energyImg.scaleX - that.energyDeco.width * 0.2;
that.energyLabel.text = "精力" + that.energy + "/" + that.maxEnergy;
......@@ -160,15 +163,42 @@ export class MainScene extends Scene {
/**按照时间恢复精力 */
energyUp() {
var that = this;
that.recoverEnergyHandler = setInterval(() => {
sendTbNet(TbNetName.recoverEnergy,{},(s,r)=>{
if(s){
that.getUserEnergy();
}else{
Ins.showToast(r.message);
}
});
}, Ins.recoverEnergy)
}
/**时间到的时候拿取精力值 */
getUserEnergy(){
var that = this;
sendTbNet(TbNetName.getUserEnergy,{},(s,r)=>{
if(s){
if(r.data!=Ins.userInfo.energy){
Ins.userInfo.energy = r.data;
that.setEnergy();
return;
}else{
that.getUserEnergy();
}
}else{
Ins.showToast(r.message);
}
})
}
/**切换场景 */
changeMainScene(type: SCENETYPE) {
console.log("切换到" + type)
var that = this;
Ins.curScene = type>3?3:type;
that.sceneBg.texture = RES.getRes(resCanvasList[that.bgUUID[type-1]].url)
Ins.curScene = type > 3 ? 3 : type;
that.sceneBg.texture = RES.getRes(resCanvasList[that.bgUUID[type - 1]].url)
//切换场景时判断猫在不在,后面要改成与接口值判断
if (Ins.catIsOut) {
that.cat.visible = false;
......@@ -205,7 +235,7 @@ export class MainScene extends Scene {
}
/**更新用户信息时更新场景信息 */
updateSceneInfo(){
updateSceneInfo() {
}
......@@ -216,27 +246,27 @@ export class MainScene extends Scene {
sendTbNet(TbNetName.getUserInfo, {}, (s, r) => {
if (s) {
Ins.userInfo = r.data;
if(r.data.sence>3){
if (r.data.sence > 3) {
Ins.catIsOut = true;
that.cat.visible = false;
that.cat.stopCatAct();
that.mainUi.changeBtnByCatIsOuT(Ins.curScene)
if(Ins.curScene==3){
if (Ins.curScene == 3) {
that.letter.visible = true;
}
}else{
if(Ins.catIsOut){
} else {
if (Ins.catIsOut) {
that.cat.visible = true;
that.letter.visible = false;
}
Ins.catIsOut = false;
}
that.setEnergy();
that.mainUi.updateUserInfo();
} else {
Ins.showToast(r.message)
}
})
......@@ -256,6 +286,7 @@ export class MainScene extends Scene {
removeEvents() {
var that = this;
console.log("主场景移除事件")
that.recoverEnergyHandler && clearInterval(that.recoverEnergyHandler);
that.tlBtn.removeEventListener(FYGE.MouseEvent.CLICK, () => { that.changeMainScene(SCENETYPE.CLASSROOM) }, that);
that.mxqBtn.removeEventListener(FYGE.MouseEvent.CLICK, () => { that.changeMainScene(SCENETYPE.PLAYGROUND) }, that);
that.letter && that.letter.removeEventListener(FYGE.MouseEvent.CLICK, that.openLetter, that);
......
......@@ -20,6 +20,8 @@ export class MainSceneBtnUi extends Module {
}
/**ui类型 */
private uiType: SCENETYPE;
/**商城按钮 */
private shapGoBtn:FYGE.Sprite;
/**返回按钮 */
private returnBtn: FYGE.Sprite;
/**攻略按钮 */
......@@ -43,7 +45,8 @@ export class MainSceneBtnUi extends Module {
private catAvatar: FYGE.Sprite; //猫猫头像
private catNameLabel: FYGE.TextField; //猫猫名称文本
private catLevelLabel: FYGE.TextField; //猫猫等级文本
private catExperience:FYGE.TextField; //经验值文本
private catExperienceBg:FYGE.Sprite; //经验值进度条背景
private catExperience:FYGE.Sprite; //经验值进度条
/**鱼鱼积分组 */
private fishPointGroup: FYGE.Sprite;
private fishPointLabel: FYGE.TextField; //鱼鱼积分文本
......@@ -84,6 +87,10 @@ export class MainSceneBtnUi extends Module {
that.energyBtn = Ins.initSprite("cdb8e186-9872-442e-b71e-bba0a9ce5846", 539, -7);
that.bottomBtnGroup.addChild(that.energyBtn);
that.shapGoBtn = Ins.initSprite("dba58651-57a3-4b75-9447-0e4d498dd8cd")
that.shapGoBtn.position.set((Ins.stageW-that.shapGoBtn.width)>>1,137);
that.bottomBtnGroup.addChild(that.shapGoBtn);
that.initCatInfoGroup();
that.initFishPointGroup();
that.initActBtn();
......@@ -94,7 +101,7 @@ export class MainSceneBtnUi extends Module {
/**初始化猫猫信息 */
initCatInfoGroup() {
var that = this;
that.catInfoGroup = Ins.initSprite("af4b699e-5152-4571-8c54-1c06eabf19e9", 69),
that.catInfoGroup = Ins.initSprite("8b0d746a-524e-4dc5-984a-2da2f7f6f862", 69),
that.topBtnGroup.addChild(that.catInfoGroup);
that.catAvatar = new FYGE.Sprite();
......@@ -113,6 +120,21 @@ export class MainSceneBtnUi extends Module {
that.catLevelLabel = Ins.initLabel({ color: "black", size: 24, text: "Lv.1", x: (192 - 19), y: (167 - 145) })
that.catInfoGroup.addChild(that.catLevelLabel);
that.catExperienceBg = Ins.initSprite("60d6bb5e-5af1-459d-8a0f-ac7a3edcb703",76,52);
that.catInfoGroup.addChild(that.catExperienceBg);
that.catExperience = Ins.initSprite("f2a39dcf-acc3-4cc8-9dd1-e82e915048db");
that.catExperience.anchorY = that.catExperience.height>>1;
that.catExperienceBg.addChild(that.catExperience);
var mask = new FYGE.Shape();
mask.beginFill(6, 1);
mask.drawRoundedRect(0, 0, that.catExperience.width, that.catExperience.height, 38, 38, 38, 38);
mask.endFill();
mask.x = 5;
mask.y = 0;
that.catExperienceBg.addChild(mask);
that.catExperience.mask = mask;
// that.catLevelLabel
}
......@@ -148,7 +170,7 @@ export class MainSceneBtnUi extends Module {
/**更新用户数据,在初始化时调用一次,后续通过消息调用,调用用户信息接口的时候调用 */
updateUserInfo() {
var that = this;
const { catName, happyCoin, level, avatar } = Ins.userInfo;
const { catName, happyCoin, level, avatar,experience,experienceMax } = Ins.userInfo;
that.catAvatar.texture = RES.getRes(avatar);
that.catAvatar.width = 52;
that.catAvatar.height = 52;
......@@ -156,6 +178,8 @@ export class MainSceneBtnUi extends Module {
that.catNameLabel.text = catName;
that.catLevelLabel.text = "Lv." + level;
that.fishPointLabel.text = "" + happyCoin;
that.catExperience.scaleX = experience/experienceMax;
}
/**隐藏所有互动按钮 */
......@@ -257,6 +281,12 @@ export class MainSceneBtnUi extends Module {
}
/**去商店拉 */
goShap(){
console.log("去商城")
Ins.navigateToPage("pageshop");
}
/**召回猫咪事件 */
catRecallHandler(){
console.log("召回猫咪");
......@@ -319,6 +349,7 @@ export class MainSceneBtnUi extends Module {
that.addEvent(that.returnBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
that.addEvent(that.strategyBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
that.addEvent(that.prizeBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
that.addEvent(that.shapGoBtn,FYGE.MouseEvent.CLICK,that.goShap);
that.addEvent(that.playBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
that.addEvent(that.catBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
......@@ -348,6 +379,7 @@ export class MainSceneBtnUi extends Module {
that.removeEvent(that.returnBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
that.removeEvent(that.strategyBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
that.removeEvent(that.prizeBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
that.removeEvent(that.shapGoBtn,FYGE.MouseEvent.CLICK,that.goShap);
that.removeEvent(that.playBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
that.removeEvent(that.catBtn, FYGE.MouseEvent.CLICK, that.touchHandler);
......
......@@ -2,7 +2,7 @@
<view class="message__shade modal-animate-fade-in" />
<view class="message ">
<image class="message_bg " src={{resList['ed31e83e-535d-45bf-ba5b-20827a4cd104'].url}} />
<label class="message_txt ">{{mydata.catName}}</label>
<label class="message_txt ">{{mydata.catName+" 留"}}</label>
<image class="message_btn " onTap="onModalClose" src={{resList['3ad6a924-dda8-49f4-b8fc-0e796347e802'].url}} />
<image class="message_closebtn " onTap="onModalClose" src={{resList['5488b126-f520-496f-ace6-010a89eb108f'].url}} />
</view>
......
......@@ -29,7 +29,7 @@ Page({
catType: 1,
catName: '',
recallCatInfo: {},
taskModalVisible: 1,
taskModalVisible: 0,
messageModalVisible: false,
messageModalData: {},
ruleModalVisible: false,
......
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