Commit a6ff0b94 authored by Edwise's avatar Edwise 🍷

1234

parent 63e996f8
{
"success": false,
"message":"请稍后重试",
"data": "aaaa",
"code": "000"
}
\ No newline at end of file
{
"success": true,
"message":"",
"data": {
"catType": 1,
"userNick": "Edwise",
"energy": "100",
"happyCoin": "1000",
"experience": "50",
"level": "1",
"avatar": "https://yun.duiba.com.cn/spark/assets/b1992c528b36c2d26942e9c83941242e59481475.png",
"sence": 1,
"catName": "喵喵喵"
}
}
\ No newline at end of file
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
import { layers } from "../views/layers"; import { layers } from "../views/layers";
import { RES } from "../RES"; import { RES } from "../RES";
import resCanvasList from "../../resCanvasList.js"
import { Ins } from "../../src/Ins";
let inited = false; let inited = false;
let _toast: Toast; let _toast: Toast;
...@@ -14,14 +16,14 @@ const initToast = () => { ...@@ -14,14 +16,14 @@ const initToast = () => {
_toast = new Toast(); _toast = new Toast();
_parent = layers.toastLayer; _parent = layers.toastLayer;
_toast.alpha = 0; _toast.alpha = 0;
_toast.x = layers.stageOffsetX - _parent.x + (layers.stageWidth - _toast.width) / 2; _toast.x = (layers.stageWidth - _toast.width) / 2;
var h = _toast.height; var h = _toast.height;
var y = layers.stageOffsetY - _parent.y; var y = layers.stageOffsetY - _parent.y;
startY = y - h; startY = y - h;
endY = y + (layers.stageHeight - h) / 2; endY = y + (layers.stageHeight - h) / 2;
} }
} }
export const showToast = (msg: string) => { export const showToast = (msg="网络异常,请稍后重试~") => {
initToast(); initToast();
_toast.show(msg) _toast.show(msg)
_parent.addChild(_toast); _parent.addChild(_toast);
...@@ -56,14 +58,18 @@ class Toast extends FYGE.Container { ...@@ -56,14 +58,18 @@ class Toast extends FYGE.Container {
msg: FYGE.TextField; msg: FYGE.TextField;
bg: FYGE.Sprite; bg: FYGE.Sprite;
PADDING = 40; PADDING = 40;
bgw:number;
constructor() { constructor() {
super(); super();
this.mouseChildren = false; this.mouseChildren = false;
this.mouseEnable = false; this.mouseEnable = false;
var toastBgTexture: FYGE.Texture = RES.getRes("toastBg.png"); // var toastBgTexture: FYGE.Texture = RES.getRes("toastBg.png");
var toastBgTexture: FYGE.Texture = RES.getRes(resCanvasList["0cc64b0c-3ccc-4d88-b697-bb402319cef7"].url);
if (toastBgTexture) { if (toastBgTexture) {
this.bg = new FYGE.Sprite(toastBgTexture); this.bg = new FYGE.Sprite(toastBgTexture);
// this.bg.x = (750 - 460) / 2// (layers.stageWidth - this.bg.width) / 2 // this.bg.x = (750 - 460) / 2// (layers.stageWidth - this.bg.width) / 2
// this.bgw = this.bg.width
this.bg.x = (layers.stageWidth - this.bg.width) / 2
this.addChild(this.bg); this.addChild(this.bg);
} }
...@@ -83,11 +89,12 @@ class Toast extends FYGE.Container { ...@@ -83,11 +89,12 @@ class Toast extends FYGE.Container {
show(msg: string) { show(msg: string) {
this.msg.text = msg; this.msg.text = msg;
//文本居中适配 //文本居中适配
this.msg.x = ( (this.bg?this.bg.width:0) - this.msg.textWidth) / 2//(layers.stageWidth - this.msg.textWidth) / 2; this.msg.x = (layers.stageWidth - this.msg.textWidth) / 2;//( (this.bg?this.bg.width:0) - this.msg.textWidth) / 2
//是否需要根据文本宽度缩放背景 // // 是否需要根据文本宽度缩放背景
// this.bg.width = Math.min(this.msg.textWidth + this.PADDING * 2, 523); this.bg.width = Math.min(this.msg.textWidth + this.PADDING * 2, 523);
//背景居中适配,由于上面一行注释,那这行就构造函数里只执行一次吧 // 背景居中适配,由于上面一行注释,那这行就构造函数里只执行一次吧
// this.bg.x = (layers.stageWidth - this.bg.width) / 2 this.bg.x = (Ins.stageW - this.bg.width) / 2
// console.log(Ins.stageW,this.bg.width)
} }
destroy() { destroy() {
......
...@@ -681,6 +681,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); ...@@ -681,6 +681,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.destroyToast = exports.showToast = void 0; exports.destroyToast = exports.showToast = void 0;
var layers_1 = __webpack_require__(/*! ../views/layers */ "./module/views/layers.ts"); var layers_1 = __webpack_require__(/*! ../views/layers */ "./module/views/layers.ts");
var RES_1 = __webpack_require__(/*! ../RES */ "./module/RES.ts"); var RES_1 = __webpack_require__(/*! ../RES */ "./module/RES.ts");
var resCanvasList_js_1 = __webpack_require__(/*! ../../resCanvasList.js */ "./resCanvasList.js");
var Ins_1 = __webpack_require__(/*! ../../src/Ins */ "./src/Ins.ts");
var inited = false; var inited = false;
var _toast; var _toast;
var _parent; var _parent;
...@@ -692,7 +694,7 @@ var initToast = function () { ...@@ -692,7 +694,7 @@ var initToast = function () {
_toast = new Toast(); _toast = new Toast();
_parent = layers_1.layers.toastLayer; _parent = layers_1.layers.toastLayer;
_toast.alpha = 0; _toast.alpha = 0;
_toast.x = layers_1.layers.stageOffsetX - _parent.x + (layers_1.layers.stageWidth - _toast.width) / 2; _toast.x = (layers_1.layers.stageWidth - _toast.width) / 2;
var h = _toast.height; var h = _toast.height;
var y = layers_1.layers.stageOffsetY - _parent.y; var y = layers_1.layers.stageOffsetY - _parent.y;
startY = y - h; startY = y - h;
...@@ -700,6 +702,7 @@ var initToast = function () { ...@@ -700,6 +702,7 @@ var initToast = function () {
} }
}; };
exports.showToast = function (msg) { exports.showToast = function (msg) {
if (msg === void 0) { msg = "网络异常,请稍后重试~"; }
initToast(); initToast();
_toast.show(msg); _toast.show(msg);
_parent.addChild(_toast); _parent.addChild(_toast);
...@@ -728,9 +731,10 @@ var Toast = (function (_super) { ...@@ -728,9 +731,10 @@ var Toast = (function (_super) {
_this.PADDING = 40; _this.PADDING = 40;
_this.mouseChildren = false; _this.mouseChildren = false;
_this.mouseEnable = false; _this.mouseEnable = false;
var toastBgTexture = RES_1.RES.getRes("toastBg.png"); var toastBgTexture = RES_1.RES.getRes(resCanvasList_js_1.default["0cc64b0c-3ccc-4d88-b697-bb402319cef7"].url);
if (toastBgTexture) { if (toastBgTexture) {
_this.bg = new FYGE.Sprite(toastBgTexture); _this.bg = new FYGE.Sprite(toastBgTexture);
_this.bg.x = (layers_1.layers.stageWidth - _this.bg.width) / 2;
_this.addChild(_this.bg); _this.addChild(_this.bg);
} }
_this.msg = new FYGE.TextField(); _this.msg = new FYGE.TextField();
...@@ -745,7 +749,9 @@ var Toast = (function (_super) { ...@@ -745,7 +749,9 @@ var Toast = (function (_super) {
} }
Toast.prototype.show = function (msg) { Toast.prototype.show = function (msg) {
this.msg.text = msg; this.msg.text = msg;
this.msg.x = ((this.bg ? this.bg.width : 0) - this.msg.textWidth) / 2; this.msg.x = (layers_1.layers.stageWidth - this.msg.textWidth) / 2;
this.bg.width = Math.min(this.msg.textWidth + this.PADDING * 2, 523);
this.bg.x = (Ins_1.Ins.stageW - this.bg.width) / 2;
}; };
Toast.prototype.destroy = function () { Toast.prototype.destroy = function () {
_super.prototype.destroy.call(this); _super.prototype.destroy.call(this);
...@@ -1856,6 +1862,12 @@ const resCanvasList = { ...@@ -1856,6 +1862,12 @@ const resCanvasList = {
ext: '.jpg', ext: '.jpg',
url: 'https://yun.duiba.com.cn/spark/assets/寝室1.e9238ec5e71c328817026128dd0f41fdc65203f4.jpg', url: 'https://yun.duiba.com.cn/spark/assets/寝室1.e9238ec5e71c328817026128dd0f41fdc65203f4.jpg',
uuid: 'b3c8c187-e5c9-4968-9a00-a118d18ab2fc' uuid: 'b3c8c187-e5c9-4968-9a00-a118d18ab2fc'
},
'0cc64b0c-3ccc-4d88-b697-bb402319cef7': {
name: 'ToastBg',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/ToastBg.81e208c0050ce46ac576ba881d02db07a02bffe2.png',
uuid: '0cc64b0c-3ccc-4d88-b697-bb402319cef7'
} }
}; };
/* harmony default export */ __webpack_exports__["default"] = (resCanvasList); /* harmony default export */ __webpack_exports__["default"] = (resCanvasList);
...@@ -1973,6 +1985,7 @@ var MSG; ...@@ -1973,6 +1985,7 @@ var MSG;
MSG["CHANGE_SCENE"] = "CHANGE_SCENE"; MSG["CHANGE_SCENE"] = "CHANGE_SCENE";
MSG["SELECT_CAT"] = "SELECT_CAT"; MSG["SELECT_CAT"] = "SELECT_CAT";
MSG["CAT_ACT"] = "CAT_ACT"; MSG["CAT_ACT"] = "CAT_ACT";
MSG["UPDATE_USERINFO"] = "UPDATE_USERINFO";
})(MSG = exports.MSG || (exports.MSG = {})); })(MSG = exports.MSG || (exports.MSG = {}));
var CATTYPE; var CATTYPE;
(function (CATTYPE) { (function (CATTYPE) {
...@@ -2262,6 +2275,8 @@ var TbNetName; ...@@ -2262,6 +2275,8 @@ var TbNetName;
(function (TbNetName) { (function (TbNetName) {
TbNetName["navigateToPage"] = "mine.navigateToPage"; TbNetName["navigateToPage"] = "mine.navigateToPage";
TbNetName["showModal"] = "mine.showModal"; TbNetName["showModal"] = "mine.showModal";
TbNetName["getUserInfo"] = "tmallCat.getUserInfo";
TbNetName["interaction"] = "tamllCat.interaction";
TbNetName["trackingReport"] = "squirrelsAdoptRest2c.trackingReport"; TbNetName["trackingReport"] = "squirrelsAdoptRest2c.trackingReport";
TbNetName["getActivityBaseInfoById"] = "bubbleSurviva.getActivityBaseInfoById"; TbNetName["getActivityBaseInfoById"] = "bubbleSurviva.getActivityBaseInfoById";
TbNetName["getGameInfo"] = "babycare.getGameInfo"; TbNetName["getGameInfo"] = "babycare.getGameInfo";
...@@ -2442,6 +2457,7 @@ var xianluomao01_1 = __webpack_require__(/*! ../lottieSrc/lottieTs/xianluoCat/xi ...@@ -2442,6 +2457,7 @@ var xianluomao01_1 = __webpack_require__(/*! ../lottieSrc/lottieTs/xianluoCat/xi
var xianluoshuohua_1 = __webpack_require__(/*! ../lottieSrc/lottieTs/xianluoCat/xianluoshuohua */ "./src/lottieSrc/lottieTs/xianluoCat/xianluoshuohua.ts"); var xianluoshuohua_1 = __webpack_require__(/*! ../lottieSrc/lottieTs/xianluoCat/xianluoshuohua */ "./src/lottieSrc/lottieTs/xianluoCat/xianluoshuohua.ts");
var Enum_1 = __webpack_require__(/*! ../Enum */ "./src/Enum.ts"); var Enum_1 = __webpack_require__(/*! ../Enum */ "./src/Enum.ts");
var Ins_1 = __webpack_require__(/*! ../Ins */ "./src/Ins.ts"); var Ins_1 = __webpack_require__(/*! ../Ins */ "./src/Ins.ts");
var TaoBaoNet_1 = __webpack_require__(/*! ../TaoBaoNet */ "./src/TaoBaoNet.ts");
var Cat = (function (_super) { var Cat = (function (_super) {
__extends(Cat, _super); __extends(Cat, _super);
function Cat(data) { function Cat(data) {
...@@ -2541,14 +2557,21 @@ var Cat = (function (_super) { ...@@ -2541,14 +2557,21 @@ var Cat = (function (_super) {
var that = this; var that = this;
var actType = e.data; var actType = e.data;
console.log(actType); console.log(actType);
this.actRunning = true; TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.interaction, {}, function (s, r) {
switch (actType) { if (s) {
case Enum_1.CAT_ACTTYPEP.SLEEP: that.actRunning = true;
break; switch (actType) {
default: case Enum_1.CAT_ACTTYPEP.SLEEP:
that.setCatAnimShow(actType, function () { that.setCatAnimShow(0, null); }); break;
break; default:
} that.setCatAnimShow(actType, function () { that.setCatAnimShow(0, null); });
break;
}
}
else {
FYGE.GDispatcher.dispatchEvent("23", r.message);
}
});
}; };
Cat.prototype.initEvents = function () { Cat.prototype.initEvents = function () {
FYGE.GDispatcher.addEventListener(Enum_1.MSG.CAT_ACT, this.catAct, this); FYGE.GDispatcher.addEventListener(Enum_1.MSG.CAT_ACT, this.catAct, this);
...@@ -44746,6 +44769,7 @@ var MainSceneBtnUi = (function (_super) { ...@@ -44746,6 +44769,7 @@ var MainSceneBtnUi = (function (_super) {
MainSceneBtnUi.prototype.touchHandler = function (e) { MainSceneBtnUi.prototype.touchHandler = function (e) {
console.log(e.target); console.log(e.target);
var that = this; var that = this;
that.btnDelay(e.target);
if (e.target == that.returnBtn) { if (e.target == that.returnBtn) {
that.returnBedRoom(); that.returnBedRoom();
} }
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -683,6 +683,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); ...@@ -683,6 +683,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.destroyToast = exports.showToast = void 0; exports.destroyToast = exports.showToast = void 0;
var layers_1 = __webpack_require__(/*! ../views/layers */ "./module/views/layers.ts"); var layers_1 = __webpack_require__(/*! ../views/layers */ "./module/views/layers.ts");
var RES_1 = __webpack_require__(/*! ../RES */ "./module/RES.ts"); var RES_1 = __webpack_require__(/*! ../RES */ "./module/RES.ts");
var resCanvasList_js_1 = __webpack_require__(/*! ../../resCanvasList.js */ "./resCanvasList.js");
var Ins_1 = __webpack_require__(/*! ../../src/Ins */ "./src/Ins.ts");
var inited = false; var inited = false;
var _toast; var _toast;
var _parent; var _parent;
...@@ -694,7 +696,7 @@ var initToast = function () { ...@@ -694,7 +696,7 @@ var initToast = function () {
_toast = new Toast(); _toast = new Toast();
_parent = layers_1.layers.toastLayer; _parent = layers_1.layers.toastLayer;
_toast.alpha = 0; _toast.alpha = 0;
_toast.x = layers_1.layers.stageOffsetX - _parent.x + (layers_1.layers.stageWidth - _toast.width) / 2; _toast.x = (layers_1.layers.stageWidth - _toast.width) / 2;
var h = _toast.height; var h = _toast.height;
var y = layers_1.layers.stageOffsetY - _parent.y; var y = layers_1.layers.stageOffsetY - _parent.y;
startY = y - h; startY = y - h;
...@@ -702,6 +704,7 @@ var initToast = function () { ...@@ -702,6 +704,7 @@ var initToast = function () {
} }
}; };
exports.showToast = function (msg) { exports.showToast = function (msg) {
if (msg === void 0) { msg = "网络异常,请稍后重试~"; }
initToast(); initToast();
_toast.show(msg); _toast.show(msg);
_parent.addChild(_toast); _parent.addChild(_toast);
...@@ -730,9 +733,10 @@ var Toast = (function (_super) { ...@@ -730,9 +733,10 @@ var Toast = (function (_super) {
_this.PADDING = 40; _this.PADDING = 40;
_this.mouseChildren = false; _this.mouseChildren = false;
_this.mouseEnable = false; _this.mouseEnable = false;
var toastBgTexture = RES_1.RES.getRes("toastBg.png"); var toastBgTexture = RES_1.RES.getRes(resCanvasList_js_1.default["0cc64b0c-3ccc-4d88-b697-bb402319cef7"].url);
if (toastBgTexture) { if (toastBgTexture) {
_this.bg = new FYGE.Sprite(toastBgTexture); _this.bg = new FYGE.Sprite(toastBgTexture);
_this.bg.x = (layers_1.layers.stageWidth - _this.bg.width) / 2;
_this.addChild(_this.bg); _this.addChild(_this.bg);
} }
_this.msg = new FYGE.TextField(); _this.msg = new FYGE.TextField();
...@@ -747,7 +751,9 @@ var Toast = (function (_super) { ...@@ -747,7 +751,9 @@ var Toast = (function (_super) {
} }
Toast.prototype.show = function (msg) { Toast.prototype.show = function (msg) {
this.msg.text = msg; this.msg.text = msg;
this.msg.x = ((this.bg ? this.bg.width : 0) - this.msg.textWidth) / 2; this.msg.x = (layers_1.layers.stageWidth - this.msg.textWidth) / 2;
this.bg.width = Math.min(this.msg.textWidth + this.PADDING * 2, 523);
this.bg.x = (Ins_1.Ins.stageW - this.bg.width) / 2;
}; };
Toast.prototype.destroy = function () { Toast.prototype.destroy = function () {
_super.prototype.destroy.call(this); _super.prototype.destroy.call(this);
...@@ -1858,6 +1864,12 @@ const resCanvasList = { ...@@ -1858,6 +1864,12 @@ const resCanvasList = {
ext: '.jpg', ext: '.jpg',
url: 'https://yun.duiba.com.cn/spark/assets/寝室1.e9238ec5e71c328817026128dd0f41fdc65203f4.jpg', url: 'https://yun.duiba.com.cn/spark/assets/寝室1.e9238ec5e71c328817026128dd0f41fdc65203f4.jpg',
uuid: 'b3c8c187-e5c9-4968-9a00-a118d18ab2fc' uuid: 'b3c8c187-e5c9-4968-9a00-a118d18ab2fc'
},
'0cc64b0c-3ccc-4d88-b697-bb402319cef7': {
name: 'ToastBg',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/ToastBg.81e208c0050ce46ac576ba881d02db07a02bffe2.png',
uuid: '0cc64b0c-3ccc-4d88-b697-bb402319cef7'
} }
}; };
/* harmony default export */ __webpack_exports__["default"] = (resCanvasList); /* harmony default export */ __webpack_exports__["default"] = (resCanvasList);
...@@ -1975,6 +1987,7 @@ var MSG; ...@@ -1975,6 +1987,7 @@ var MSG;
MSG["CHANGE_SCENE"] = "CHANGE_SCENE"; MSG["CHANGE_SCENE"] = "CHANGE_SCENE";
MSG["SELECT_CAT"] = "SELECT_CAT"; MSG["SELECT_CAT"] = "SELECT_CAT";
MSG["CAT_ACT"] = "CAT_ACT"; MSG["CAT_ACT"] = "CAT_ACT";
MSG["UPDATE_USERINFO"] = "UPDATE_USERINFO";
})(MSG = exports.MSG || (exports.MSG = {})); })(MSG = exports.MSG || (exports.MSG = {}));
var CATTYPE; var CATTYPE;
(function (CATTYPE) { (function (CATTYPE) {
...@@ -2264,6 +2277,8 @@ var TbNetName; ...@@ -2264,6 +2277,8 @@ var TbNetName;
(function (TbNetName) { (function (TbNetName) {
TbNetName["navigateToPage"] = "mine.navigateToPage"; TbNetName["navigateToPage"] = "mine.navigateToPage";
TbNetName["showModal"] = "mine.showModal"; TbNetName["showModal"] = "mine.showModal";
TbNetName["getUserInfo"] = "tmallCat.getUserInfo";
TbNetName["interaction"] = "tamllCat.interaction";
TbNetName["trackingReport"] = "squirrelsAdoptRest2c.trackingReport"; TbNetName["trackingReport"] = "squirrelsAdoptRest2c.trackingReport";
TbNetName["getActivityBaseInfoById"] = "bubbleSurviva.getActivityBaseInfoById"; TbNetName["getActivityBaseInfoById"] = "bubbleSurviva.getActivityBaseInfoById";
TbNetName["getGameInfo"] = "babycare.getGameInfo"; TbNetName["getGameInfo"] = "babycare.getGameInfo";
...@@ -2444,6 +2459,7 @@ var xianluomao01_1 = __webpack_require__(/*! ../lottieSrc/lottieTs/xianluoCat/xi ...@@ -2444,6 +2459,7 @@ var xianluomao01_1 = __webpack_require__(/*! ../lottieSrc/lottieTs/xianluoCat/xi
var xianluoshuohua_1 = __webpack_require__(/*! ../lottieSrc/lottieTs/xianluoCat/xianluoshuohua */ "./src/lottieSrc/lottieTs/xianluoCat/xianluoshuohua.ts"); var xianluoshuohua_1 = __webpack_require__(/*! ../lottieSrc/lottieTs/xianluoCat/xianluoshuohua */ "./src/lottieSrc/lottieTs/xianluoCat/xianluoshuohua.ts");
var Enum_1 = __webpack_require__(/*! ../Enum */ "./src/Enum.ts"); var Enum_1 = __webpack_require__(/*! ../Enum */ "./src/Enum.ts");
var Ins_1 = __webpack_require__(/*! ../Ins */ "./src/Ins.ts"); var Ins_1 = __webpack_require__(/*! ../Ins */ "./src/Ins.ts");
var TaoBaoNet_1 = __webpack_require__(/*! ../TaoBaoNet */ "./src/TaoBaoNet.ts");
var Cat = (function (_super) { var Cat = (function (_super) {
__extends(Cat, _super); __extends(Cat, _super);
function Cat(data) { function Cat(data) {
...@@ -2543,14 +2559,21 @@ var Cat = (function (_super) { ...@@ -2543,14 +2559,21 @@ var Cat = (function (_super) {
var that = this; var that = this;
var actType = e.data; var actType = e.data;
console.log(actType); console.log(actType);
this.actRunning = true; TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.interaction, {}, function (s, r) {
switch (actType) { if (s) {
case Enum_1.CAT_ACTTYPEP.SLEEP: that.actRunning = true;
break; switch (actType) {
default: case Enum_1.CAT_ACTTYPEP.SLEEP:
that.setCatAnimShow(actType, function () { that.setCatAnimShow(0, null); }); break;
break; default:
} that.setCatAnimShow(actType, function () { that.setCatAnimShow(0, null); });
break;
}
}
else {
FYGE.GDispatcher.dispatchEvent("23", r.message);
}
});
}; };
Cat.prototype.initEvents = function () { Cat.prototype.initEvents = function () {
FYGE.GDispatcher.addEventListener(Enum_1.MSG.CAT_ACT, this.catAct, this); FYGE.GDispatcher.addEventListener(Enum_1.MSG.CAT_ACT, this.catAct, this);
...@@ -44748,6 +44771,7 @@ var MainSceneBtnUi = (function (_super) { ...@@ -44748,6 +44771,7 @@ var MainSceneBtnUi = (function (_super) {
MainSceneBtnUi.prototype.touchHandler = function (e) { MainSceneBtnUi.prototype.touchHandler = function (e) {
console.log(e.target); console.log(e.target);
var that = this; var that = this;
that.btnDelay(e.target);
if (e.target == that.returnBtn) { if (e.target == that.returnBtn) {
that.returnBedRoom(); that.returnBedRoom();
} }
...@@ -3,52 +3,7 @@ ...@@ -3,52 +3,7 @@
{ {
"keys": "comCloseBtn.png,toastBg.png,waitingBg.png,waitingRot.png", "keys": "comCloseBtn.png,toastBg.png,waitingBg.png,waitingRot.png",
"name": "common", "name": "common",
"atlas": { "atlas": "common.json"
"comCloseBtn.png": {
"x": 646,
"y": 60,
"w": 48,
"h": 48,
"ox": 0,
"oy": 0,
"sw": 48,
"sh": 48,
"ro": false
},
"toastBg.png": {
"x": 184,
"y": 2,
"w": 460,
"h": 130,
"ox": 0,
"oy": 0,
"sw": 460,
"sh": 130,
"ro": false
},
"waitingBg.png": {
"x": 2,
"y": 2,
"w": 160,
"h": 180,
"ox": 0,
"oy": 0,
"sw": 160,
"sh": 180,
"ro": true
},
"waitingRot.png": {
"x": 646,
"y": 2,
"w": 56,
"h": 56,
"ox": 0,
"oy": 0,
"sw": 56,
"sh": 56,
"ro": false
}
}
}, },
{ {
"keys": "map_bg1.jpg", "keys": "map_bg1.jpg",
......
...@@ -628,6 +628,18 @@ const resCanvasList = { ...@@ -628,6 +628,18 @@ const resCanvasList = {
ext: '.jpg', ext: '.jpg',
url: 'https://yun.duiba.com.cn/spark/assets/寝室1.e9238ec5e71c328817026128dd0f41fdc65203f4.jpg', url: 'https://yun.duiba.com.cn/spark/assets/寝室1.e9238ec5e71c328817026128dd0f41fdc65203f4.jpg',
uuid: 'b3c8c187-e5c9-4968-9a00-a118d18ab2fc' uuid: 'b3c8c187-e5c9-4968-9a00-a118d18ab2fc'
},
'0cc64b0c-3ccc-4d88-b697-bb402319cef7': {
name: 'ToastBg',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/ToastBg.81e208c0050ce46ac576ba881d02db07a02bffe2.png',
uuid: '0cc64b0c-3ccc-4d88-b697-bb402319cef7'
},
'69009eb9-4593-4a43-a9d7-a6356ebd6d04': {
name: '精力条对话框',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/精力条对话框.da8e059d18cf967026989e3c376b7364210c3d4e.png',
uuid: '69009eb9-4593-4a43-a9d7-a6356ebd6d04'
} }
}; };
export default resCanvasList; export default resCanvasList;
...@@ -15,7 +15,9 @@ export enum MSG{ ...@@ -15,7 +15,9 @@ export enum MSG{
/**选择猫咪 */ /**选择猫咪 */
SELECT_CAT="SELECT_CAT", SELECT_CAT="SELECT_CAT",
/**猫咪互动 */ /**猫咪互动 */
CAT_ACT="CAT_ACT" CAT_ACT="CAT_ACT",
/**刷新用户领养信息 */
UPDATE_USERINFO = "UPDATE_USERINFO"
} }
/**猫咪类型 */ /**猫咪类型 */
......
...@@ -52,8 +52,8 @@ export class Ins { ...@@ -52,8 +52,8 @@ export class Ins {
label.fillColor = data.color ? data.color : "black"; label.fillColor = data.color ? data.color : "black";
label.size = data.size ? data.size : 24; label.size = data.size ? data.size : 24;
label.x = data.x ? data.x : 0, label.x = data.x ? data.x : 0,
label.y = data.y ? data.y : 0, label.y = data.y ? data.y : 0,
label.text = data.text ? data.text : ""; label.text = data.text ? data.text : "";
return label; return label;
} }
......
...@@ -3,57 +3,12 @@ export const ResJson = { ...@@ -3,57 +3,12 @@ export const ResJson = {
{ {
"keys": "comCloseBtn.png,toastBg.png,waitingBg.png,waitingRot.png", "keys": "comCloseBtn.png,toastBg.png,waitingBg.png,waitingRot.png",
"name": "common", "name": "common",
"atlas": { "atlas": "common.json"
"comCloseBtn.png": {
"x": 646,
"y": 60,
"w": 48,
"h": 48,
"ox": 0,
"oy": 0,
"sw": 48,
"sh": 48,
"ro": false
},
"toastBg.png": {
"x": 184,
"y": 2,
"w": 460,
"h": 130,
"ox": 0,
"oy": 0,
"sw": 460,
"sh": 130,
"ro": false
},
"waitingBg.png": {
"x": 2,
"y": 2,
"w": 160,
"h": 180,
"ox": 0,
"oy": 0,
"sw": 160,
"sh": 180,
"ro": true
},
"waitingRot.png": {
"x": 646,
"y": 2,
"w": 56,
"h": 56,
"ox": 0,
"oy": 0,
"sw": 56,
"sh": 56,
"ro": false
}
}
}, },
{ {
"keys": "map_bg1.jpg", "keys": "map_bg1.jpg",
"name": "startScene" "name": "startScene"
} }
], ],
"path": "https://yun.duiba.com.cn/db_games/activity/babycare_xiaoxiao/1600243346/resource/" "path": "https://yun.duiba.com.cn/db_games/activity/babycare_xiaoxiao/1600743469/resource/"
} }
\ No newline at end of file
...@@ -5,6 +5,17 @@ import { GDispatcher } from "./Main"; ...@@ -5,6 +5,17 @@ import { GDispatcher } from "./Main";
export enum TbNetName { export enum TbNetName {
navigateToPage = "mine.navigateToPage", navigateToPage = "mine.navigateToPage",
showModal = "mine.showModal", showModal = "mine.showModal",
/**
* 获取用户领养信息
*/
getUserInfo = "tmallCat.getUserInfo",
/**
* 猫咪互动
*/
interaction = "tamllCat.interaction",
/** /**
* 埋点统计 到时改名字 * 埋点统计 到时改名字
* activityId params elemType * activityId params elemType
......
...@@ -25,6 +25,8 @@ import { xianluomao01 } from "../lottieSrc/lottieTs/xianluoCat/xianluomao01"; ...@@ -25,6 +25,8 @@ import { xianluomao01 } from "../lottieSrc/lottieTs/xianluoCat/xianluomao01";
import { xianluoshuohua } from "../lottieSrc/lottieTs/xianluoCat/xianluoshuohua"; import { xianluoshuohua } from "../lottieSrc/lottieTs/xianluoCat/xianluoshuohua";
import { CATTYPE, MSG, CAT_ACTTYPEP } from "../Enum"; import { CATTYPE, MSG, CAT_ACTTYPEP } from "../Enum";
import { Ins } from "../Ins"; import { Ins } from "../Ins";
import { sendTbNet, TbNetName } from "../TaoBaoNet";
import { showToast } from "../../module/ctrls";
export class Cat extends Module { export class Cat extends Module {
constructor(data?: any) { constructor(data?: any) {
...@@ -41,7 +43,7 @@ export class Cat extends Module { ...@@ -41,7 +43,7 @@ export class Cat extends Module {
cat_touch: FYGE.Lottie; //摸头 cat_touch: FYGE.Lottie; //摸头
catAnimArr: FYGE.Lottie[] = []; //猫咪lottie实例组 catAnimArr: FYGE.Lottie[] = []; //猫咪lottie实例组
catLottieArr: any //猫咪lottie数据组 catLottieArr: any //猫咪lottie数据组
actRunning:boolean = false; //动效是否进行中,如果动效进行中,无法进行其他动效 actRunning: boolean = false; //动效是否进行中,如果动效进行中,无法进行其他动效
initUi() { initUi() {
this.initCatLottieArr(); this.initCatLottieArr();
...@@ -122,7 +124,7 @@ export class Cat extends Module { ...@@ -122,7 +124,7 @@ export class Cat extends Module {
* 0:睡觉,1:说话,2:梳毛,3:撸猫,4:玩球,5:摸头 * 0:睡觉,1:说话,2:梳毛,3:撸猫,4:玩球,5:摸头
*/ */
setCatAnimShow(index: number, callback?: () => void) { setCatAnimShow(index: number, callback?: () => void) {
if(index == 0||index==1){ if (index == 0 || index == 1) {
this.actRunning = false; this.actRunning = false;
} }
for (let i = 0; i < this.catAnimArr.length; i++) { for (let i = 0; i < this.catAnimArr.length; i++) {
...@@ -142,32 +144,26 @@ export class Cat extends Module { ...@@ -142,32 +144,26 @@ export class Cat extends Module {
/**猫咪互动 */ /**猫咪互动 */
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;
console.log(actType); console.log(actType);
// switch(actType){ sendTbNet(TbNetName.interaction, {}, (s, r) => {
// case CAT_ACTTYPEP.SLEEP: if (s) {
// break; that.actRunning = true;
// case CAT_ACTTYPEP.TALK: switch (actType) {
// break; case CAT_ACTTYPEP.SLEEP:
// case CAT_ACTTYPEP.CLEAR: break;
// break; default:
// case CAT_ACTTYPEP.RUA: that.setCatAnimShow(actType, () => { that.setCatAnimShow(0, null) });
// break; break;
// case CAT_ACTTYPEP.PLAY: }
// break; }else
// case CAT_ACTTYPEP.TOUCH: {
// break; FYGE.GDispatcher.dispatchEvent("23",r.message)
// } }
this.actRunning = true; })
switch (actType) {
case CAT_ACTTYPEP.SLEEP:
break;
default:
that.setCatAnimShow(actType, () => { that.setCatAnimShow(0, null) });
break;
}
} }
......
...@@ -45,6 +45,7 @@ export class MainScene extends Scene{ ...@@ -45,6 +45,7 @@ export class MainScene extends Scene{
var that = this; var that = this;
that.x = (Ins.stageW - 750)>>1; that.x = (Ins.stageW - 750)>>1;
that.y = (Ins.stageH - 1624)>>1; that.y = (Ins.stageH - 1624)>>1;
console.log(that.y);
that.mouseChildren = true; that.mouseChildren = true;
//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"];
...@@ -88,6 +89,12 @@ export class MainScene extends Scene{ ...@@ -88,6 +89,12 @@ export class MainScene extends Scene{
that.energyGroup.addChild(that.energyImg); that.energyGroup.addChild(that.energyImg);
that.energyDeco = Ins.initSprite("0eb9c19f-248e-4bf1-bffb-ea694a94b16f",541,-9); that.energyDeco = Ins.initSprite("0eb9c19f-248e-4bf1-bffb-ea694a94b16f",541,-9);
that.energyGroup.addChild(that.energyDeco); that.energyGroup.addChild(that.energyDeco);
that.energyDialog = Ins.initSprite("69009eb9-4593-4a43-a9d7-a6356ebd6d04",174,-60);
that.energyGroup.addChild(that.energyDialog);
that.energyDialogLabel = Ins.initLabel({size:26,text:"每5分钟恢复10点精力"});
that.energyDialog.addChild(that.energyDialogLabel);
that.energyDialogLabel.x = (that.energyDialog.width - that.energyDialogLabel.textWidth)*0.5;
that.energyDialogLabel.y = (that.energyDialog.height - that.energyDialogLabel.textHeight)*0.5-2;
var mask = new FYGE.Shape(); var mask = new FYGE.Shape();
mask.beginFill(6,1); mask.beginFill(6,1);
mask.drawRoundedRect(0,0,that.energyImg.width,that.energyImg.height,38,38,38,38); mask.drawRoundedRect(0,0,that.energyImg.width,that.energyImg.height,38,38,38,38);
......
...@@ -5,8 +5,9 @@ import Root from "./Root"; ...@@ -5,8 +5,9 @@ import Root from "./Root";
import resCanvasList from "../../../game/resCanvasList" import resCanvasList from "../../../game/resCanvasList"
import { MainScene } from "./MainScene"; import { MainScene } from "./MainScene";
import { Ins } from "../Ins"; import { Ins } from "../Ins";
import { showPanel } from "../../module/ctrls"; import { showPanel, showToast } from "../../module/ctrls";
import { SelectCatPanel } from "../panels/selectcatpanel/SelectCatPanel"; import { SelectCatPanel } from "../panels/selectcatpanel/SelectCatPanel";
import { sendTbNet, TbNetName } from "../TaoBaoNet";
export class StartScene extends Scene { export class StartScene extends Scene {
initUi() { initUi() {
super.initUi(); super.initUi();
...@@ -15,7 +16,21 @@ export class StartScene extends Scene { ...@@ -15,7 +16,21 @@ export class StartScene extends Scene {
this.x = (Ins.stageW - 750)>>1; this.x = (Ins.stageW - 750)>>1;
this.y = (Ins.stageH - 1624)>>1; this.y = (Ins.stageH - 1624)>>1;
showPanel(SelectCatPanel); sendTbNet(TbNetName.getUserInfo,{},(s,r)=>{
if(s){
if(r.data){
Ins.userInfo = r.data;
this.addChild(new MainScene());
}else
{
showPanel(SelectCatPanel);
}
}else
{
showToast(r.message)
}
})
// this.addChild(new MainScene()); // this.addChild(new MainScene());
} }
......
...@@ -153,6 +153,7 @@ export class MainSceneBtnUi extends Module { ...@@ -153,6 +153,7 @@ export class MainSceneBtnUi extends Module {
touchHandler(e: FYGE.MouseEvent) { touchHandler(e: FYGE.MouseEvent) {
console.log(e.target); console.log(e.target);
var that = this; var that = this;
that.btnDelay(e.target);
if (e.target == that.returnBtn) { if (e.target == that.returnBtn) {
that.returnBedRoom(); that.returnBedRoom();
} else { } else {
......
...@@ -683,6 +683,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); ...@@ -683,6 +683,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.destroyToast = exports.showToast = void 0; exports.destroyToast = exports.showToast = void 0;
var layers_1 = __webpack_require__(/*! ../views/layers */ "./module/views/layers.ts"); var layers_1 = __webpack_require__(/*! ../views/layers */ "./module/views/layers.ts");
var RES_1 = __webpack_require__(/*! ../RES */ "./module/RES.ts"); var RES_1 = __webpack_require__(/*! ../RES */ "./module/RES.ts");
var resCanvasList_js_1 = __webpack_require__(/*! ../../resCanvasList.js */ "./resCanvasList.js");
var Ins_1 = __webpack_require__(/*! ../../src/Ins */ "./src/Ins.ts");
var inited = false; var inited = false;
var _toast; var _toast;
var _parent; var _parent;
...@@ -694,7 +696,7 @@ var initToast = function () { ...@@ -694,7 +696,7 @@ var initToast = function () {
_toast = new Toast(); _toast = new Toast();
_parent = layers_1.layers.toastLayer; _parent = layers_1.layers.toastLayer;
_toast.alpha = 0; _toast.alpha = 0;
_toast.x = layers_1.layers.stageOffsetX - _parent.x + (layers_1.layers.stageWidth - _toast.width) / 2; _toast.x = (layers_1.layers.stageWidth - _toast.width) / 2;
var h = _toast.height; var h = _toast.height;
var y = layers_1.layers.stageOffsetY - _parent.y; var y = layers_1.layers.stageOffsetY - _parent.y;
startY = y - h; startY = y - h;
...@@ -702,6 +704,7 @@ var initToast = function () { ...@@ -702,6 +704,7 @@ var initToast = function () {
} }
}; };
exports.showToast = function (msg) { exports.showToast = function (msg) {
if (msg === void 0) { msg = "网络异常,请稍后重试~"; }
initToast(); initToast();
_toast.show(msg); _toast.show(msg);
_parent.addChild(_toast); _parent.addChild(_toast);
...@@ -730,9 +733,10 @@ var Toast = (function (_super) { ...@@ -730,9 +733,10 @@ var Toast = (function (_super) {
_this.PADDING = 40; _this.PADDING = 40;
_this.mouseChildren = false; _this.mouseChildren = false;
_this.mouseEnable = false; _this.mouseEnable = false;
var toastBgTexture = RES_1.RES.getRes("toastBg.png"); var toastBgTexture = RES_1.RES.getRes(resCanvasList_js_1.default["0cc64b0c-3ccc-4d88-b697-bb402319cef7"].url);
if (toastBgTexture) { if (toastBgTexture) {
_this.bg = new FYGE.Sprite(toastBgTexture); _this.bg = new FYGE.Sprite(toastBgTexture);
_this.bg.x = (layers_1.layers.stageWidth - _this.bg.width) / 2;
_this.addChild(_this.bg); _this.addChild(_this.bg);
} }
_this.msg = new FYGE.TextField(); _this.msg = new FYGE.TextField();
...@@ -747,7 +751,9 @@ var Toast = (function (_super) { ...@@ -747,7 +751,9 @@ var Toast = (function (_super) {
} }
Toast.prototype.show = function (msg) { Toast.prototype.show = function (msg) {
this.msg.text = msg; this.msg.text = msg;
this.msg.x = ((this.bg ? this.bg.width : 0) - this.msg.textWidth) / 2; this.msg.x = (layers_1.layers.stageWidth - this.msg.textWidth) / 2;
this.bg.width = Math.min(this.msg.textWidth + this.PADDING * 2, 523);
this.bg.x = (Ins_1.Ins.stageW - this.bg.width) / 2;
}; };
Toast.prototype.destroy = function () { Toast.prototype.destroy = function () {
_super.prototype.destroy.call(this); _super.prototype.destroy.call(this);
...@@ -1858,6 +1864,12 @@ const resCanvasList = { ...@@ -1858,6 +1864,12 @@ const resCanvasList = {
ext: '.jpg', ext: '.jpg',
url: 'https://yun.duiba.com.cn/spark/assets/寝室1.e9238ec5e71c328817026128dd0f41fdc65203f4.jpg', url: 'https://yun.duiba.com.cn/spark/assets/寝室1.e9238ec5e71c328817026128dd0f41fdc65203f4.jpg',
uuid: 'b3c8c187-e5c9-4968-9a00-a118d18ab2fc' uuid: 'b3c8c187-e5c9-4968-9a00-a118d18ab2fc'
},
'0cc64b0c-3ccc-4d88-b697-bb402319cef7': {
name: 'ToastBg',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/ToastBg.81e208c0050ce46ac576ba881d02db07a02bffe2.png',
uuid: '0cc64b0c-3ccc-4d88-b697-bb402319cef7'
} }
}; };
/* harmony default export */ __webpack_exports__["default"] = (resCanvasList); /* harmony default export */ __webpack_exports__["default"] = (resCanvasList);
...@@ -1975,6 +1987,7 @@ var MSG; ...@@ -1975,6 +1987,7 @@ var MSG;
MSG["CHANGE_SCENE"] = "CHANGE_SCENE"; MSG["CHANGE_SCENE"] = "CHANGE_SCENE";
MSG["SELECT_CAT"] = "SELECT_CAT"; MSG["SELECT_CAT"] = "SELECT_CAT";
MSG["CAT_ACT"] = "CAT_ACT"; MSG["CAT_ACT"] = "CAT_ACT";
MSG["UPDATE_USERINFO"] = "UPDATE_USERINFO";
})(MSG = exports.MSG || (exports.MSG = {})); })(MSG = exports.MSG || (exports.MSG = {}));
var CATTYPE; var CATTYPE;
(function (CATTYPE) { (function (CATTYPE) {
...@@ -2264,6 +2277,8 @@ var TbNetName; ...@@ -2264,6 +2277,8 @@ var TbNetName;
(function (TbNetName) { (function (TbNetName) {
TbNetName["navigateToPage"] = "mine.navigateToPage"; TbNetName["navigateToPage"] = "mine.navigateToPage";
TbNetName["showModal"] = "mine.showModal"; TbNetName["showModal"] = "mine.showModal";
TbNetName["getUserInfo"] = "tmallCat.getUserInfo";
TbNetName["interaction"] = "tamllCat.interaction";
TbNetName["trackingReport"] = "squirrelsAdoptRest2c.trackingReport"; TbNetName["trackingReport"] = "squirrelsAdoptRest2c.trackingReport";
TbNetName["getActivityBaseInfoById"] = "bubbleSurviva.getActivityBaseInfoById"; TbNetName["getActivityBaseInfoById"] = "bubbleSurviva.getActivityBaseInfoById";
TbNetName["getGameInfo"] = "babycare.getGameInfo"; TbNetName["getGameInfo"] = "babycare.getGameInfo";
...@@ -2444,6 +2459,7 @@ var xianluomao01_1 = __webpack_require__(/*! ../lottieSrc/lottieTs/xianluoCat/xi ...@@ -2444,6 +2459,7 @@ var xianluomao01_1 = __webpack_require__(/*! ../lottieSrc/lottieTs/xianluoCat/xi
var xianluoshuohua_1 = __webpack_require__(/*! ../lottieSrc/lottieTs/xianluoCat/xianluoshuohua */ "./src/lottieSrc/lottieTs/xianluoCat/xianluoshuohua.ts"); var xianluoshuohua_1 = __webpack_require__(/*! ../lottieSrc/lottieTs/xianluoCat/xianluoshuohua */ "./src/lottieSrc/lottieTs/xianluoCat/xianluoshuohua.ts");
var Enum_1 = __webpack_require__(/*! ../Enum */ "./src/Enum.ts"); var Enum_1 = __webpack_require__(/*! ../Enum */ "./src/Enum.ts");
var Ins_1 = __webpack_require__(/*! ../Ins */ "./src/Ins.ts"); var Ins_1 = __webpack_require__(/*! ../Ins */ "./src/Ins.ts");
var TaoBaoNet_1 = __webpack_require__(/*! ../TaoBaoNet */ "./src/TaoBaoNet.ts");
var Cat = (function (_super) { var Cat = (function (_super) {
__extends(Cat, _super); __extends(Cat, _super);
function Cat(data) { function Cat(data) {
...@@ -2543,14 +2559,21 @@ var Cat = (function (_super) { ...@@ -2543,14 +2559,21 @@ var Cat = (function (_super) {
var that = this; var that = this;
var actType = e.data; var actType = e.data;
console.log(actType); console.log(actType);
this.actRunning = true; TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.interaction, {}, function (s, r) {
switch (actType) { if (s) {
case Enum_1.CAT_ACTTYPEP.SLEEP: that.actRunning = true;
break; switch (actType) {
default: case Enum_1.CAT_ACTTYPEP.SLEEP:
that.setCatAnimShow(actType, function () { that.setCatAnimShow(0, null); }); break;
break; default:
} that.setCatAnimShow(actType, function () { that.setCatAnimShow(0, null); });
break;
}
}
else {
FYGE.GDispatcher.dispatchEvent("23", r.message);
}
});
}; };
Cat.prototype.initEvents = function () { Cat.prototype.initEvents = function () {
FYGE.GDispatcher.addEventListener(Enum_1.MSG.CAT_ACT, this.catAct, this); FYGE.GDispatcher.addEventListener(Enum_1.MSG.CAT_ACT, this.catAct, this);
...@@ -44748,6 +44771,7 @@ var MainSceneBtnUi = (function (_super) { ...@@ -44748,6 +44771,7 @@ var MainSceneBtnUi = (function (_super) {
MainSceneBtnUi.prototype.touchHandler = function (e) { MainSceneBtnUi.prototype.touchHandler = function (e) {
console.log(e.target); console.log(e.target);
var that = this; var that = this;
that.btnDelay(e.target);
if (e.target == that.returnBtn) { if (e.target == that.returnBtn) {
that.returnBedRoom(); that.returnBedRoom();
} }
'use strict'; 'use strict';
import { Main } from './output'; import {
Main
} from './output';
import API from '../../api'; import API from '../../api';
const app = getApp(); const app = getApp();
const { tbcc } = app; const {
const { commonToast, getAuthUserInfo, navigateToOutside, getSystemInfo } = tbcc.tb; tbcc
} = app;
const {
commonToast,
getAuthUserInfo,
navigateToOutside,
getSystemInfo
} = tbcc.tb;
const checkSystem = async () => { const checkSystem = async () => {
const { version } = await getSystemInfo(); const {
console.log('version', version); version
return tbcc.utils.versionCompare(version, '9.8.0'); } = await getSystemInfo();
console.log('version', version);
return tbcc.utils.versionCompare(version, '9.8.0');
} }
Page({ Page({
data: { data: {
ruleModalVisible: false ruleModalVisible: false
}, },
onLoad(props) {
this.setData({});
checkSystem().then(r => {
if (!r) {
my.showToast({
content: "请升级最新版本的淘宝",
duration: 5000
});
}
});
onLoad(props) { },
this.setData({});
onReady() {
console.log('on ready')
//授权和登录先搞
// this.getAuth();
},
init() {
console.log('do init');
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;
if (!this.main) {
this.main = new Main(ccc); //添加事件,为了和main里的通信
app.canvasMain = this.main;
this.main.addGlobalEvent("onMessage", self.onMessage, self);
this.main.addGlobalEvent("showToast", self.showToast, self);
}
}
});
},
onCanvasReady() {
console.log('onCanvasReady')
//授权和登录先搞
checkSystem().then(r => {
if (r) {
this.getAuth();
}
});
},
checkSystem().then(r => { showToast(e) {
if (!r) {
my.showToast({ my.showToast({
content: "请升级最新版本的淘宝", content: e.data || "网络异常,请稍后重试~",
duration: 5000 duration: 2000
}); });
} },
});
postMessage(netName, data) {
}, this.main.dispatchGlobalEvent({
type: netName
onReady() { }, data); //以防复用事件event串了,就用这种方式
console.log('on ready') },
//授权和登录先搞
// this.getAuth(); //和main通信的方法,接收main的信息
}, onMessage(e) {
//接口名字
init() { let netName = e.data.netName; //接口参数
console.log('do init');
this.spark_startEngine(); let parameter = e.data.parameter; //暂时发现3个需要用户操作的接口
}, //定制的授权
spark_startEngine() { if (netName.indexOf("mine") == 0) {
console.log('spark_startEngine') var data = {
var self = this; success: true
my.createCanvas({ };
id: 'canvas',
success: ccc => { switch (netName) {
const dpr = my.getSystemInfoSync().pixelRatio; case "mine.getAppData":
const windowWidth = my.getSystemInfoSync().windowWidth; //获取信息
const windowHeight = my.getSystemInfoSync().windowHeight; data = {
ccc.width = windowWidth * dpr + dpr; //重新修改会有误差 success: true,
data: {
ccc.height = windowHeight * dpr + dpr; activityId: app.activityId,
nickName: app.nickName,
if (!this.main) { avatar: app.avatar,
this.main = new Main(ccc); //添加事件,为了和main里的通信 openId: app.openId
app.canvasMain = this.main; }
};
this.main.addGlobalEvent("onMessage", self.onMessage, self); break;
} case "mine.navigateToPage": //切换page
} data = {
}); success: true,
}, data: {}
};
onCanvasReady() { my.navigateTo({
console.log('onCanvasReady') url: `/pages/${parameter.name}/${parameter.name}`
//授权和登录先搞 });
checkSystem().then(r => { break;
if (r) { case "mine.showModal": //切换page
this.getAuth(); data = {
} success: true,
}); data: {}
}, };
const key = `${parameter.name}Visible`;
postMessage(netName, data) { const toSetData = {};
this.main.dispatchGlobalEvent({ toSetData[key] = true;
type: netName this.setData(toSetData);
}, data); //以防复用事件event串了,就用这种方式 break;
}, case 'test':
console.log('测试一下', parameter.hint);
//和main通信的方法,接收main的信息 break;
onMessage(e) {
//接口名字
let netName = e.data.netName; //接口参数
let parameter = e.data.parameter; //暂时发现3个需要用户操作的接口
//定制的授权
if (netName.indexOf("mine") == 0) {
var data = {
success: true
};
switch (netName) {
case "mine.getAppData":
//获取信息
data = {
success: true,
data: {
activityId: app.activityId,
nickName: app.nickName,
avatar: app.avatar,
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 toSetData = {};
toSetData[key]=true;
this.setData(toSetData);
break;
case 'test':
console.log('测试一下', parameter.hint);
break;
}
this.postMessage(netName, data);
} else {
const {
function: fc
} = app.cloud;
const [myCloudName, handler] = netName.split("."); //待写,
parameter.activityId = app.activityId;
fc.invoke(myCloudName, parameter, handler).then(res => {
this.postMessage(netName, res);
});
}
},
//鼠标事件
onMouseEvent(e) {
if (this.main) this.main.stage.onMouseEvent(e);
},
onShow() {
// 页面显示
if (this.main) {
this.main.run();
this.main.dispatchGlobalEvent("onShow");
}
},
onHide() { this.postMessage(netName, data);
// 页面隐藏 } else {
if (this.main) { const {
this.main.pause(); function: fc
this.main.dispatchGlobalEvent("onHide"); } = app.cloud;
} const [myCloudName, handler] = netName.split("."); //待写,
},
parameter.activityId = app.activityId;
/** fc.invoke(myCloudName, parameter, handler).then(res => {
* 获取用户授权信息 this.postMessage(netName, res);
*/ });
async getAuth() { }
const userInfo = await getAuthUserInfo().catch(err => { },
console.log('未授权成功', err);
}); //鼠标事件
if (userInfo) { onMouseEvent(e) {
console.log('userInfo', userInfo); if (this.main) this.main.stage.onMouseEvent(e);
const { nickName, avatar } = userInfo; },
app.nickName = nickName;
app.avatar = avatar; onShow() {
this.login(); // 页面显示
} if (this.main) {
}, this.main.run();
/** this.main.dispatchGlobalEvent("onShow");
* 登录接口 }
*/ },
async login() {
const { nickName, avatar } = app; onHide() {
const { success } = await API.login({ userNick: nickName, avatar }).catch(res => { // 页面隐藏
commonToast(res && res.message); if (this.main) {
}) || {}; this.main.pause();
this.main.dispatchGlobalEvent("onHide");
if (success) { }
this.init(); },
/**
* 获取用户授权信息
*/
async getAuth() {
const userInfo = await getAuthUserInfo().catch(err => {
console.log('未授权成功', err);
});
if (userInfo) {
console.log('userInfo', userInfo);
const {
nickName,
avatar
} = userInfo;
app.nickName = nickName;
app.avatar = avatar;
this.login();
}
},
/**
* 登录接口
*/
async login() {
const {
nickName,
avatar
} = app;
const {
success
} = await API.login({
userNick: nickName,
avatar
}).catch(res => {
commonToast(res && res.message);
}) || {};
if (success) {
this.init();
}
},
closeRuleModal() {
this.setData({
ruleModalVisible: false
});
} }
},
closeRuleModal() {
this.setData({
ruleModalVisible: 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