Commit b36879cf authored by liujiaxin's avatar liujiaxin

ff

parent 1d924adf
......@@ -46,9 +46,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
onLoadEnd() {
globalThis.USER_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2Mzk2MjE3MTIsImV4cCI6MTY0MjIxMzcxMiwiaWQiOjQwMDY2LCJwYXNzd29yZCI6IjE5QTEwM0E3NUUzM0QzQTNCODg0QkQxNTUwMjhENTA1Iiwic2Nob29sX2lkIjoyODYsInBob25lIjoiMTMxMDAwMDAwMDAiLCJuYW1lIjoi5bCP546J5rWL6K-VMCIsInN0YXR1cyI6MCwidHlwZSI6MCwicm9sZXMiOjEsImV4cGlyZWQiOiIyMDIyLTAzLTE5VDE2OjAwOjAwLjAwMFoiLCJzY2hvb2xfbmFtZSI6Iue7mOeOqea1i-ivleeOr-Wig-WtpuagoSIsInNjaG9vbF90eXBlIjoyLCJjcmVhdGVvbiI6MTU3MDc2MTk3NDAwMCwiY2xhc3NfbmFtZSI6IuS4ieW5tDHnj60iLCJjbGFzc19pbmZvIjpbeyJjbGFzc19pZCI6MzkxNSwiY2xhc3NfbmFtZSI6IuS4ieW5tDHnj60ifV0sIm90aGVycyI6W119.4T-Lnsl25aJ-rvUOCDwShq4F5u3BbR86ZLPew4zyULU"
globalThis.CLIENT_TYPE = 'student'
globalThis.SERVER_HOST = 'http://192.168.3.127:3900'
const isLocalDev = window && window.location && window.location.href
// globalThis.USER_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2Mzk2MjE3MTIsImV4cCI6MTY0MjIxMzcxMiwiaWQiOjQwMDY2LCJwYXNzd29yZCI6IjE5QTEwM0E3NUUzM0QzQTNCODg0QkQxNTUwMjhENTA1Iiwic2Nob29sX2lkIjoyODYsInBob25lIjoiMTMxMDAwMDAwMDAiLCJuYW1lIjoi5bCP546J5rWL6K-VMCIsInN0YXR1cyI6MCwidHlwZSI6MCwicm9sZXMiOjEsImV4cGlyZWQiOiIyMDIyLTAzLTE5VDE2OjAwOjAwLjAwMFoiLCJzY2hvb2xfbmFtZSI6Iue7mOeOqea1i-ivleeOr-Wig-WtpuagoSIsInNjaG9vbF90eXBlIjoyLCJjcmVhdGVvbiI6MTU3MDc2MTk3NDAwMCwiY2xhc3NfbmFtZSI6IuS4ieW5tDHnj60iLCJjbGFzc19pbmZvIjpbeyJjbGFzc19pZCI6MzkxNSwiY2xhc3NfbmFtZSI6IuS4ieW5tDHnj60ifV0sIm90aGVycyI6W119.4T-Lnsl25aJ-rvUOCDwShq4F5u3BbR86ZLPew4zyULU"
// globalThis.CLIENT_TYPE = 'student'
// globalThis.SERVER_HOST = 'http://192.168.3.127:3900'
globalThis.____GAME_ENV____ = {
baseUrl: isLocalDev ? 'http://192.168.3.127:3900/api/' : cc.find('middleLayer').getComponent('middleLayer').baseUrl,
token: isLocalDev
? "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2Mzk2MjE3MTIsImV4cCI6MTY0MjIxMzcxMiwiaWQiOjQwMDY2LCJwYXNzd29yZCI6IjE5QTEwM0E3NUUzM0QzQTNCODg0QkQxNTUwMjhENTA1Iiwic2Nob29sX2lkIjoyODYsInBob25lIjoiMTMxMDAwMDAwMDAiLCJuYW1lIjoi5bCP546J5rWL6K-VMCIsInN0YXR1cyI6MCwidHlwZSI6MCwicm9sZXMiOjEsImV4cGlyZWQiOiIyMDIyLTAzLTE5VDE2OjAwOjAwLjAwMFoiLCJzY2hvb2xfbmFtZSI6Iue7mOeOqea1i-ivleeOr-Wig-WtpuagoSIsInNjaG9vbF90eXBlIjoyLCJjcmVhdGVvbiI6MTU3MDc2MTk3NDAwMCwiY2xhc3NfbmFtZSI6IuS4ieW5tDHnj60iLCJjbGFzc19pbmZvIjpbeyJjbGFzc19pZCI6MzkxNSwiY2xhc3NfbmFtZSI6IuS4ieW5tDHnj60ifV0sIm90aGVycyI6W119.4T-Lnsl25aJ-rvUOCDwShq4F5u3BbR86ZLPew4zyULU"
: cc.find('middleLayer').getComponent('middleLayer').token
}
// globalThis.SERVER_HOST = 'http://staging.ireadabc.com'
this.initGame();
......
......@@ -4,11 +4,12 @@ import user from "../model/user";
import kitchen from "../model/kitchen";
import shop from "../model/shop";
//获取信息,购买物品,使用物品(吃东西),穿戴衣服/更换家具
class Api {
static askUser() {
return new Promise((resolve, reject) => {
console.log(`[askUser] ${cc.find('middleLayer').getComponent('middleLayer').baseUrl}/pets/info`)
pg.http.send("GET", `${cc.find('middleLayer').getComponent('middleLayer').baseUrl}pets/info`, null).then((userInfo: any) => {
console.log(`[askUser] ${ globalThis.____GAME_ENV____.baseUrl}/pets/info`)
pg.http.send("GET", `${ globalThis.____GAME_ENV____.baseUrl}pets/info`, null).then((userInfo: any) => {
// let userInfo = USER;
try{
const mood = (Date.now() - userInfo.status.eat.time) > 4 * 60 * 60 * 1000 ? 1: 0; // 4 hours
......@@ -39,7 +40,7 @@ class Api {
}
static askUseItem(data) {
return new Promise((resolve, reject) => {
pg.http.send("POST", `${cc.find('middleLayer').getComponent('middleLayer').baseUrl}pets/use/item`, {item_id: data.id}).then((resp: any) => {
pg.http.send("POST", `${ globalThis.____GAME_ENV____.baseUrl}pets/use/item`, {item_id: data.id}).then((resp: any) => {
// user.addGrowth(data.growthValue);
// kitchen.use(data.id);
try {
......@@ -56,7 +57,7 @@ class Api {
return new Promise((resolve, reject) => {
data.id;
data.type;
pg.http.send("POST", `${cc.find('middleLayer').getComponent('middleLayer').baseUrl}pets/item/buy`, {item_id: data.id}).then((resp: any) => {
pg.http.send("POST", `${ globalThis.____GAME_ENV____.baseUrl}pets/item/buy`, {item_id: data.id}).then((resp: any) => {
// user.useCoin(data.cost * data.discount);
// kitchen.buy(data.id);
try {
......
......@@ -340,7 +340,7 @@ let pg = {
xhr.timeout = 30000;
xhr.responseType = "text";
xhr.open(type, url, true);
xhr.setRequestHeader("token", cc.find('middleLayer').getComponent('middleLayer').token);
xhr.setRequestHeader("token", globalThis.____GAME_ENV____.token);
xhr.setRequestHeader("Client-Type", 'student');
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = () => {
......
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