Commit ecf1293b authored by liujiaxin's avatar liujiaxin

feat: add exit function

parent 8020f9d6
This diff is collapsed.
...@@ -89,6 +89,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -89,6 +89,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
private kitchen: cc.Node; private kitchen: cc.Node;
private shop: cc.Node; private shop: cc.Node;
private loading: cc.Node; private loading: cc.Node;
private exitButton: cc.Node;
tws: any[] = []; tws: any[] = [];
LoadingCount: number = 1; LoadingCount: number = 1;
initView() { initView() {
...@@ -99,6 +100,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -99,6 +100,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.shop = pg.view.find(this, "shop"); this.shop = pg.view.find(this, "shop");
this.elephant = pg.view.find(this.home, "elephant"); this.elephant = pg.view.find(this.home, "elephant");
this.loading = pg.view.find(this, "loading"); this.loading = pg.view.find(this, "loading");
this.exitButton = pg.view.find(this.home, "exit_btn");
this.elephentState(0); this.elephentState(0);
} }
...@@ -109,9 +111,14 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -109,9 +111,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg.view.touchOn(pg.view.find(this, "shop/btn_close"), this.onTouchShopClose, this); pg.view.touchOn(pg.view.find(this, "shop/btn_close"), this.onTouchShopClose, this);
pg.view.touchOn(pg.view.find(this.elephant, "walk"), this.onTouchElephent, this); pg.view.touchOn(pg.view.find(this.elephant, "walk"), this.onTouchElephent, this);
pg.view.touchOn(pg.view.find(this.elephant, "panel_info/btn_close"), this.onTouchPanel, this); pg.view.touchOn(pg.view.find(this.elephant, "panel_info/btn_close"), this.onTouchPanel, this);
pg.view.touchOn(this.exitButton, this.onExitPetRoom, this);
} }
//----------------------------商店部分-------------------------------------- //----------------------------商店部分--------------------------------------
// 推出按钮
onExitPetRoom() {
cc.find('middleLayer').getComponent('middleLayer').exit();
}
//商店按钮 //商店按钮
private shopType = 0; private shopType = 0;
onTouchShop() { onTouchShop() {
......
...@@ -7,7 +7,7 @@ import shop from "../model/shop"; ...@@ -7,7 +7,7 @@ import shop from "../model/shop";
class Api { class Api {
static askUser() { static askUser() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
pg.http.send("GET", `${globalThis.SERVER_HOST}/api/pets/info`, null).then((userInfo: any) => { pg.http.send("GET", `${cc.find('middleLayer').getComponent('middleLayer').baseUrl}/pets/info`, null).then((userInfo: any) => {
// let userInfo = USER; // let userInfo = USER;
try{ try{
const mood = (Date.now() - userInfo.status.eat.time) > 4 * 60 * 60 * 1000 ? 1: 0; // 4 hours const mood = (Date.now() - userInfo.status.eat.time) > 4 * 60 * 60 * 1000 ? 1: 0; // 4 hours
...@@ -38,7 +38,7 @@ class Api { ...@@ -38,7 +38,7 @@ class Api {
} }
static askUseItem(data) { static askUseItem(data) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
pg.http.send("POST", `${globalThis.SERVER_HOST}/api/pets/use/item`, {item_id: data.id}).then((resp: any) => { pg.http.send("POST", `${cc.find('middleLayer').getComponent('middleLayer').baseUrl}/pets/use/item`, {item_id: data.id}).then((resp: any) => {
// user.addGrowth(data.growthValue); // user.addGrowth(data.growthValue);
// kitchen.use(data.id); // kitchen.use(data.id);
try { try {
...@@ -55,7 +55,7 @@ class Api { ...@@ -55,7 +55,7 @@ class Api {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
data.id; data.id;
data.type; data.type;
pg.http.send("POST", `${globalThis.SERVER_HOST}/api/pets/item/buy`, {item_id: data.id}).then((resp: any) => { pg.http.send("POST", `${cc.find('middleLayer').getComponent('middleLayer').baseUrl}/pets/item/buy`, {item_id: data.id}).then((resp: any) => {
// user.useCoin(data.cost * data.discount); // user.useCoin(data.cost * data.discount);
// kitchen.buy(data.id); // kitchen.buy(data.id);
try { try {
......
...@@ -340,8 +340,8 @@ let pg = { ...@@ -340,8 +340,8 @@ let pg = {
xhr.timeout = 30000; xhr.timeout = 30000;
xhr.responseType = "text"; xhr.responseType = "text";
xhr.open(type, url, true); xhr.open(type, url, true);
xhr.setRequestHeader("token", globalThis.USER_TOKEN); xhr.setRequestHeader("token", cc.find('middleLayer').getComponent('middleLayer').token);
xhr.setRequestHeader("Client-Type", globalThis.CLIENT_TYPE); xhr.setRequestHeader("Client-Type", 'student');
xhr.setRequestHeader("Content-Type", "application/json"); xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = () => { xhr.onreadystatechange = () => {
if (xhr.readyState !== 4) return; if (xhr.readyState !== 4) return;
......
{
"ver": "2.3.5",
"uuid": "96dab226-d041-47e5-8549-068281e523e0",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 82,
"height": 65,
"platformSettings": {},
"subMetas": {
"btn_return": {
"ver": "1.0.4",
"uuid": "cc47e80b-2d35-4cdb-b287-5df9dc415a92",
"rawTextureUuid": "96dab226-d041-47e5-8549-068281e523e0",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 82,
"height": 65,
"rawWidth": 82,
"rawHeight": 65,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ 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