Commit 8a837778 authored by wildfirecode's avatar wildfirecode

1

parent ad3a038e
import { IModuleData } from "../interface/IModuleData";
import { IDestroy } from "../interface/IDestroy";
/**
*Created by cuiliqiang on 2018/3/1
* 组件基类
*/
export abstract class ABModule implements IDestroy {
/**
* 模块数据
*/
private _data: IModuleData;
/**
* 视图层
*/
private _view: any;
constructor(data: IModuleData) {
this._data = data;
let viewClass: any;
if (typeof this.data.viewClass === 'string') {
viewClass = eval(this.data.viewClass);
} else {
viewClass = this.data.viewClass;
}
this._view = new viewClass();
}
/**
* 初始化模型
*/
protected abstract initModel(): void
/**
* 初始化UI
*/
protected abstract initUI(): void
/**
* 显示
*/
protected abstract show(): void
/**
* 隐藏
*/
protected abstract hide(): void
/**
* 添加事件
*/
protected abstract addEvent(): void
/**
* 移除事件
*/
protected abstract removeEvent(): void
/**
* 更新页面
* @param args
*/
public abstract updateData(...args): void
/**
* 播放进场动画
* @param callback 回调函数
*/
public abstract playShowAnimation(callback?: Function): void
/**
* 播放退场动画
* @param callback 回调函数
*/
public abstract playHideAnimation(callback?: Function): void
/**
* 销毁
*/
public abstract dispose(): void
/**
* 模块数据
* @returns {IModuleData}
*/
public get data(): IModuleData {
return this._data;
}
/**
* 视图
* @returns {any}
*/
protected get view(): any {
return this._view;
}
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/13
* 布局枚举
*/
export enum LayoutType {
TOP = 0,
BOTTOM,
LEFT,
RIGHT,
HORIZONTAL,
VERTICAL
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/16
* 模块类型
*/
export enum ModuleType {
SCENE = 0,
PANEL,
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/15
* 资源加载优先级
*/
export enum ResPriority {
PRE = 0,
NOMARL,
DELAY
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/26
* 时间格式
*/
export enum TimeFormat {
HMS = 'hms',
DHMS = 'dhms'
}
\ No newline at end of file
// import { GLang } from './util/GLang';
// import { INetData } from './interface/INetData';
// import { GTime } from './util/GTime';
// import { GPool } from './util/GPool';
// import { GMath } from './util/GMath';
// import { GFun,getImgURL } from './util/GFun';
// import { GDispatcher } from './util/GDispatcher';
// import { GConsole } from './util/GConsole';
// import { GCache } from './util/GCache';
// import { ABPanelManager } from './manager/ABPanelManager';
// import { IModuleData } from './interface/IModuleData';
// import { IDestroy } from './interface/IDestroy';
// import { TimeFormat } from './enum/TimeFormat';
// import { ResPriority } from './enum/ResPriority';
// import { ModuleType } from './enum/ModuleType';
// import { LayoutType } from './enum/LayoutType';
// import { ABModule } from "./component/ABModule";
// import { IData } from './interface/IData';
// import { ABAnimationManager } from './manager/ABAnimationManager';
// import { ABAudioManager } from './manager/ABAudioManager';
// import { ABResManager } from './manager/ABResManager';
// import { ABSceneManager } from './manager/ABSceneManager';
// import { ABStageManager } from './manager/ABStageManager';
// import { ABDataManager } from './manager/ABDataManager';
// import { ABModuleManager } from './manager/ABModuleManager';
// import { ABNetManager } from './manager/ABNetManager';
// import { ABVideoManager } from './manager/ABVideoManager';
// export {
// ABModule, LayoutType, ModuleType, ResPriority, TimeFormat, IData, IDestroy, INetData,
// IModuleData, ABAnimationManager, ABAudioManager, ABDataManager, ABModuleManager, ABNetManager,
// ABPanelManager, ABResManager, ABSceneManager, ABStageManager, ABVideoManager, GCache, GConsole,
// GDispatcher, GFun, GMath, GPool, GTime, GLang,getImgURL
// }
export const a =1
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/8
*/
export interface IData {
update(data: any): void
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/2/28
* 销毁
*/
export interface IDestroy {
dispose(): void;
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/13
* 模块数据
*/
import { ResPriority } from "../enum/ResPriority";
import { ModuleType } from "../enum/ModuleType";
export interface IModuleData {
/**
* 模块名字
*/
moduleName: string;
/**
* 模块类
*/
moduleClass: any;
/**
* 视图类
*/
viewClass: any;
/**
* 资源
*/
res: string;
/**
* 资源加载优先级
*/
resPriority: ResPriority;
/**
* 类型 1 场景, 2面板
*/
type: ModuleType;
/**
* 显示层级
*/
layerIndex: number;
/**
* 显示遮罩背景
*/
showBg: boolean;
/**
* 是否可以事件穿透
*/
eventPenetrate: boolean;
/**
* 进场动画
*/
showAnimation?: Function;
/**
* 退场动画
*/
hideAnimation?: Function;
/**
* UI配置
*/
uiCfg?: any;
}
\ No newline at end of file
export interface INetData {
//名字
name: any;
//地址
uri: string;
//接口类型 get、post等
type: string;
//返回数据类型
dataType: string;
//参数
param: any;
//回调
callback: Function;
//轮询次数
pollingCount?: number;
//轮询条件检查
pollingCheck?: Function;
//url拼接内容
addUrl?: string;
//是否显示错误提示
hideMsg?: boolean;
}
\ No newline at end of file
/**
* 动画管理器
*/
export abstract class ABAnimationManager {
/**
* 播放动画
* @param animations 动画数组
*/
public abstract play(animations: any[]): void
}
\ No newline at end of file
export abstract class ABAudioManager {
constructor() {
}
/**
* 创建声音实例
* @param {string} name 标识
* @param {string} src 音频地址
*/
public abstract createSound(name: string, src: string): void
/**
* 获取当前声音实例
* @param {string} name 标识
* @returns {any}
* @constructor
*/
public abstract getSound(name: string): any
/**
* 播放声音
* @param {string} name 标识
* @param {number} start 开始点 默认为0
* @param {number} loop 循环次数 默认为1
*/
public abstract play(name: string, start?: number, loop?: number): void
/**
* 暂停播放,或者恢复播放
* @param {string} name 标识
* @param {boolean} isPause 默认为true;是否要暂停,如果要暂停,则暂停;否则则播放
*/
public abstract pause(name: string, isPause?: boolean): void
/**
* 停止声音播放
* @param {string} name 标识
* @param {.Sound} sound 声音实例
*/
public abstract stop(name: string): void
/**
* 设置音量
* @param {string} name 标识
* @param {number} volume 音量大小,从0-1 在ios里 volume只能是0 或者1,其他无效
*/
public abstract setVolume(name: string, volume: number): void
/**
* 设置所有音频音量
* @param volume
*/
public abstract setAllVolume(volume: number): void
/**
* 暂停状态
* @param name
*/
public abstract getPause(name: string): boolean
/**
* 从静态声音池中删除声音对象,如果一个声音再也不用了,建议先执行这个方法,再销毁
* @param {string} name 声音实例
*/
public abstract destory(name: string): void
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/8
* 数据管理
*/
export abstract class ABDataManager {
/**
* 更新数据
* @param {number} name 接口名字
* @param result 接口返回数据
* @returns {any}
*/
public abstract updateData(name: number, result: any): any
}
\ No newline at end of file
import { IModuleData } from './../interface/IModuleData';
/**
* 模块管理器
*/
export abstract class ABModuleManager {
/**
* 初始化
* @param {ModuleData} modules
*/
public abstract init(modules: IModuleData[]): void
/**
* 按模块名获取模块数据
* @param {string} moduleName 模块名
* @returns {ModuleData}
*/
public abstract getModule(moduleName: string): IModuleData
/**
* 打开一个模块
* @param {string} moduleName 模块名
* @param args 携带参数
*/
public abstract openModule(moduleName: string, ...args): void
/**
* 访问模块内的公用方法
* @param {string} moduleName 模块名
* @param {string} funcName 方法名
*/
public abstract callModuleFunc(moduleName: string, funcName: string, ...args): void
}
\ No newline at end of file
import { INetData } from './../interface/INetData';
import { GTime } from "../util/GTime";
import { GConsole } from "../util/GConsole";
import { IData } from '../interface/IData';
export abstract class ABNetManager {
/**
* 接口底层错误
*/
public static ERROR = 'Error';
/**
* 调用接口对象池
*/
private callbackPool: any = {};
constructor() {
}
/**
* 发送请求
* @param net
*/
public send(net: INetData): void {
let gTime: string = '?_=' + GTime.getTimestamp();
let realUrl: string = net.uri;
if (realUrl.indexOf('?') != -1) {
gTime = '&_=' + GTime.getTimestamp();
}
//url加参数等特殊需求(例如再玩一次需要在dostart接口的url上加埋点)
if (net.addUrl) {
realUrl += net.addUrl;
}
$.ajax({
type: net.type,
// url: realUrl + gTime,
url: realUrl,
dataType: net.dataType,
data: net.param,
async: true,
success: (result) => {
this.onResponse(net, result);
},
error: (message) => {
this.onError(net);
}
});
}
/**
* 消息响应
* @param net
*/
protected abstract onResponse(net: INetData, result: IData): void
/**
* 通讯底层错误
* @param net
* @param message
*/
protected abstract onError(net: INetData, message?: any): void
}
\ No newline at end of file
import { IModuleData } from "../interface/IModuleData";
/**
* 面板管理
*/
export abstract class ABPanelManager {
constructor() {
}
/**
* 显示面板
* @param {ModuleData} module 模块
* @param {any} data 数据
*/
public abstract show(module: IModuleData, data: any): void
/**
* 关闭面板
* @param moduleName
* @param dispose
*/
public abstract hide(moduleName: string, dispose?: boolean): void
/**
* 关闭所有面板
* @param {boolean} dispose
*/
public abstract hideAll(dispose?: boolean): void
/**
* 调用面板方法
* @param {ModuleName} moduleName
* @param {string} funcName
* @param args
*/
public abstract callFunc(moduleName: string, funcName: string, ...args): void
}
\ No newline at end of file
import { ResPriority } from './../enum/ResPriority';
import { IModuleData } from '../interface/IModuleData';
export abstract class ABResManager {
/**
* 添加资源到加载列表
* @param res
* @param priority
*/
public abstract addRes(res: any, priority: ResPriority): void
/**
* 加载资源
*/
public abstract loadRes(): void
/**
* 检测模块资源是否加载完成
* @param {ModuleData} module 模块数据
* @returns {boolean}
*/
public abstract checkRes(module: IModuleData): boolean
}
\ No newline at end of file
import { IModuleData } from "../interface/IModuleData";
/**
* 场景管理器
*/
export abstract class ABSceneManager {
constructor() {
}
/**
* 切换场景
* @param {ModuleData} module 模块数据
* @param {any} data 携带数据
*/
public abstract change(moduleData: IModuleData, data?: any): void
/**
* 调用场景方法
* @param {ModuleName} moduleName
* @param {string} funcName
* @param args 携带参数
*/
public abstract callFunc(moduleName: string, funcName: string, ...args): void
/**
* 当前场景名字
*/
public abstract get currSceneName(): string
}
\ No newline at end of file
import { LayoutType } from "../enum/LayoutType";
export abstract class ABStageManager {
/**
* 添加显示对象到指定容器
* @param {any} child 对象实例
* @param {any} container 容器实例
* @param {number} 指定层级 默认不指定层级
*/
public abstract addChild(child: any, container: any, index: number): void
/**
* 移除显示对象从父容器
* @param child 要移除的显示对象
*/
public abstract removeChild(child): void
/**
* 对齐方式
* @param display 显示对象
* @param mode 对齐方式 (left, right, top, bottom, horizontal, vertical)
* @param offset 偏移量
*/
public abstract align(display: any, layout: LayoutType, offset: number): void
}
\ No newline at end of file
export abstract class ABVideoManager {
/**
* 创建视频
* @param {string} name 名字
* @param {string} src 视频链接
* @param {number} width 视频宽,默认可以不填
* @param {number} height 视频高,默认可以不填
*/
public abstract createVideo(name: string, src: string, width?: number, height?: number): void
/**
* 获取当前最新的一个video对象
* @returns {any}
*/
public abstract getVideo(name: string): any
/**
* 开始播放媒体
* @method play
* @param {number} start 开始点 默认为0
* @param {number} loop 循环次数 默认为1
*/
public abstract play(start?: number, loop?: number): void
/**
* 暂停播放,或者恢复播放
* @method pause
* @param isPause 默认为true;是否要暂停,如果要暂停,则暂停;否则则播放
*/
public abstract pause(isPause?: boolean): void
/**
* 停止播放
*/
public abstract stop(): void
}
\ No newline at end of file
import { GFun } from './GFun';
import { GConsole } from './GConsole';
export class GCache {
private static gKey: string;
/**
* 初始化
* @param keys
*/
public static init(keys: string[]): void {
let i = 0;
const len: number = keys.length;
this.gKey = '';
for (i; i < len; i++) {
this.gKey += '_' + keys[i];
}
}
/**
* 写入缓存
* @param key
* @param value
* @param type type 缓存类型 localStorage永久缓存 sessionStorage浏览器生命周期结束前'
*/
public static writeCache(key: string, value: any, type = 'localStorage') {
if (!window[type]) {
GConsole.log(GFun.replace('webview不支持{0}', [type]));
return;
}
window[type].setItem(key + this.gKey, value);
}
/**
* 读取缓存
* @param key
* @param type type 缓存类型 localStorage永久缓存 sessionStorage浏览器生命周期结束前'
* @return
*/
public static readCache(key: string, type = 'localStorage'): string {
if (!window[type]) {
GConsole.log(GFun.replace('webview不支持{0}', [type]));
return;
}
return window[type].getItem(key + this.gKey);
}
/**
* 删除缓存
* @param key
* @param type 缓存类型 localStorage永久缓存 sessionStorage浏览器生命周期结束前
*/
public static removeCache(key: string, type = 'localStorage'): string {
if (!window[type]) {
GConsole.log(GFun.replace('webview不支持{0}', [type]));
return;
}
window[type].removeItem(key + this.gKey);
}
}
\ No newline at end of file
export class GConsole {
private static switch: boolean = window['debug'] || true;
/**
* 日志打印
* @param args
*/
public static log(...args): void {
if (!this.switch) {
return;
}
let i = 0;
const len: number = args.length;
for (i; i < len; i++) {
console.log(args[i]);
}
}
}
\ No newline at end of file
export class GDispatcher {
/**
* 事件回调池
*/
private static callbackPool: any = {};
/**
* 事件作用域池
*/
private static thisObjPool: any = {};
/**
*
* @param name 事件名
* @param callback 回调
* @param thisObj 作用域
*/
public static addEvent(name: string, callback, thisObj: any): void {
if (!this.callbackPool[name]) {
this.callbackPool[name] = [];
this.thisObjPool[name] = [];
}
const index: number = this.callbackPool[name].indexOf(callback);
if (index != -1) {
this.callbackPool[name][index] = callback;
this.thisObjPool[name][index] = thisObj;
} else {
this.callbackPool[name].push(callback);
this.thisObjPool[name].push(thisObj);
}
}
/**
*
* @param name 事件名
* @param callback 回调
* @param thisObj 作用域
*/
public static removeEvent(name: string, callback, thisObj?: any): void {
if (this.callbackPool[name]) {
const index: number = this.callbackPool[name].indexOf(callback);
if (index != -1) {
this.callbackPool[name].splice(index, 1);
this.thisObjPool[name].splice(index, 1);
}
}
}
/**
* 派发事件
* @param name 事件名
* @param args 任意参数
*/
public static dispatchEvent(name: string, ...args): void {
const callbacks: Function[] = this.callbackPool[name];
const thisObjs: any = this.thisObjPool[name];
if (callbacks) {
let i = 0;
const len: number = callbacks.length;
for (i; i < len; i++) {
callbacks[i].apply(thisObjs[i], args);
}
}
}
}
\ No newline at end of file
import { GMath } from './GMath';
import { GTime } from './GTime';
import { GConsole } from './GConsole';
export class GFun {
/**
* 加载 html Image
* @param url
* @param callback
*/
public static loadImage(url: string, callback: Function): any {
//取出跟url匹配的Image
const bitmapData: any = new Image();
bitmapData.onload = (e) => {
if (callback) {
callback(bitmapData);
}
};
bitmapData.src = url;
}
/**
* 替换字符串中元素
* @param str
* @param replaceList
*/
public static replace(str: string, replaceList: Array<string | number>) {
const len = replaceList.length;
for (let i = 0; i < len; i++) {
str = str.replace("{" + i + "}", replaceList[i].toString());
}
return str;
}
/**
* 是否在app内运行
* @param strs 匹配字符串
*/
public static checkInApp(strs: string[]): boolean {
const ua = navigator.userAgent.toLocaleLowerCase();
let i: number;
const len: number = strs.length;
for (i = 0; i < len; i++) {
if (ua.indexOf(strs[i]) != -1) {
return true;
}
}
return false;
}
/**
* 判断操作系统
* @returns {Array|{index: number, input: string}}
*/
public static get isIOS(): boolean {
return navigator.userAgent.match(/iphone|ipod|ipad/gi) != null;
}
/**
* 获取url参数
*/
public static getQueryString(name): any {
const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
const r = window.location.search.substr(1).match(reg);
if (r != null) {
return unescape(r[2]);
}
return null;
}
}
const check_webp_feature = (callback) => {
const _support_webp_ = localStorage.getItem('_support_webp_');
if (_support_webp_ !== null) {
return callback(_support_webp_ === '1')
}
const img = new Image();
img.onload = function () {
const result = (img.width > 0) && (img.height > 0);
callback(result);
localStorage.setItem('_support_webp_', result ? '1' : '0')
};
img.onerror = function () {
callback(false);
localStorage.setItem('_support_webp_', '0')
};
img.src = "data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA";
}
export const getImgURL = (url: string, cb) => {
check_webp_feature((isSupport) => {
if (isSupport) url += '?x-oss-process=image/format,webp';
cb(url)
})
}
\ No newline at end of file
export class GLang {
public static lang_001 = "pre资源加载完成";
public static lang_002 = "nomarl资源加载完成";
public static lang_003 = "delay资源加载完成";
}
\ No newline at end of file
export class GMath {
/**
* 向下取整
* @param n
* @returns {number}
*/
public static int(n: any): number {
return n >> 0;
}
/**
* 给数组随机排序
* @param arr
*/
public static randomArr(arr: any[]): any[] {
const len = arr.length;
for (let i = 0; i < len; i++) {
const n = this.random(0, arr.length, true);
const temp = arr[n];
arr[n] = arr[i];
arr[i] = temp;
}
return arr;
}
/**
* 范围随机数
* @param n1 范围起始
* @param n2 范围结束
* @param int 结果是否返回整数
* @return {*}
*/
public static random(n1: number, n2: number, int: boolean): number {
let n: number;
let min: number;
let max: number;
if ((typeof n1) != 'undefined' && (typeof n2) != 'undefined') {
min = Math.min(n1, n2);
max = Math.max(n1, n2);
n = Math.random() * (max - min) + min;
} else {
n = Math.random();
}
if (int) {
n = this.int(n);
}
return n;
}
}
\ No newline at end of file
/**
* 对象池
*/
export class GPool {
private static pool: any = {};
private static maxCount = {};
/**
* 根据类型设置缓存最大个数
* @param className
* @param count
*/
public static setMaxCountByType(className: any, count): void {
this.maxCount[className] = count;
}
/**
* 取出
* @param className 资源名
* @param 类名
*/
public static takeOut(className: string, classObj?: any, isCreate?: boolean): any {
if (!className || className == '') {
return;
}
let obj: any;
if (this.pool[className] && this.pool[className].length) {
obj = this.pool[className].shift();
} else if (isCreate) {
if (!classObj) {
classObj = eval(className);
}
obj = new classObj();
}
return obj;
}
/**
* 回收
* @param className 资源Class
* @param obj 资源
*/
public static recover(className: string, obj: any): void {
if (!obj || !className) {
return;
}
if (!this.pool[className]) {
this.pool[className] = [];
}
if (!this.maxCount[className]) {
this.maxCount[className] = 100;
}
if (this.pool[className].length > this.maxCount[className]) {
return;
}
this.pool[className].push(obj);
if (obj['dispose']) {
obj.dispose();
}
}
}
\ No newline at end of file
import { IData } from 'duiba-tc';
/**
*Created by cuiliqiang on 2018/3/12
* 数据基类
*/
export class Data implements IData {
private _success: boolean;
private _message: string;
private _code: number;
public update(data: any): void {
this._success = data.success == undefined ? true : data.success;
if (data.message) {
this._message = data.message;
} else if (data.desc) {
this._message = data.desc;
} else if (data.msg) {
this._message = data.msg;
}
this._code = data.code;
}
/**
* 接口状态
* @returns {boolean}
*/
public get success(): boolean {
return this._success;
}
/**
* 接口提示信息
* @returns {string}
*/
public get message(): string {
return this._message;
}
/**
* 状态码
* @returns {string}
*/
public get code(): number {
return this._code;
}
}
import { Data } from './../Data';
import { RecordData } from './record/RecordData';
export class GetRecordData extends Data {
public invalidPage: boolean;
public nextPage: boolean;
public records: RecordData[];
public update(data: any): void {
if(!data) {
return;
}
super.update(data);
this.invalidPage = data.invalidPage;
this.nextPage = data.nextPage;
this.records = data.records;
}
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/1
* 埋点信息
*/
export interface IExposureData {
activityId?: number;
activityUseType?: string;
advertId?: number;
appId: number;
consumerId: number;
dcm: string;
domain: string;
dpm: string;
ip?: string;
isEmbed?: boolean;
materialId?: number;
orderId?: string;
os?: string;
}
\ No newline at end of file
export interface IShareData {
/**
* 开发者名字
*/
appName: string;
/**
* 标题
*/
title: string;
/**
* 分享文案
*/
desc: string;
/**
* 分享链接
*/
link: string;
/**
* 分享图片
*/
imgUrl: string;
/**
* 分享整张图片(image_url),只支持微信、朋友圈、QQ。
*/
image_only: boolean;
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/7
* 添加游戏次数
*/
import { Data } from "../../Data";
export class AddTimesForActivityData extends Data {
/**
* 累计添加次数的总和
*/
public addedTimes: number;
/**
* 累计调用接口的次数
*/
public shareCount: number;
public update(data: any): void {
if (!data) {
return;
}
super.update(data);
this.addedTimes = data.addedTimes;
this.shareCount = data.shareCount;
}
}
\ No newline at end of file
import { Data } from './../../Data';
import { ICollectRuleData } from './ICollectRuleData';
/**
*Created by cuiliqiang on 2018/3/7
* 集卡数据
*/
export class GetCollectRuleData extends Data {
/**
* 集卡规则列表
*/
public collectRules: ICollectRuleData[];
/**
* 奖品等级(几等奖)
*/
public prizeLevel: number;
/**
* 是否可以开奖
*/
public clickFlag: boolean;
/**
*
*/
public exchange: boolean;
/**
* 所有卡片数量
*/
public allCount: number;
public update(data: any): void {
if (!data) {
return;
}
super.update(data);
this.prizeLevel = data.prizeLeve;
this.clickFlag = data.clickFlag;
this.exchange = data.exchange;
this.collectRules = data.collectRule;
if (data.collectGoods) {
const len = data.collectGoods.length;
let i = 0;
for (i; i < len; i++) {
this.allCount += data.collectGoods[i].count;
}
} else {
this.allCount = 0;
}
}
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/7
* 集卡卡片数据
*/
export interface ICollectGoodData {
/**
* 卡片数量
*/
count: number;
/**
* 卡片ID
*/
id: number;
/**
* 展示图片
*/
img: string;
/**
* 卡片名字
*/
name: string
}
import { ICollectGoodData } from "./ICollectGoodData";
/**
* 集卡规则
*/
export interface ICollectRuleData {
/**
* 奖品等级
*/
grade: number;
/**
* 是否是随机卡兑换,优先于固定卡
*/
entryCount: number;
/**
* 集卡规则
*/
rule: ICollectGoodData[];
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/12
* 用户剩余积分数据
*/
import { Data } from "../../Data";
export class GetCreditsData extends Data {
/**
* 积分单位
*/
public unitName: string;
/**
* 积分
*/
public credits: number;
/**
* 用户积分
*/
public consumerCredits: number;
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
this.unitName = result.data.unitName;
this.credits = result.data.credits;
this.consumerCredits = result.data.consumerCredits;
}
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/12
* 获取用户角色信息
*/
import { Data } from "../../Data";
export class GetRoleData extends Data {
/**
* 性别
*/
public role: string;
public update(data: any): void {
if (!data) {
return;
}
super.update(data);
this.role = data.data.role;
}
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/1
* 奖品信息
*/
import { LotteryType } from "../../../enum/LotteryType";
import { IData } from "duiba-tc";
import { IExposureData } from "../IExposureData";
export class LotteryData implements IData {
/**
* 广告ID
*/
public id: number;
/**
* 安卓下载链接
*/
public androidDownloadUrl: string;
/**
* 图片链接
*/
public img: string;
/**
* IOS下载链接
*/
public iosDownloadUrl: string;
/**
* 跳转地址
*/
public link: string;
/**
* 奖品名字
*/
public name: string;
/**
*
*/
public openUrl: string;
/**
* 是否展示立即使用按钮
*/
public showUse: boolean;
/**
*
*/
public tip: string;
/**
* 标题
*/
public title: string;
/**
* 立即使用按钮文案
*/
public useBtnText: string;
/**
* 有效日期
*/
public validate: string;
/**
* 奖品类型
*/
public type: LotteryType;
/**
* 关闭按钮埋点
*/
public closeExposure: IExposureData;
/**
* 立即使用按钮埋点
*/
public useExposure: IExposureData;
/**
* 奖品图片埋点
*/
public imgExposure: IExposureData;
/**
* 是否弹出下载提示框
*/
public confirm: string;
/**
* 集卡id
*/
public itemId: number;
public update(data: any): void {
if (!data) {
return;
}
this.androidDownloadUrl = data.androidDownloadUrl;
this.iosDownloadUrl = data.iosDownloadUrl;
this.img = data.imgurl;
this.link = data.link;
this.name = data.name ? data.name : data.title;
this.openUrl = data.openUrl;
this.showUse = data.showUse;
this.tip = data.tip;
this.title = data.title;
this.useBtnText = data.useBtnText;
this.validate = data.validate;
this.type = data.type;
this.confirm = data.confirm;
this.id = data.id;
if (data.stinfodpmclose) {
this.closeExposure = JSON.parse(data.stinfodpmclose);
} else {
this.closeExposure = null;
}
if (data.stinfodpmgouse) {
this.useExposure = JSON.parse(data.stinfodpmgouse);
} else {
this.useExposure = null;
}
if (data.stinfodpmimg) {
this.imgExposure = JSON.parse(data.stinfodpmimg);
} else {
this.imgExposure = null;
}
if(data.itemId){
this.itemId = data.itemId;
}
}
}
\ No newline at end of file
import { Data } from './../../Data';
export class OpenCollectGoodsPrizeData extends Data {
/**
* 订单ID
*/
public orderId: number;
public update(data: any): void {
if(!data) {
return;
}
super.update(data);
this.orderId = data.orderId;
}
}
\ No newline at end of file
import { Data } from './../../Data';
export class RecordData extends Data {
public emdDpmJson: any;
public emdJson: any;
public gmtCreate: any;
public img: string;
public invalid: boolean;
public orderTypeTitle: string;
public quantity: number;
public statusText: string;
public text: string;
public title: string;
public trueActivityTitle: string;
public url: string;
public update(data: any): void {
if(!data) {
return;
}
super.update(data);
this.emdDpmJson = data.emdDpmJson;
this.emdJson = data.emdJson;
this.gmtCreate = data.gmtCreate;
this.img = data.img;
this.invalid = data.invalid;
this.orderTypeTitle = data.orderTypeTitle;
this.quantity = data.quantity;
this.statusText = data.statusText;
this.text = data.text;
this.title = data.title;
this.trueActivityTitle = data.trueActivityTitle;
this.url = data.url;
}
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/12
* 设置用户信息
*/
import { Data } from "../../Data";
export class SetRoleData extends Data {
/**
* 性别
*/
public role: string;
public update(data: any): void {
if (!data) {
return;
}
super.update(data);
this.role = data.data.role;
}
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/10
* 获奖用户数据
*/
export interface IWinnerData {
/**
* 手机号码
*/
phone: string;
/**
* 花费充值账号
*/
phoneBill: string;
/**
* 支付宝充值账号
*/
alipayAccount: string;
/**
* Q币充值账号
*/
qqAccount: string;
/**
* 奖品类型
*/
prizeType: string;
/**
* 所在地
*/
city: string;
/**
* 用户ID
*/
userId: string;
/**
* 中奖日期
*/
date: string;
/**
*
*/
winnerCarouselId: number;
/**
* 昵称
*/
nickName: string;
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/10
* 中奖广播数据
*/
import { IWinnerData } from "./IWinnerData";
import { Data } from "../../Data";
export class WinnersData extends Data {
/**
* 用户列表
*/
public winnerList: IWinnerData[];
public update(data: any): void {
if (!data) {
return;
}
super.update(data);
this.winnerList = data.data;
}
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/12
* 自定义活动配置信息
*/
import { Data } from "../../Data";
import { ICustomOptionData } from "./ICustomOptionData";
import { IElementData } from "./IElementData";
export class AjaxElementData extends Data {
/**
* 闯关信息
*/
public throughCurrent: number;
/**
* 闯关模式
*/
public throughMode: number;
/**
* 关卡ID
*/
public throughNum: number;
/**
* 站点位置
*/
public throughCurrentStep: number;
/**
* 弹层js
*/
public jsTest: string;
/**
* 弹层css
*/
public cssTest: string;
/**
* 活动规则
*/
public rule: any;
/**
* 活动类型
*/
public type: string;
/**
* 奖项列表
*/
public options: ICustomOptionData[];
/**
* 页面展示信息
*/
public element: IElementData;
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
this.throughCurrent = result.throughCurrent;
this.throughMode = result.throughMode;
this.throughNum = result.throughNum;
this.throughCurrentStep = result.throughCurrentStep;
this.jsTest = result.jsTest;
this.cssTest = result.cssTest;
this.rule = result.rule;
this.type = result.type;
this.options = result.options;
this.element = result.element;
}
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/12
* 活动工具奖项信息
*/
export interface ICustomOptionData {
/**
* 是否展示奖品
*/
hidden: boolean;
/**
* 奖品ID
*/
id: number;
/**
* 奖品图片
*/
logo: string;
/**
* 奖品名字
*/
name: string;
/**
* 奖品类型 lucky 福袋, virtual 虚拟商品, object 实物, coupon 优惠券, alipay 支付宝, phonebill 话费, qb Q币, collectGoods 集卡
*/
prizeType: string;
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/12
* 活动工具页面展示数据
*/
export interface IElementData {
/**
* 积分模式
*/
isCreditsTypeOpen: boolean;
/**
* 免费次数
*/
freeLimit: number;
/**
* 我的积分
*/
myCredits: string;
/**
* 参与积分
*/
needCredits: number;
/**
* 状态码 0其它异常 1积分不足 3今日没有抽奖次数 4没有抽奖次数 5次数提示为:今日剩余{0}次 6{0}元宝/次 7次数提示为:剩余{0}次 18未登录
*/
status: number;
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/12
* 闯关游戏配置数据
*/
import { Data } from "../../Data";
import { IThroughInfoData } from "./IThroughInfoData";
export class AjaxThroughInfoData extends Data {
/**
* 闯关信息
*/
public throughNum: number;
/**
* 闯关模式
*/
public throughCurrent: number;
/**
* 关卡ID
*/
public throughCurrentStep: number;
/**
* 站点位置
*/
public throughMode: number;
/**
* 关卡列表
*/
public throughInfoList: IThroughInfoData[];
public update(data: any): void {
if (!data) {
return;
}
super.update(data);
this.throughCurrent = data.throughCurrent;
this.throughMode = data.throughMode;
this.throughNum = data.throughNum;
this.throughCurrentStep = data.throughCurrentStep;
this.throughInfoList = data.throughInfo;
}
}
\ No newline at end of file
import { IData } from "duiba-tc";
/**
*Created by cuiliqiang on 2018/3/12
* 闯关游戏关卡数据
*/
export interface IThroughInfoData {
/**
* 展示图片
*/
img: string;
/**
* 奖品类型
*/
type: string;
/**
* 所在步数
*/
step: number;
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/12
* 前置开奖提交数据
*/
import { Data } from "../../Data";
export class BeforSubmitData extends Data {
/**
* 状态 0处理成功
*/
public result: number;
/**
*
*/
public type: string;
/**
* 用户虚拟积分可达到的阈值 未中奖返回-1
*/
public facePrice: number;
/**
* 订单ID
*/
public orderId: number;
/**
* 标题
*/
public title: string;
public update(data: any): void {
if (!data) {
return;
}
this.result = data.result;
this.type = data.type;
this.facePrice = data.facePrice;
this.orderId = data.orderId;
this.title = data.title;
}
}
/**
*Created by cuiliqiang on 2018/3/12
* 活动工具基础配置数据
*/
export interface ICustomCfgData {
/**
* 活动ID
*/
actId: number;
/**
* 入库ID
*/
oaId: number;
/**
* 积分单位
*/
unitName: string;
/**
* 按钮单位
*/
btnUnitName: string;
/**
* 用户ID
*/
consumerId: number;
/**
*
*/
hdType: string;
/**
*
*/
hdToolId: number;
/**
*
*/
appId: number;
/**
* 兑换记录地址
*/
recordUrl: string;
/**
* 是否使用配置的优惠券弹窗
*/
needCouponModal: boolean;
/**
* 是否是预览
*/
preview: boolean;
/**
* 需要异步加载的文件列表
*/
asyncFiles: string[];
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/12
* 活动工具抽奖数据
*/
import { Data } from "../../Data";
export class DoJoinData extends Data {
/**
* 所需积分
*/
public needCredits: number;
/**
* 订单ID
*/
public orderId: number;
public update(data: any): void {
if (!data) {
return;
}
super.update(data);
this.needCredits = data.needCredits;
this.orderId = data.orderId;
}
}
\ No newline at end of file
import { GPool } from "duiba-tc";
import { LotteryData } from "../../common/lottery/LotteryData";
import { Data } from "../../Data";
import { IExposureData } from "../../common/IExposureData";
/**
*Created by cuiliqiang on 2018/3/12
* 订单状态
*/
export class GetCustomOrderStatusData extends Data {
/**
* 推啊埋点数据
*/
public exposure: IExposureData;
/**
* 奖品数据
*/
public lottery: LotteryData;
/**
* 业务状态 -1处理失败 0处理中 1谢谢参与 2处理完成 3再来一次 101扣积分失败或者内部处理异常
*/
public result: number;
public update(data: any): void {
if (!data) {
return;
}
super.update(data);
this.result = data.result;
if (data.exposure) {
this.exposure = data.exposure;
} else if (this.exposure) {
this.exposure = null;
}
if (data.lottery && data.lottery.type != 'thanks') {
this.lottery = GPool.takeOut('LotteryData', LotteryData);
if (!this.lottery) {
this.lottery = new LotteryData();
}
this.lottery.update(data.lottery);
} else {
GPool.recover('LotteryData', this.lottery);
this.lottery = null;
}
}
}
/**
*Created by cuiliqiang on 2018/3/13
* 中奖前置数据
*/
import { Data } from "../../Data";
export class GetOrderInfoData extends Data {
/**
* 状态 0,101 处理中 2处理成功
*/
public result: number;
/**
* 奖品类型
*/
public type: string;
/**
* 用户虚拟积分可达到的阈值 未中奖返回-1
*/
public facePrice: number;
/**
* 前端缓存到后端的数据
*/
public cacheInfo: any;
/**
* 订单ID
*/
public orderId: number;
/**
* 标题
*/
public title: string;
public update(data: any): void {
if (!data) {
return;
}
this.result = data.result;
this.type = data.type;
this.facePrice = data.facePrice;
this.cacheInfo = data.cacheInfo;
this.orderId = data.orderId;
this.title = data.title;
}
}
/**
*Created by cuiliqiang on 2018/3/12
* 答题提交结果数据
*/
import { Data } from "../../Data";
export class QuestionSubmitData extends Data {
/**
* 订单ID
*/
public orderId: number;
/**
* 1:插件式抽奖工具 返回数据中 对一个 plginOrderId 然后调用 collectRule/getOrderStatus?orderId=plginOrderId 查询奖品信息
* 2:后退 3:前进 4终点 5:活动工具奖品出奖 6:跳转地址
*/
public type: string;
/**
* 插件订单ID 对应type = 1时
*/
public plginOrderId: number;
/**
* 为true 时 需要调用 newActivity/getOrderStatus 查询奖品信息
*/
public needPrize: boolean;
/**
*
*/
public point: number;
/**
* 当前位置
*/
public currentLocation: number;
public update(data: any): void {
if (!data) {
return;
}
this.orderId = data.orderId;
this.type = data.prizeType;
this.plginOrderId = data.plginOrderId;
this.needPrize = data.needPrize;
this.point = data.point;
this.currentLocation = data.currentLocation;
}
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/12
* 闯关游戏提交结果数据
*/
import { Data } from "../../Data";
export class ThroughSubmitData extends Data {
/**
* 订单ID
*/
public orderId: number;
/**
* 1:插件式抽奖工具 返回数据中 对一个 plginOrderId 然后调用 collectRule/getOrderStatus?orderId=plginOrderId 查询奖品信息
* 2:后退 3:前进 4终点 5:活动工具奖品出奖 6:跳转地址
*/
public type: string;
/**
* 插件订单ID 对应type = 1时
*/
public plginOrderId: number;
/**
* 为true 时 需要调用 newActivity/getOrderStatus 查询奖品信息
*/
public needPrize: boolean;
/**
*
*/
public point: number;
/**
* 当前位置
*/
public currentLocation: number;
public update(data: any): void {
if (!data) {
return;
}
super.update(data);
this.orderId = data.orderId;
this.type = data.prizeType;
this.plginOrderId = data.plginOrderId;
this.needPrize = data.needPrize;
this.point = data.point;
this.currentLocation = data.currentLocation;
}
}
\ No newline at end of file
import { IData } from "duiba-tc";
/**
*Created by cuiliqiang on 2018/3/1
*/
export interface IAppData {
/**
* AppID
*/
appId: number;
/**
* 赚取积分链接
*/
earnCreditsUrl: string;
/**
*
*/
isOpen: boolean;
/**
*
*/
openLogin: string;
/**
*
*/
loginProgram: string;
}
\ No newline at end of file
export interface IDefenseStrategyData {
/**
* 阶段性提交分值条件(每到此分值的倍数则提交一次)
*/
scoreUnit: number;
/**
* 每局可阶段性提交次数
*/
interfaceLimit: number;
}
\ No newline at end of file
import { IData } from "duiba-tc";
export interface IExtraCfgData {
/**
* 埋点域名
*/
embedDomain: string;
}
\ No newline at end of file
import { GetInfoData } from '../getInfo/GetInfoData';
import { IAppData } from './IAppData';
import { IGameData } from './IGameData';
import { IExtraCfgData } from './IExtraCfgData';
import { IDefenseStrategyData } from './IDefenseStrategyData';
export interface IGameCfgData {
/**
* App数据
*/
appInfo: IAppData;
/**
* 游戏配置数据
*/
gameInfo: IGameData;
/**
* 其它数据
*/
extra: IExtraCfgData;
/**
* 防作弊数据
*/
defenseStrategy: IDefenseStrategyData;
}
\ No newline at end of file
import { IData } from "duiba-tc";
import { IRecommendData } from "./IRecommendData";
export interface IGameData {
/**
* 皮肤内容
*/
skinContent: string;
/**
*
*/
oaId: number;
/**
* 活动结束时间
*/
offDate: string;
/**
* 是否是排名开奖
*/
rankPrize: boolean;
/**
* 是否开启积分累计模式
*/
openTotalScoreSwitch: boolean;
/**
* 游戏ID
*/
gameId: number;
/**
* 管理后台游戏ID
*/
id: number;
/**
* 推荐位数据
*/
recommend: IRecommendData;
}
\ No newline at end of file
import { IData } from "duiba-tc";
/**
*Created by cuiliqiang on 2018/3/1
* 推荐位
*/
export interface IRecommendData {
/**
* banner图
*/
bannerImg: string;
/**
* 展示图
*/
image: string;
/**
* 跳转地址
*/
link: string;
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/1
* 中奖用户信息
*/
export interface IUserData {
/**
* 是否参与过
*/
active: boolean;
/**
* 用户ID
*/
cid: string;
/**
* 最高分
*/
maxScore: number;
/**
* 排名
*/
rank: number;
/**
* 昵称
*/
nickName?: string;
/**
* 头像
*/
avatar?: string;
}
\ No newline at end of file
import { Data } from "../../Data";
/**
* 阶段提交数据
*/
export class DatapashData extends Data {
public update(result: any): void {
super.update(result);
}
}
\ No newline at end of file
export interface IDynamicData {
//x坐标
x: number;
//y坐标
y: number;
//action 行为类型 md按下 mu抬起
a: string;
//行为产生时间戳
t: number;
}
\ No newline at end of file
/**
*Created by huangwenjie on 2018/7/18
* 复活操作
*/
import { Data } from "../../Data";
export class DoReviveData extends Data {
/**
* 时间戳
*/
public timestamp:string;
/**
* 是否成功
*/
public isSuccess:boolean;
/**
* 复活卡数量
*/
public reviveCardNum:number;
/**
* 是否复活成功, true成功,false失败
*/
public status:boolean;
constructor() {
super();
}
public update(data: any): void {
if (!data) {
return;
}
super.update(data);
this.timestamp = data.timestamp;
this.isSuccess = data.success;
this.reviveCardNum = data.data.reviveCardNum;
this.status = data.data.status;
}
}
\ No newline at end of file
/**
*Created by huangwenjie on 2018/7/18
* 获得复活卡数量
*/
import { Data } from "../../Data";
export class GetReviveCardNumData extends Data {
/**
* 时间戳
*/
public timestamp:string;
/**
* 是否成功
*/
public isSuccess:boolean;
/**
* 复活卡数量
*/
public reviveCardNum:number;
constructor() {
super();
}
public update(data: any): void {
if (!data) {
return;
}
super.update(data);
this.timestamp = data.timestamp;
this.isSuccess = data.success;
this.reviveCardNum = data.data;
}
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/1
* 开始游戏
*/
import { Data } from "../../Data";
import { IExtraData } from "./ExtraData";
export class DoStartData extends Data {
/**
* 附加数据
*/
public extra: IExtraData;
/**
* 订单ID
*/
public ticketId: number;
/**
* 提交游戏数据token
*/
public submitToken: string;
/**
*
*/
public token: string;
/**
* 剩余积分
*/
public credits: number;
constructor() {
super();
}
public update(data: any): void {
if (!data) {
return;
}
super.update(data);
this.extra = data.extra;
this.ticketId = data.ticketId;
this.credits = data.credits;
this.submitToken = window['resolve'](data.submitToken);
this.token = window['resolve'](data.token);
}
}
\ No newline at end of file
import { IData } from "duiba-tc";
/**
*Created by cuiliqiang on 2018/3/12
* 开始游戏附加数据
*/
export interface IExtraData {
/**
* 初始分数
*/
initialScore: number;
/**
* 初始卡牌
*/
poker: number;
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/8
* 查询游戏订单结果
*/
import { Data } from "../../Data";
export class GetStartStatusData extends Data {
public update(data: any): void {
if (!data) {
return;
}
super.update(data);
}
}
\ No newline at end of file
import { IStatusData } from './IStatusData';
import { Data } from "../../Data";
export class GetInfoData extends Data {
/**
* 用户ID
*/
public consumerId: number;
/**
* 积分
*/
public credits: number;
/**
* 累计成绩
*/
public totalScore: number;
/**
* 最佳成绩
*/
public maxScore: number;
/**
* 最佳成绩产生时间
*/
public maxScoreTime: string;
/**
* 排名
*/
public rank: number;
/**
* 百分比排名
*/
public percentage: number;
/**
* 游戏状态
*/
public token: string;
/**
*
*/
public status: IStatusData;
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
let data;
if(result.data) {
if(result.data.rsp) {
data = result.data.rsp;
} else {
data = result.data;
}
}
this.consumerId = data.consumerId;
this.credits = data.credits;
this.totalScore = data.totalScore;
this.maxScore = data.maxScore;
this.maxScoreTime = data.maxScoreTime;
this.rank = data.rank;
this.percentage = data.percentage || 0;
if(data.token) {
this.token = window['resolve'](data.token);
}
this.status = data.status;
}
}
\ No newline at end of file
import { IStatusData } from './IStatusData';
import { Data } from "../../Data";
export class GetSummerInfoData extends Data {
/**
* 用户ID
*/
public consumerId: number;
/**
* 累计成绩
*/
public totalScore: number;
/**
* 最佳成绩
*/
public maxScore: number;
/**
* 游戏状态
*/
public status: IStatusData;
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
let data;
if(result.data) {
if(result.data.rsp) {
data = result.data.rsp;
} else {
data = result.data;
}
}
this.consumerId = data.consumerId;
this.totalScore = data.totalScore;
this.maxScore = data.maxScore;
this.status = data.status;
}
}
\ No newline at end of file
import { IData } from "duiba-tc";
/**
*Created by cuiliqiang on 2018/3/1
* 业务状态
*/
export interface IStatusData {
/**
* 按钮是否禁用 true不可点击 false可以点击
*/
btnDisable: boolean;
/**
* 按钮响应类型 click执行btnEvent url内部逻辑
*/
btnEventType: string;
/**
* 按钮处理内容
*/
btnEvent: string;
/**
* 按钮展示文案
*/
btnText: string;
/**
* 状态码 0开始游戏 1未登录 2积分不足 3参与次数用完 4已经结束等待开奖 5已开奖 6无大奖游戏结束
*/
code: number;
/**
* 业务展示文案
*/
text: string;
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/1
* 游戏奖项信息
*/
import { Data } from "../../Data";
import { IGameOptionData } from "./IGameOptionData";
export class GetOptionsData extends Data {
/**
* 奖品列表
*/
public optionList: IGameOptionData[];
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
this.optionList = result;
}
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/2
* 奖品数据
*/
export interface IGameOptionData {
/**
* 是否参与立即发奖
*/
autoOpen: boolean;
/**
* 奖品说明
*/
description: string;
/**
* 奖品图片
*/
logo: string;
/**
* 奖品名字
*/
name: string;
/**
* 排名范围(如:1-2)
*/
scope: string;
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/7
* 游戏规则数据
*/
import { Data } from './../../Data';
export class GetRuleData extends Data {
/**
* 规则文案
*/
public ruleText: any;
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
this.ruleText = result;
}
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/12
* 用户成长值数据
*/
import { Data } from "../../Data";
export class GetUserTotalScoreData extends Data {
/**
* 成长值
*/
private score: number;
public update(data: any): void {
if (!data) {
return;
}
super.update(data);
this.score = data.data;
}
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/9
* 猜扑克数据
*/
import { Data } from "../../Data";
export class GuessPokerData extends Data {
/**
* 是否猜中
*/
public isWin: boolean;
/**
* 发出的卡牌
*/
public poker: number;
/**
* 当前成长值
*/
public score: number;
/**
* 当前第几轮
*/
public times: number;
public update(data: any): void {
if (!data) {
return;
}
super.update(data);
if (!data.data) {
return;
}
this.isWin = data.data.win;
this.poker = data.data.poker;
this.score = data.data.score;
this.times = data.data.times;
}
}
\ No newline at end of file
import { DataManager } from './../../../manager/DataManager';
import { Data } from "../../Data";
import { IUserData } from '../common/IUserData';
/**
*Created by cuiliqiang on 2018/3/9
* 时时排行榜数据
*/
export class RealTimeRankData extends Data {
/**
* 是否在排行榜内
*/
public inRank: boolean;
/**
* 自己的排行数据
*/
public myUserData: IUserData;
/**
* 排行列表
*/
public userList: IUserData[];
public update(data: any): void {
if (!data) {
return;
}
super.update(data);
this.inRank = data.data.inRank;
if (data.data.user) {
this.myUserData = data.data.user;
DataManager.ins.getInfoData.rank = this.myUserData.rank;
}
this.userList = data.data.userList;
}
}
\ No newline at end of file
import { IExposureData } from './../../common/IExposureData';
import { GPool } from "duiba-tc";
import { GetInfoData } from './../getInfo/GetInfoData';
import { LotteryData } from './../../common/lottery/LotteryData';
import { Data } from './../../Data';
/**
* 获取游戏抽奖结果
*/
export class GameGetSubmitResultData extends Data {
/**
* 奖品数据
*/
public lottery: LotteryData;
/**
* 推啊数据埋点
*/
public exposure: IExposureData;
/**
* 再来一次埋点
*/
public againExposure: IExposureData;
/**
* 是否需要继续轮询
*/
public flag: boolean;
/**
* 本局分数
*/
public score: number;
public update(result: any): void {
if(!result) {
return;
}
super.update(result);
this.flag = result.data.flag;
if (result.data.option) {
this.lottery = GPool.takeOut('LotteryData', LotteryData);
if (!this.lottery) {
this.lottery = new LotteryData();
}
if (!result.data.option.lottery) {
result.data.option.lottery = {};
}
result.data.option.lottery.type = result.data.option.type;
result.data.option.lottery.stinfodpmgouse = result.data.useDpm;
result.data.option.lottery.stinfodpmimg = result.data.useDpm;
result.data.option.lottery.imgurl = result.data.option.image;
result.data.option.lottery.link = result.data.option.link;
result.data.option.lottery.name = result.data.option.name;
result.data.option.lottery.type = result.data.option.type;
this.lottery.update(result.data.option.lottery);
} else if (this.lottery) {
GPool.recover('LotteryData', this.lottery);
this.lottery = null;
}
if (this.lottery) {
this.exposure = result.data.option.lottery.exposure;
} else if (this.exposure) {
this.exposure = null;
}
this.againExposure = JSON.parse(result.data.againDpm);
this.score = result.data.score;
}
}
\ No newline at end of file
import { DataManager } from './../../../manager/DataManager';
import { Data } from './../../Data';
export class GameSubmitData extends Data {
/**
* 订单ID
*/
public orderId: number;
/**
* 百分比排名
*/
public percentage: number;
/**
* 更新
* @param result
*/
public update(result: any): void {
super.update(result);
if(result.data){
this.orderId = result.data.orderId;
this.percentage = DataManager.ins.getInfoData.percentage = result.data.rsp.percentage;
}
}
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/1
* 用户中奖信息
*/
export interface IConsumerData {
/**
* 用户ID
*/
cid: string;
/**
* 参与过活动
*/
join: boolean;
/**
* 奖品名字
*/
option: string;
/**
* 用户ID
*/
rank: string;
}
\ No newline at end of file
import { IUserData } from "../common/IUserData";
/**
*Created by cuiliqiang on 2018/3/1
* 奖项及中奖用户列表
*/
export interface IRankData {
/**
* 奖品名字
*/
name: string;
/**
* 展示图片
*/
imageUrl: string;
/**
* 中奖用户列表
*/
users: IUserData[];
}
\ No newline at end of file
import { Data } from "../../Data";
import { IConsumerData } from "./IConsumerData";
import { IRankData } from "./IRankData";
/**
*Created by cuiliqiang on 2018/3/1
* 中奖数据
*/
export class WinRanksData extends Data {
/**
* 用户数据
*/
public consumer: IConsumerData;
/**
* 排行列表
*/
public rankList: IRankData[];
public update(data: any): void {
if (!data) {
return;
}
super.update(data);
this.consumer = data.consumer;
this.rankList = data.ranks;
}
}
\ No newline at end of file
import { Data } from "../Data";
/**
* 收取礼物
*/
export class CollectData extends Data {
public update(result: any): void {
if(!result) {
return;
}
super.update(result);
}
}
\ No newline at end of file
import { Data } from './../Data';
export class GetFoodPilesData extends Data {
public list:any[];
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
this.list = result.data;
}
}
\ No newline at end of file
export interface GetRankItemData {
/**
* 用户id
*/
consumerId:number;
/**
* 昵称
*/
nickname:string;
/**
* 头像
*/
avatar:string;
/**
* 排名
*/
rank:number;
/**
* 投食数量
*/
feedCount:string;
}
\ No newline at end of file
import { Data } from './../Data';
import { GetRankItemData } from './GetRankItemData';
export class GetRankListData extends Data {
/**
* 排名列表
*/
public list: GetRankItemData[];
/**
* 我的排行数据
*/
public myUserData: GetRankItemData;
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
if(!result.data){
return;
}
this.list = result.data.rankList;
if(result.data.user){
this.myUserData = result.data.user;
}
}
}
\ No newline at end of file
import { Data } from "../Data";
import { IToyItemData } from "./IToyItemData";
/**
* 道具展示接口
*/
export class GetToysData extends Data {
/**
* 道具列表
*/
public list: IToyItemData[];
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
this.list = result.data;
}
}
\ No newline at end of file
/**
*Created by ck on 2018/5/16
*/
export interface IPetToyData {
/**
* 道具id
*/
toyId: number;
/**
* 道具名字
*/
toyName: string;
/**
* 是否有状态(无状态即为装饰道具)
*/
withStatus: boolean;
/**
* 道具标识
*/
identifier: string;
/**
* 道具描述
*/
description: string;
}
\ No newline at end of file
/**
* 单个道具数据
*/
export interface IToyItemData {
/**
* 道具id
*/
toyId: number;
/**
* 道具名字
*/
toyName: string;
/**
* 积分消耗
*/
credits: number;
/**
* 道具标识
*/
identifier: string;
/**
* 道具描述
*/
description: string;
/**
* 道具数量
*/
count: number;
}
\ No newline at end of file
import { Data } from "../Data";
/**
* 宠物领养
*/
export class PetAdopteData extends Data {
/**
* 宠物id
*/
public petId: number;
/**
* 活动id
*/
public activityId: string;
/**
* 宠物名称
*/
public petName: string;
/**
* 宠物等级
*/
public petLevel: number;
/**
* 累计收到食物
*/
public totalReceivedNum: number;
/**
* 累计消耗食物
*/
public totalEatNum: number;
/**
* 当前状态(1:正常 2:外出 3:吃饭 4:学习 5:喝水 6:睡觉)
*/
public status: number;
/**
* 拥有萝卜数量
*/
public foodNum: number;
/**
* 状态剩余时间
*/
public leftMinutes: number;
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
if(!result.data) {
return;
}
result = result.data;
this.petId = result.petId;
this.activityId = result.activityId;
this.petName = result.petName;
this.petLevel = result.petLevel;
this.totalReceivedNum = result.totalReceivedNum;
this.totalEatNum = result.totalEatNum;
this.status = result.status;
this.foodNum = result.foodNum;
this.leftMinutes = result.leftMinutes;
}
}
\ No newline at end of file
import { Data } from "../Data";
/**
* 宠物喂食
*/
export class PetFeedData extends Data {
/**
* 错误标识码(见状态码-宠物养成-喂食错误码)
*/
public errorCode: string;
/**
* 当前状态(1:正常 2:外出 3:吃饭 4:学习 5:喝水 6:睡觉)
*/
public status: number;
/**
* 拥有萝卜数量
*/
public foodNum: number;
/**
* 状态剩余时间
*/
public leftMinutes: number;
/**
* 喂食周期剩余时间(分钟)
*/
public feedIntervalRemain: number;
public update(result: any): void {
if (!result) {
return;
}
result.message = window['errorMessage'] ? window['errorMessage'][result.errorCode] : "";
super.update(result);
this.errorCode = result.errorCode;
if (result.data) {
this.status = result.data.status;
this.foodNum = result.data.foodNum;
this.leftMinutes = result.data.leftMinutes;
this.feedIntervalRemain = result.data.feedIntervalRemain;
}
}
}
\ No newline at end of file
import { Data } from "../Data";
import { IPetToyData } from "./IPetToyData";
export class PetHomeInfoData extends Data {
/**
* 宠物id
*/
public petId: number;
/**
* 当前状态(1:正常 2:外出 3:吃饭 4:学习 5:喝水 6:睡觉)
*/
public status = 0;
/**
* 状态过期倒计时(单位:分钟,目前只针对吃饭状态有此值)
*/
public leftMinutes = "0";
/**
* 是否是吃饱状态
*/
public isFull: boolean;
/**
* 宠物名称
*/
public petName = "";
/**
* 宠物等级
*/
public petLevel = 0;
/**
* 饲养员拥有食物量
*/
public foodNum = 0;
/**
* 食物名称
*/
public foodName = "";
/**
* 每次喂养食物数量
*/
public feedLimit = 10;
/**
* 宝箱插件id
*/
public awardPluginId = 0;
/**
* 外出奖励(-1:自定义奖励 0:无奖励 1:粮食奖励)
*/
public travelRewardType = 0;
/**
* 外出奖励个数(针对粮食奖励)
*/
public travelRewardNum = 0;
/**
* 宠物正在使用的道具数据
*/
public toy: IPetToyData[] = [];
/**
* 等级奖励插件ID
*/
public levelRewardPluginId:number;
/**
* 当前经验值
*/
public petExp:number;
/**
* 当前级别初始的经验值
*/
public currentLevelExp:number;
/**
* 下个级别初始的经验值
*/
public nextLevelExp:number;
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
let result2;
if (result.data) {
result2 = result.data;
}
if(result2){
if (result2.petId) {
this.petId = result2.petId;
}
if (result2.status) {
this.status = result2.status;
}
if (result2.leftMinutes) {
this.leftMinutes = result2.leftMinutes;
}
if (result2.isFull) {
this.isFull = result2.isFull;
}
if (result2.petName) {
this.petName = result2.petName;
}
if (result2.petLevel) {
this.petLevel = result2.petLevel;
}
if (result2.foodNum) {
this.foodNum = result2.foodNum;
}
if (result2.foodName) {
this.foodName = result2.foodName;
}
if (result2.feedLimit) {
this.feedLimit = result2.feedLimit;
}
if (result2.awardPluginId) {
this.awardPluginId = result2.awardPluginId;
}
if (result2.travelRewardType) {
this.travelRewardType = result2.travelRewardType;
}
if (result2.travelRewardNum) {
this.travelRewardNum = result2.travelRewardNum;
}
this.toy = result2.toy;
if(result2.levelRewardPluginId){
this.levelRewardPluginId = result2.levelRewardPluginId;
}
if(result2.petExp){
this.petExp = result2.petExp;
}
if(result2.currentLevelExp){
this.currentLevelExp = result2.currentLevelExp;
}
if(result2.nextLevelExp){
this.nextLevelExp = result2.nextLevelExp;
}
}
}
}
\ No newline at end of file
/**
*Created by ck on 2018/5/2
*/
import { Data } from "../Data";
import { PetHomeInfoData } from "./PetHomeInfoData";
export class PetIndexData extends Data {
/**
* 积分
*/
public credits: number;
/**
* 积分单位
*/
public creditsUnitName: string;
/**
*
*/
public partnerUserId: string;
/**
* appId
*/
public appId: number;
/**
* 当前时间
*/
public currentTime: string;
/**
* 是否未登录
*/
public notLogin: any;
/**
* 商品域名
*/
public goodsDomain:string;
/**
* 楼层域名
*/
public homeDomain:string;
/**
* 埋点域名
*/
public embedDomain:string;
/**
* 唤起登录代码
*/
public openLogin:string;
/**
* 登录参数
*/
public loginProgram:string;
/**
* 用户自定义参数
*/
public dcustom:object = {};
/**
* 活动id
*/
public activityId:number;
/**
* 用户id
*/
public consumerId:number;
/**
* 首页宠物相关信息
*/
public petHomeInfo: PetHomeInfoData;
public update(result: any): void {
if(!result) {
return;
}
if(result.credits){
this.credits = result.credits;
}
if(result.creditsUnitName){
this.creditsUnitName = result.creditsUnitName;
}
if(result.partnerUserId){
this.partnerUserId = result.partnerUserId;
}
if(result.appId){
this.appId = result.appId;
}
if(result.currentTime){
this.currentTime = result.currentTime;
}
if(result.notLogin){
this.notLogin = result.notLogin;
}
if(result.goodsDomain){
this.goodsDomain = result.goodsDomain;
}
if(result.homeDomain){
this.homeDomain = result.homeDomain;
}
if(result.embedDomain){
this.embedDomain = result.embedDomain;
}
if(result.openLogin){
this.openLogin = result.openLogin;
}
if(result.loginProgram){
this.loginProgram = result.loginProgram;
}
if(result.dcustom){
this.dcustom = result.dcustom;
}
if(result.activityId){
this.activityId = result.activityId;
}
if(result.consumerId){
this.consumerId = result.consumerId;
}
// if(!this.petHomeInfo) {
// this.petHomeInfo = new PetHomeInfoData();
// }
// this.petHomeInfo.update(result.data);
}
}
\ No newline at end of file
import { Data } from "../Data";
/**
* 宠物状态刷新
*/
export class PetStatusData extends Data {
/**
* 当前状态(1:正常 2:外出 3:吃饭 4:学习 5:喝水 6:睡觉)
*/
public status: number;
/**
* 状态过期倒计时(单位:分钟,目前只针对吃饭状态有此值)
*/
public leftMinutes: string;
public update(result: any): void {
if (!result || !result.data) {
return;
}
super.update(result);
result = result.data;
this.status = result.status;
this.leftMinutes = result.leftMinutes;
}
}
\ No newline at end of file
import { SignInfoVo } from "./SignInfoVo";
import { Data } from "../Data";
/**
* 签到
*/
export class SignInfoData extends Data {
/**
* 签到流水ID
*/
public logId: number;
/**
* 签到信息
*/
public signInfoVO: SignInfoVo;
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
this.logId = result.logId;
this.signInfoVO = new SignInfoVo();
this.signInfoVO.update(result.signInfoVO);
}
}
\ No newline at end of file
import { IData } from "../../../tc/interface/IData";
// import { IData } from "duiba-tc";
/**
* 签到信息查询
*/
export class SignInfoVo implements IData {
/**
* 抽期内累计签到天数
*/
public acmDays = 0;
/**
* 今日奖励抽奖次数
*/
public activityCount = 0;
/**
* 明天签到奖励抽奖次数
*/
public activityCountTomorrow = 0;
/**
* 连续签到天数
*/
public continueDay = 0;
/**
* 今日签到奖励积分
*/
public credits = 0;
/**
* 明日签到奖励抽奖次数
*/
public creditsTomorrow = 0;
/**
* 首次签到日期
*/
public firstSignDate = 0;
/**
* 是否有累计奖励
*/
public hasAcmReward = false;
/**
* 连续签到天数
*/
public lastDays = 0;
/**
* 连续签到天数
*/
public monthResignedMap: any;
/**
* 周期内已签到日期记录
*/
public monthSignedMap: any;
/**
* 今天是否已签到
*/
public todaySigned = false;
/**
* 奖励集合
*/
public rewardMap: any;
public update(result: any): void {
if (!result) {
return;
}
this.acmDays = result.acmDays;
this.activityCount = result.activityCount;
this.activityCountTomorrow = result.activityCountTomorrow;
this.continueDay = result.continueDay;
this.credits = result.credits;
this.creditsTomorrow = result.creditsTomorrow;
this.firstSignDate = result.firstSignDate;
this.hasAcmReward = result.hasAcmReward;
this.lastDays = result.lastDays;
this.monthResignedMap = result.monthResignedMap;
this.monthSignedMap = result.monthSignedMap;
this.todaySigned = result.todaySigned;
if (result.rewardMap) {
this.rewardMap = result.rewardMap;
}
}
}
\ No newline at end of file
import { Data } from "../Data";
/**
* 道具兑换接口
*/
export class ToyExchangeData extends Data {
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
}
}
\ No newline at end of file
import { Data } from "../Data";
/**
* 道具使用
*/
export class ToyUseData extends Data {
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
}
}
\ No newline at end of file
import { Data } from './../Data';
export interface GetActToysItemData{
/**
* 是否可重复购买
*/
canRepeatePurchase:boolean;
/**
* 道具兑换价值
*/
cost:number;
/**
* 道具描述
*/
description:string;
/**
* 道具兑换方式:1-积分 2-粮食
*/
exchangeType:number;
/**
* 道具主键id
*/
id:number;
/**
* 道具标识
*/
identifier:string;
/**
* 道具对当前用户是否开启
*/
openStatus:boolean;
/**
* 道具名称
*/
toyName:string;
/**
* 道具类型:1-状态类 2-装饰类 3-功能类 4-食物类 5-玩具类
*/
toyType:number;
/**
* 道具图片
*/
imgUrl:string;
/**
* 是否已经购买:针对不可重复购买的道具
*/
alreadyPurchased:boolean;
/**
* 是否因经验值不足无法开启
*/
expLimited:boolean;
}
\ No newline at end of file
import { Data } from './../Data';
import { GetActToysItemData } from '../pets/GetActToysItemData';
export class GetActToysListData extends Data {
/**
* 道具列表
*/
public toyList: GetActToysItemData[];
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
this.toyList = result.data;
}
}
\ No newline at end of file
import { Data } from "../Data";
import { IUsingPetToysData } from "./IUsingPetToysData";
import { IWanderPetData } from "./IWanderPetData";
export class GetHomeInfoData extends Data {
/**
* 账户额度上限
*/
public accountBalanceLimit: number;
/**
* 每份待领取个数
*/
public amountPerPiles: number;
/**
* 是否有新动态
*/
public hasNewInfo: boolean;
/**
* 是否有待领取礼物
*/
public hasGift: boolean;
/**
* 距离下一次投放道具剩余的时间(分钟)
*/
public nextPeriodBegin: number;
/**
* 正在投放的道具
*/
public usingPetToys: IUsingPetToysData[];
/**
* 正在来访的宠物
*/
public wanderPet: IWanderPetData;
/**
* 当前粮食数
*/
public accountBalance: number;
/**
* 待收取粮食列表
* [{id:1, foodNum:10}, {id:2, foodNum:20}]
*/
public foodPiles: any;
/**
* 是否为新用户
*/
public newUser:boolean;
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
let data;
if (result.data) {
data = result.data;
}
if(data){
this.accountBalanceLimit = data.accountBalanceLimit;
this.amountPerPiles = data.amountPerPiles;
this.hasNewInfo = data.hasNewInfo;
this.hasGift = data.hasGift;
this.nextPeriodBegin = data.nextPeriodBegin;
this.usingPetToys = data.usingPetToys;
this.wanderPet = data.wanderPet;
this.accountBalance = data.accountBalance;
this.foodPiles = data.foodPiles;
this.newUser = data.newUser;
}
}
}
\ No newline at end of file
import { Data } from './../Data';
export interface GetUserToysItemData{
/**
* 道具个数(同一标识)
*/
count:number;
/**
* 道具描述
*/
description:string;
/**
* 道具标识
*/
identifier:string;
/**
* 道具图片
*/
imgUrl:string;
/**
* 道具名称
*/
toyName:string;
/**
* 道具类型:1-状态类 2-装饰类 3-功能类 4-食物类 5-玩具类
*/
toyType:number;
}
\ No newline at end of file
import { Data } from "../Data";
import { GetUserToysItemData } from "./GetUserToysItemData";
/**
* 道具使用
*/
export class GetUserToysListData extends Data {
/**
* 我的道具列表
*/
public myToyList: GetUserToysItemData[];
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
this.myToyList = result.data;
}
}
\ No newline at end of file
import { IPetMsgData } from './IPetMsgData';
import { Data } from './../Data';
export class GetVisitInfoData extends Data {
public data:IPetMsgData[];
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
this.data = result.data;
}
}
\ No newline at end of file
export interface IPetMsgData{
id:number; //记录主键ID
acceted:boolean;
eatToyName:string; //吃的食物道具名称
petName:string; //宠物名称
playToyName:string; //玩的道具名称
readStatus:boolean; //是否已读
recordType:number; //记录类型:1.到访 2.礼物
showTime:number; //发生时间
pluginId:number; //礼物插件ID(礼物类型)
}
\ No newline at end of file
/**
*Created by ck on 2018/8/25
*/
export interface IPlayToyDetailData {
/**
* 发生时间
*/
occurTime: number;
/**
* 玩具名称
*/
playToyName: string;
}
\ No newline at end of file
import { IData } from "duiba-tc";
/**
*Created by ck on 2018/5/16
*/
export interface IUsingPetToysData {
/**
* 道具标识
*/
identifier: string;
/**
* 道具类型:1-状态类 2-装饰类 3-功能类 4-食物类 5-玩具类
*/
toyType: string;
/**
* 道具投放位置
*/
usePosition: number;
}
\ No newline at end of file
import { IData } from "duiba-tc";
/**
*Created by ck on 2018/8/24
*/
export interface IVisitPetData {
/**
* 宠物唯一标识
*/
identifier: string;
/**
* 宠物头像
*/
petAvatar: string;
/**
* 宠物头像大图
*/
petAvatarBig: string;
/**
* 描述
*/
petDesc: string;
/**
* 宠物名字
*/
petName: string;
/**
* 来访次数
*/
visitTimes: number;
/**
* 1:普通,2:稀有
*/
petLevel: number;
/**
* 是否是最新
*/
newVisit: boolean;
}
\ No newline at end of file
// import { IData } from "duiba-tc";
/**
*Created by ck on 2018/5/16
*/
export interface IWanderPetData {
/**
* 宠物标识
*/
petIdentifier: string;
/**
* 宠物状态: 1-吃食物 2-玩玩具
*/
status: number;
/**
* 道具标识(食物或玩具)
*/
toyIdentifier: string;
}
\ No newline at end of file
/**
*Created by ck on 2018/5/2
*/
// import { IData } from "duiba-tc";
import { Data } from "../Data";
import { GetHomeInfoData } from "./GetHomeInfoData";
export class PetsIndexData extends Data {
/**
* 积分
*/
public credits: number;
/**
* 积分单位
*/
public creditsUnitName: string;
/**
* 用户uid
*/
public uid: string;
/**
* appId
*/
public appId: number;
/**
* 是否未登录
*/
public notLogin: boolean;
/**
* 用户id(未登录时为空)
*/
public consumerId:number;
/**
* 商品域名
*/
public goodsDomain:string;
/**
* 楼层域名
*/
public homeDomain:string;
/**
* 埋点域名
*/
public embedDomain:string;
/**
* 用户自定义参数
*/
public dcustom:object = {};
/**
* 活动id
*/
public activityId:number;
public update(result: any): void {
if(!result) {
return;
}
this.credits = result.credits;
this.creditsUnitName = result.creditsUnitName;
this.uid = result.uid;
this.appId = result.appId;
this.notLogin = result.notLogin;
this.goodsDomain = result.goodsDomain;
this.homeDomain = result.homeDomain;
this.embedDomain = result.embedDomain;
this.dcustom = result.dcustom;
this.activityId = result.activityId;
this.consumerId = result.consumerId;
}
}
\ No newline at end of file
import { Data } from "../Data";
/**
* 外来宠物养成-道具兑换接口
*/
export class ToyExchangesData extends Data {
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
}
}
\ No newline at end of file
import { Data } from "../Data";
/**
* 道具使用
*/
export class UseToyData extends Data {
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
}
}
\ No newline at end of file
import { Data } from './../Data';
import { IPlayToyDetailData } from './IPlayToyDetailData';
export class VisitDetailData extends Data {
/**
* 宠物id
*/
public id: number;
/**
* 宠物唯一标识
*/
public identifier: string;
/**
* 宠物头像
*/
public petAvatar: string;
/**
* 宠物头像大图
*/
public petAvatarBig: string;
/**
* 描述
*/
public petDesc: string;
/**
* 宠物名字
*/
public petName: string;
/**
* 玩玩具记录
*/
public playToyDetail: IPlayToyDetailData[];
/**
* 来访次数
*/
public visitTimes: number;
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
if (result.data) {
this.id = result.data.id;
this.identifier = result.data.identifier;
this.petAvatar = result.data.petAvatar;
this.petAvatarBig = result.data.petAvatarBig;
this.petDesc = result.data.petDesc;
this.petName = result.data.petName;
this.playToyDetail = result.data.playToyDetail;
this.visitTimes = result.data.visitTimes;
}
}
}
\ No newline at end of file
import { Data } from './../Data';
import { IVisitPetData } from './IVisitPetData';
export class VisitStatisticsData extends Data {
/**
* 宠物总数
*/
public total: number;
/**
* 已来访个数
*/
public visitPetCount: number;
/**
* 宠物列表信息
*/
public pet: IVisitPetData[];
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
if (result.data) {
this.total = result.data.total;
this.visitPetCount = result.data.visitPetCount;
this.pet = result.data.pet;
}
}
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/7
* 插件抽奖接口
*/
import { Data } from "../../Data";
export class DoJoinPlugDrawData extends Data {
/**
* 订单ID
*/
public orderId: number;
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
this.orderId = result.orderId;
}
}
\ No newline at end of file
import { IExposureData } from './../../common/IExposureData';
// import { GPool } from "duiba-tc";
import { LotteryData } from "../../common/lottery/LotteryData";
import { Data } from "../../Data";
import { GPool } from '../../../../tc/util/GPool';
/**
*Created by cuiliqiang on 2018/3/8
* 查询插件订单结果
*/
export class GetPlugOrderStatusData extends Data {
/**
* 订单状态 0:订单处理中 1:谢谢参与(有lottery) 2:中奖 -1:订单出错(当谢谢参与处理,没有lottery)
*/
public result: number;
/**
* 推啊埋点数据
*/
public exposure: IExposureData;
/**
* 奖品数据
*/
public lottery: LotteryData;
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
this.result = result.result;
if (result.exposure) {
this.exposure = result.exposure;
} else if (this.exposure) {
this.exposure = null;
}
if (result.lottery && result.lottery.type != 'thanks') {
this.lottery = GPool.takeOut('LotteryData', LotteryData);
if (!this.lottery) {
this.lottery = new LotteryData();
}
this.lottery.update(result.lottery);
} else {
GPool.recover('LotteryData', this.lottery);
this.lottery = null;
}
}
}
import { Data } from "../../Data";
import { IPrizeData } from "./IPrizeData";
/**
*Created by cuiliqiang on 2018/3/30
* 查询插件剩余抽奖次数
*/
export class GetPrizeInfoData extends Data {
/**
* 需要消耗的积分
*/
public creditsPrice: number;
/**
* 周期每天/永久
*/
public limitScope: number;
/**
* 剩余次数
*/
public limitCount: number;
/**
* 规则
*/
public ruleDescription: string;
/**
* 时间
*/
public rateDescription: string;
/**
* 奖品列表
*/
public prizeList: IPrizeData[];
public update(data: any): void {
if (!data) {
return;
}
super.update(data);
this.creditsPrice = data.creditsPrice;
this.limitScope = data.limitScope;
this.limitCount = data.limitCount;
this.ruleDescription = data.ruleDescription;
this.rateDescription = data.rateDescription;
this.prizeList = data.prize;
}
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/30
* 商品数据
*/
export interface IPrizeData {
id: number;
activityId: number;
activityType: string;
appItemId: number;
itemId: number;
gId: number;
gType: string;
prizeType: string;
prizeName: string;
facePrice: number;
stockId: number;
rate: number;
description: string;
payload: number;
hidden: boolean;
minComein: number;
winLimit: number;
logo: string;
otherUse: string;
stockWarning: number;
rolling: number;
prizesLimit: string;
gmtCreate: number;
gmtModified: number;
}
\ No newline at end of file
import { IPlugOptionData } from "./IPlugOptionData";
/**
*Created by cuiliqiang on 2018/3/9
* 插件数据
*/
export interface IPlugData {
/**
* 插件ID
*/
plugId: number;
/**
* 奖品列表
*/
options: IPlugOptionData[];
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/9
* 插件奖项数据
*/
export interface IPlugOptionData {
/**
* 插件ID
*/
id: number;
/**
* 数量
*/
count: number;
/**
* 名字
*/
name: string;
/**
* 展示图片
*/
img: string;
/**
* 类型
*/
type: string;
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/9
* 插件奖项数据
*/
import { Data } from "../../Data";
import { IPlugData } from "./IPlugData";
export class OptionInfoData extends Data {
public plugList: IPlugData[];
public update(result: any): void {
if (!result) {
return;
}
super.update(result);
this.plugList = result.data.list;
}
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/9
* 解锁插件数据
*/
import { Data } from "../../Data";
export class UnblockingData extends Data {
/**
* 解锁反馈success返回true时才有;0:解锁成功; 1:重复解锁; 2:未到解锁时间
*/
public status: number;
public update(data: any): void {
if (!data) {
return;
}
super.update(data);
if (data.data) {
this.status = data.data.status;
}
}
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/16
*
*/
export enum LotteryType {
//福袋
LUCKY = 'lucky',
//虚拟商品
VIRTUAL = 'virtual',
//实物
OBJECT = 'object',
//优惠券
COUPON = 'coupon',
//支付宝
ALIPAY = 'alipay',
//话费
PHONEBILL = 'phonebill',
//Q币
QB = 'qb',
//集卡
COLLECT_GOODS = 'collectGoods'
}
\ No newline at end of file
export enum NetName {
//游戏
GAME_INFO = 1,
GAME_SUMMERINFO,
GAME_START,
GAME_START_STATUS,
GAME_SUBMIT,
GAME_SUBMIT_STATUS,
GAME_RANKS,
GAME_OPTIONS,
GAME_RULE,
GAME_REAL_TIME_RANK,
GAME_DATA_PASH,
GAME_GUESS_POKER,
GAME_TOTAL_SCORE,
GAME_REVIVE,
GAME_REVIVE_STATUS,
GAME_SUMMER_BUYPROP,//购买鱼钩鱼线道具
GAME_SUMMER_GET_ORDER_STATUS,//查询购买鱼钩鱼线道具订单是否成功
GAME_SUMMER_GET_TOY_INFO,//查询购买鱼钩鱼线道具订单是否成功
//活动工具
CUSTOM_ELEMENT,
CUSTOM_THROUGH_INFO,
CUSTOM_DO_JOIN,
CUSTOM_ORDER_STATUS,
CUSTOM_ORDER_INFO,
CUSTOM_BEFOR_SUBMIT,
CUSTOM_QUESTION_SUBMIT,
CUSTOM_THROUGH_SUBMIT,
CUSTOM_PRIZE_DETAIL,
//插件
PLUG_DO_JOIN,
PLUG_ORDER_STATUS,
PLUG_OPTION_INFO,
PLUG_UNBLOCKING,
PLUG_PRIZE_INFO,
//全局
GET_ROLE,
SET_ROLE,
GET_CREDITS,
ADD_TIMES,
COLLECT_RULE,
OPEN_COLLECT,
WINNERS,
GET_TOKEN,
//宠物养成
PET_ADOPTE,
PET_STATUS,
PET_INFO,
PET_FEED,
PET_TOYS,
PET_TOY_EXCHANGE,
PET_TOY_USE,
PET_COLLECT,
PET_GET_RANK_LIST,
PET_GET_FOOD_PILES,
PET_COLLECT_FOOD,
//外来宠物养成
PETS_GET_HOME_INFO,
PETS_GET_ACT_TOYS,
PETS_GET_USER_TOYS,
PETS_USE_TOYS,
PETS_TOY_EXCHANGE,
PETS_BATCHOLLECT_FOOD,
PETS_VISI_STATISTICS,
PETS_GET_VISIT_INFO,
PETS_VISIT_DETAIL,
PETS_COLLECT_GIFT_RECORD,
//签到
SIGN_INFO,
SIGN_DO_SIGN,
//查询奖品记录
GET_RECORD
}
\ No newline at end of file
import { GetVisitInfoData } from './../data/pets/GetVisitInfoData';
import { GetSummerInfoData } from './../data/game/getInfo/GetSummerInfoData';
import { GetReviveCardNumData } from './../data/game/doRevive/GetReviveCardNumData';
import { DoReviveData } from './../data/game/doRevive/DoReviveData';
import { DoJoinPlugDrawData } from './../data/plug/doJoinPlugDraw/DoJoinPlugDrawData';
import { NetName } from './../enum/NetName';
import { QuestionSubmitData } from './../data/custom/questionSbumit/QuestionSubmitData';
import { GetCollectRuleData } from './../data/common/getCollectRule/GetCollectRuleData';
import { DatapashData } from './../data/game/datapash/DatapashData';
import { OpenCollectGoodsPrizeData } from './../data/common/openCollectGoodsPrize/openCollectGoodsPrizeData';
import { TwLang } from "../util/TwLang";
import { DoStartData } from "../data/game/doStart/DoStartData";
import { GetStartStatusData } from "../data/game/doStart/GetStartStatusData";
import { GetInfoData } from "../data/game/getInfo/GetInfoData";
import { GetOptionsData } from "../data/game/getOptions/GetOptionsData";
import { GetRuleData } from "../data/game/getRule/GetRuleData";
import { GetUserTotalScoreData } from "../data/game/getUserTotalScore/GetUserTotalScoreData";
import { GuessPokerData } from "../data/game/guessPoker/GuessPokerData";
import { GameSubmitData } from "../data/game/submit/GameSubmitData";
import { RealTimeRankData } from "../data/game/realtimerank/RealTimeRankData";
import { WinRanksData } from "../data/game/winranks/WinRanksData";
import { AjaxElementData } from "../data/custom/ajaxElement/AjaxElementData";
import { DoJoinData } from "../data/custom/doJoin/DoJoinData";
import { AjaxThroughInfoData } from "../data/custom/ajaxThroughInfo/AjaxThroughInfoData";
import { GetOrderInfoData } from "../data/custom/getOrderInfo/GetOrderInfoData";
import { GetCustomOrderStatusData } from "../data/custom/doJoin/GetCustomOrderStatusData";
import { GetRoleData } from "../data/common/getRole/GetRoleData";
import { GetCreditsData } from "../data/common/getCredits/GetCreditsData";
import { AddTimesForActivityData } from "../data/common/addTimesForActivity/AddTimesForActivityData";
import { SetRoleData } from "../data/common/setRole/SetRoleData";
import { GameGetSubmitResultData } from './../data/game/submit/GameGetSubmitResultData';
import { ThroughSubmitData } from '../data/custom/throughSubmit/ThroughSubmitData';
import { BeforSubmitData } from '../data/custom/beforSubmit/BeforSubmitData';
import { PetAdopteData } from "../data/pet/PetAdopteData";
import { PetFeedData } from "../data/pet/PetFeedData";
import { PetStatusData } from "../data/pet/PetStatusData";
import { SignInfoData } from "../data/pet/SignInfoData";
import { PetHomeInfoData } from "../data/pet/PetHomeInfoData";
import { GetToysData } from "../data/pet/GetToysData";
import { ToyExchangeData } from "../data/pet/ToyExchangeData";
import { ToyUseData } from "../data/pet/ToyUseData";
import { CollectData } from "../data/pet/CollectData";
import { Data } from '../data/Data';
import { GetPlugOrderStatusData } from '../data/plug/doJoinPlugDraw/GetPlugOrderStatusData';
import { OptionInfoData } from '../data/plug/optionInfo/OptionInfoData';
import { UnblockingData } from '../data/plug/unblocking/UnblockingData';
import { GetPrizeInfoData } from '../data/plug/getPrizeInfo/GetPrizeInfoData';
// import { ABDataManager } from 'duiba-tc';
import { PetIndexData } from '../data/pet/PetIndexData';
// import { ICustomCfgData } from '..';
import { IGameCfgData } from '../data/game/cfg/IGameCfgData';
import { GetRankListData } from '../data/pet/GetRankListData';
import { GetFoodPilesData } from '../data/pet/GetFoodPilesData';
import { GetRecordData } from '../data/common/GetRecordData';
import { UseToyData } from '../data/pets/UseToyData';
import { GetActToysListData } from '../data/pets/GetActToysListData';
import { ToyExchangesData } from '../data/pets/ToyExchangesData';
import { GetUserToysListData } from '../data/pets/GetUserToysListData';
import { GetHomeInfoData } from '../data/pets/GetHomeInfoData';
import { PetsIndexData } from '../data/pets/PetsIndexData';
import { VisitStatisticsData } from '../data/pets/VisitStatisticsData';
import { VisitDetailData } from '../data/pets/VisitDetailData';
import { ABDataManager } from '../../tc/manager/ABDataManager';
import { ICustomCfgData } from '../data/custom/cfg/ICustomCfgData';
/**
*Created by cuiliqiang on 2018/3/8
* 数据管理
*/
export class DataManager extends ABDataManager {
private static instance: DataManager;
public static get ins(): DataManager {
if (!this.instance) {
this.instance = new DataManager();
}
return this.instance;
}
private isInit: boolean;
constructor() {
super();
if (this.isInit) {
throw Error(TwLang.lang_001);
}
this.isInit = true;
}
/**
* 游戏业务
*/
public gameCfgData: IGameCfgData;
/**
* 自定义活动工具业务
*/
public customCfgData: ICustomCfgData;
private _getInfoData: GetInfoData;
private _getSummerInfoData: GetSummerInfoData;
private _getRoleData: GetRoleData;
private _getUserTotalScoreData: GetUserTotalScoreData;
private _getCreditsData: GetCreditsData;
private _doStartData: DoStartData;
private _getStartStatusData: GetStartStatusData;
private _doReviveData: DoReviveData;
private _getReviveCardNumData: GetReviveCardNumData;
private _gameSubmitData: GameSubmitData;
private _gameGetSubmitResultData: GameGetSubmitResultData;
private _winRanksData: WinRanksData;
private _getOptionsData: GetOptionsData;
private _getRuleData: GetRuleData;
private _addTimesForActivityData: AddTimesForActivityData;
private _getCollectRuleData: GetCollectRuleData;
private _openCollectGoodsPrizeData: OpenCollectGoodsPrizeData;
private _realTimeRankData: RealTimeRankData;
private _doJoinPlugDrawData: DoJoinPlugDrawData;
private _getPlugOrderStatusData: GetPlugOrderStatusData;
private _setRoleData: SetRoleData;
private _ajaxElementData: AjaxElementData;
private _ajaxThroughInfoData: AjaxThroughInfoData;
private _doJoinData: DoJoinData;
private _getCustomOrderStatusData: GetCustomOrderStatusData;
private _getOrderInfoData: GetOrderInfoData;
private _throughSubmitData: ThroughSubmitData;
private _beforSubmitData: BeforSubmitData;
private _questionSubmitData: QuestionSubmitData;
private _guessPokerData: GuessPokerData;
private _optionInfoData: OptionInfoData;
private _unblockingData: UnblockingData;
private _datapashData: DatapashData;
private _summerBuyPropData: any;
private _summerOrderStatus: any;
private _summerToyInfo: any;
/**
* 签到业务
*/
public petIndexData: PetIndexData = new PetIndexData();//用户基础数据
private _petAdopteData: PetAdopteData;
private _petFeedData: PetFeedData;
private _petStatusData: PetStatusData;
private _petHomeInfoData: PetHomeInfoData;
private _getToysData: GetToysData;//暂时不用
private _toyExchangeData: ToyExchangeData;//暂时不用
private _toyUseData: ToyUseData;//暂时不用
private _collectData: CollectData;
private _signInfoData: SignInfoData;//签到信息
private _getRankListData: GetRankListData;//群内喂食排行榜
private _getFoodPilesData: GetFoodPilesData;//查询待领取粮食
/**
* 外来宠物养成
*/
public petsIndexData: PetsIndexData = new PetsIndexData();//外来宠物活动主页
private _getHomeInfoData: GetHomeInfoData;//活动主信息接口
private _getActToysListData: any = [];//商店道具接口
private _toyExchangesData:ToyExchangesData;//道具兑换
private _useToyData:UseToyData;//道具使用
private _getUserToysListData:GetUserToysListData;//已购买的道具
private _batchollectFoodData:Data;//粮食收取返回
private _visitStatisticsData: VisitStatisticsData;//来访统计
private _getVisitInfoData:GetVisitInfoData;//来访统计
private _visitDetailData: VisitDetailData;//到访记录详情
private _collectGiftRecord:Data;//礼物收取
/**
* 插件信息列表
*/
private _getPrizeInfoList: any = {};
private _getRecordData:GetRecordData;
/**
* 更新数据
* @param {NetName} name
* @param result
* @returns {any}
*/
// tslint:disable-next-line:cyclomatic-complexity
public updateData(name: number, result: any, param?: any): Data {
let data: Data;
switch (name) {
case NetName.GET_ROLE:
if (!this._getRoleData) {
this._getRoleData = new GetRoleData();
}
this._getRoleData.update(result);
data = this._getRoleData;
break;
case NetName.GAME_TOTAL_SCORE:
if (!this._getUserTotalScoreData) {
this._getUserTotalScoreData = new GetUserTotalScoreData();
}
this._getUserTotalScoreData.update(result);
data = this._getUserTotalScoreData;
break;
case NetName.GET_CREDITS:
if (!this._getCreditsData) {
this._getCreditsData = new GetCreditsData();
}
this._getCreditsData.update(result);
data = this._getCreditsData;
break;
case NetName.GAME_INFO:
if (!this._getInfoData) {
this._getInfoData = new GetInfoData();
}
this._getInfoData.update(result);
data = this._getInfoData;
break;
case NetName.GAME_SUMMERINFO:
if (!this._getSummerInfoData) {
this._getSummerInfoData = new GetSummerInfoData();
}
this._getSummerInfoData.update(result);
data = this._getSummerInfoData;
break;
case NetName.GAME_START:
if (!this._doStartData) {
this._doStartData = new DoStartData();
}
this._doStartData.update(result);
data = this._doStartData;
break;
case NetName.GAME_START_STATUS:
if (!this._getStartStatusData) {
this._getStartStatusData = new GetStartStatusData();
}
this._getStartStatusData.update(result);
data = this._getStartStatusData;
break;
case NetName.GAME_REVIVE:
if (!this._doReviveData) {
this._doReviveData = new DoReviveData();
}
this._doReviveData.update(result);
data = this._doReviveData;
break;
case NetName.GAME_REVIVE_STATUS:
if (!this._getReviveCardNumData) {
this._getReviveCardNumData = new GetReviveCardNumData();
}
this._getReviveCardNumData.update(result);
data = this._getReviveCardNumData;
break;
case NetName.GAME_SUBMIT:
if (!this._gameSubmitData) {
this._gameSubmitData = new GameSubmitData();
}
this._gameSubmitData.update(result);
data = this._gameSubmitData;
if (result.data) {
this._getInfoData.update(result);
}
break;
case NetName.GAME_SUBMIT_STATUS:
if (!this._gameGetSubmitResultData) {
this._gameGetSubmitResultData = new GameGetSubmitResultData();
}
this._gameGetSubmitResultData.update(result);
data = this._gameGetSubmitResultData;
break;
case NetName.GAME_RANKS:
if (!this._winRanksData) {
this._winRanksData = new WinRanksData();
}
this._winRanksData.update(result);
data = this._winRanksData;
break;
case NetName.GAME_OPTIONS:
if (!this._getOptionsData) {
this._getOptionsData = new GetOptionsData();
}
this._getOptionsData.update(result);
data = this._getOptionsData;
break;
case NetName.GAME_RULE:
if (!this._getRuleData) {
this._getRuleData = new GetRuleData();
}
this._getRuleData.update(result);
data = this._getRuleData;
break;
case NetName.ADD_TIMES:
if (!this._addTimesForActivityData) {
this._addTimesForActivityData = new AddTimesForActivityData();
}
this._addTimesForActivityData.update(result);
data = this._addTimesForActivityData;
break;
case NetName.COLLECT_RULE:
if (!this._getCollectRuleData) {
this._getCollectRuleData = new GetCollectRuleData();
}
this._getCollectRuleData.update(result);
data = this._getCollectRuleData;
break;
case NetName.OPEN_COLLECT:
if (!this._openCollectGoodsPrizeData) {
this._openCollectGoodsPrizeData = new OpenCollectGoodsPrizeData();
}
this._openCollectGoodsPrizeData.update(result);
data = this._openCollectGoodsPrizeData;
break;
case NetName.GAME_REAL_TIME_RANK:
if (!this._realTimeRankData) {
this._realTimeRankData = new RealTimeRankData();
}
this._realTimeRankData.update(result);
data = this._realTimeRankData;
break;
case NetName.PLUG_DO_JOIN:
if (!this._doJoinPlugDrawData) {
this._doJoinPlugDrawData = new DoJoinPlugDrawData();
}
this._doJoinPlugDrawData.update(result);
data = this._doJoinPlugDrawData;
break;
case NetName.PLUG_ORDER_STATUS:
if (!this._getPlugOrderStatusData) {
this._getPlugOrderStatusData = new GetPlugOrderStatusData();
}
this._getPlugOrderStatusData.update(result);
data = this._getPlugOrderStatusData;
break;
case NetName.PLUG_PRIZE_INFO://查询插件信息
const plugID = param.activityId;
if (!this._getPrizeInfoList[plugID]) {
this._getPrizeInfoList[plugID] = new GetPrizeInfoData();
}
this._getPrizeInfoList[plugID].update(result);
data = this._getPrizeInfoList[plugID];
break;
case NetName.SET_ROLE:
if (!this._setRoleData) {
this._setRoleData = new SetRoleData();
}
this._setRoleData.update(result);
data = this._setRoleData;
break;
case NetName.CUSTOM_ELEMENT:
if (!this._ajaxElementData) {
this._ajaxElementData = new AjaxElementData();
}
this._ajaxElementData.update(result);
data = this._ajaxElementData;
break;
case NetName.CUSTOM_THROUGH_INFO:
if (!this._ajaxThroughInfoData) {
this._ajaxThroughInfoData = new AjaxThroughInfoData();
}
this._ajaxThroughInfoData.update(result);
data = this._ajaxThroughInfoData;
break;
case NetName.CUSTOM_DO_JOIN:
if (!this._doJoinData) {
this._doJoinData = new DoJoinData();
}
this._doJoinData.update(result);
data = this._doJoinData;
break;
case NetName.CUSTOM_ORDER_STATUS:
if (!this._getCustomOrderStatusData) {
this._getCustomOrderStatusData = new GetCustomOrderStatusData();
}
this._getCustomOrderStatusData.update(result);
data = this._getCustomOrderStatusData;
this._ajaxElementData.element = result.element;
break;
case NetName.CUSTOM_ORDER_INFO:
if (!this._getOrderInfoData) {
this._getOrderInfoData = new GetOrderInfoData();
}
this._getOrderInfoData.update(result);
data = this._getOrderInfoData;
break;
case NetName.CUSTOM_THROUGH_SUBMIT:
if (!this._throughSubmitData) {
this._throughSubmitData = new ThroughSubmitData();
}
this._throughSubmitData.update(result);
data = this._throughSubmitData;
break;
case NetName.CUSTOM_BEFOR_SUBMIT:
if (!this._beforSubmitData) {
this._beforSubmitData = new BeforSubmitData();
}
this._beforSubmitData.update(result);
data = this._beforSubmitData;
break;
case NetName.CUSTOM_QUESTION_SUBMIT:
if (!this._questionSubmitData) {
this._questionSubmitData = new QuestionSubmitData();
}
this._questionSubmitData.update(result);
data = this._questionSubmitData;
break;
case NetName.GAME_GUESS_POKER:
if (!this._guessPokerData) {
this._guessPokerData = new GuessPokerData();
}
this._guessPokerData.update(result);
data = this._guessPokerData;
break;
case NetName.PLUG_OPTION_INFO:
if (!this._optionInfoData) {
this._optionInfoData = new OptionInfoData();
}
this._optionInfoData.update(result);
data = this._optionInfoData;
break;
case NetName.PET_ADOPTE:
if (!this._petAdopteData) {
this._petAdopteData = new PetAdopteData();
}
this._petAdopteData.update(result);
this.petIndexData.update(result.data);//更新petIndexData里面的活动id(activityid);
if (!this._petHomeInfoData) {
this._petHomeInfoData = new PetHomeInfoData();
}
this._petHomeInfoData.update(result);//更新宠物信息
data = this._petAdopteData;
break;
case NetName.PET_FEED:
if (!this._petFeedData) {
this._petFeedData = new PetFeedData();
}
this._petFeedData.update(result);
if (!this._petHomeInfoData) {
this._petHomeInfoData = new PetHomeInfoData();
}
this._petHomeInfoData.update(result);//更新宠物信息
data = this._petFeedData;
break;
case NetName.PET_STATUS:
if (!this._petStatusData) {
this._petStatusData = new PetStatusData();
}
this._petStatusData.update(result);
if (!this._petHomeInfoData) {
this._petHomeInfoData = new PetHomeInfoData();
}
this._petHomeInfoData.update(result);//更新宠物信息
data = this._petStatusData;
break;
case NetName.PET_INFO:
if (!this._petHomeInfoData) {
this._petHomeInfoData = new PetHomeInfoData();
}
this._petHomeInfoData.update(result);//更新宠物信息
data = this._petHomeInfoData;
break;
case NetName.PET_TOYS://签到养成里暂时没用到这个接口
if (!this._getToysData) {
this._getToysData = new GetToysData();
}
this._getToysData.update(result);
data = this._getToysData;
break;
case NetName.PET_TOY_EXCHANGE://签到养成里暂时没用到这个接口
if (!this._toyExchangeData) {
this._toyExchangeData = new ToyExchangeData();
}
this._toyExchangeData.update(result);
data = this._toyExchangeData;
break;
case NetName.PET_TOY_USE://签到养成里暂时没用到这个接口
if (!this._toyUseData) {
this._toyUseData = new ToyUseData();
}
this._toyUseData.update(result);
data = this._toyUseData;
break;
case NetName.PET_COLLECT://收取礼物接口
if (!this._collectData) {
this._collectData = new CollectData();
}
this._collectData.update(result);
data = this._collectData;
break;
case NetName.SIGN_INFO://查询签到信息接口
case NetName.SIGN_DO_SIGN://签到接口
if (!this._signInfoData) {
this._signInfoData = new SignInfoData();
}
this._signInfoData.update(result);
data = this._signInfoData;
break;
case NetName.PET_GET_RANK_LIST://群内喂食排行榜
if (!this._getRankListData) {
this._getRankListData = new GetRankListData();
}
this._getRankListData.update(result);
data = this._getRankListData;
break;
case NetName.PET_GET_FOOD_PILES://查询待领取粮食
if (!this._getFoodPilesData) {
this._getFoodPilesData = new GetFoodPilesData();
}
this._getFoodPilesData.update(result);
data = this._getFoodPilesData;
break;
case NetName.PET_COLLECT_FOOD://待领取粮食收取
if (!data) {
data = new Data();
}
data.update(result);
break;
case NetName.PETS_GET_HOME_INFO://外来宠物养成---活动主信息接口
if(!this._getHomeInfoData) {
this._getHomeInfoData = new GetHomeInfoData();
}
this._getHomeInfoData.update(result);
data = this._getHomeInfoData;
break;
case NetName.PETS_GET_ACT_TOYS://外来宠物养成---商店道具接口
const toyType = param.toyType;
if(!this._getActToysListData[toyType]) {
this._getActToysListData[toyType] = new GetActToysListData();
}
this._getActToysListData[toyType].update(result);
data = this._getActToysListData[toyType];
break;
case NetName.PETS_TOY_EXCHANGE://外来宠物养成---道具兑换
if(!this._toyExchangesData) {
this._toyExchangesData = new ToyExchangesData();
}
this._toyExchangesData.update(result);
data = this._toyExchangesData;
break;
case NetName.PETS_USE_TOYS://外来宠物养成---道具使用
if(!this._useToyData) {
this._useToyData = new UseToyData();
}
this._useToyData.update(result);
data = this._useToyData;
break;
case NetName.PETS_GET_USER_TOYS://外来宠物养成---已购买的道具
if(!this._getUserToysListData) {
this._getUserToysListData = new GetUserToysListData();
}
this._getUserToysListData.update(result);
data = this._getUserToysListData;
break;
case NetName.PETS_BATCHOLLECT_FOOD://外来宠物养成---收取猫草
if(!this._batchollectFoodData){
this._batchollectFoodData = new Data();
}
this._batchollectFoodData.update(result);
data = this._batchollectFoodData;
break;
case NetName.PETS_VISI_STATISTICS://外来宠物养成---来访统计
if(!this._visitStatisticsData) {
this._visitStatisticsData = new VisitStatisticsData();
}
this._visitStatisticsData.update(result);
data = this._visitStatisticsData;
break;
case NetName.PETS_GET_VISIT_INFO://未来宠物养成---动态信息列表
if(!this._getVisitInfoData){
this._getVisitInfoData = new GetVisitInfoData();
}
this._getVisitInfoData.update(result);
data = this._getVisitInfoData;
break;
case NetName.PETS_VISIT_DETAIL://外来宠物养成---到访记录详情
if(!this._visitDetailData) {
this._visitDetailData = new VisitDetailData();
}
this._visitDetailData.update(result);
data = this._visitDetailData;
break;
case NetName.PETS_COLLECT_GIFT_RECORD:
if(!this._collectGiftRecord) {
this._collectGiftRecord = new Data();
}
this._collectGiftRecord.update(result);
data = this._collectGiftRecord;
break;
case NetName.PLUG_UNBLOCKING:
if (!this._unblockingData) {
this._unblockingData = new UnblockingData();
}
this._unblockingData.update(result);
data = this._unblockingData;
break;
case NetName.GAME_DATA_PASH:
if (!this._datapashData) {
this._datapashData = new DatapashData();
}
this._datapashData.update(result);
data = this._datapashData;
break;
case NetName.GAME_SUMMER_BUYPROP:
this._summerBuyPropData = result;
data = result;
break;
case NetName.GAME_SUMMER_GET_ORDER_STATUS:
this._summerOrderStatus = result;
data = result;
break;
case NetName.GAME_SUMMER_GET_TOY_INFO:
this._summerToyInfo = result;
data = result;
break;
case NetName.GET_RECORD://查询我的奖品记录
if(!this._getRecordData){
this._getRecordData = new GetRecordData();
}
this._getRecordData.update(result);
data = this._getRecordData;
default:
this[this.getKey(name)]=result;
}
return data || result;
}
getData(name){
return this[this.getKey(name)]
}
private getKey(name){
return `_tw_data_${name}_`
}
/**
* 用户信息
*/
public get getInfoData(): GetInfoData {
return this._getInfoData;
}
/**
* 夏日活动用户信息
*/
public get getSummerInfoData(): GetSummerInfoData {
return this._getSummerInfoData;
}
/**
* 角色信息
*/
public get getRoleData(): GetRoleData {
return this._getRoleData;
}
/**
* 用户成长值
*/
public get getUserTotalScoreData(): GetUserTotalScoreData {
return this._getUserTotalScoreData;
}
/**
* 用户积分
*/
public get getCreditsData(): GetCreditsData {
return this._getCreditsData;
}
/**
* 开始游戏
*/
public get doStartData(): DoStartData {
return this._doStartData;
}
/**
* 开始游戏订单结果
*/
public get getStartStatusData(): GetStartStatusData {
return this._getStartStatusData;
}
/**
* 复活
*/
public get doReviveData(): DoReviveData {
return this._doReviveData;
}
/**
* 获得复活卡数量
*/
public get getReviveCardNumData(): GetReviveCardNumData {
return this._getReviveCardNumData;
}
/**
* 游戏提交
*/
public get gameSubmitData(): GameSubmitData {
return this._gameSubmitData;
}
/**
* 游戏提交订单结果
*/
public get gameGetSubmitResultData(): GameGetSubmitResultData {
return this._gameGetSubmitResultData;
}
/**
* 开奖
*/
public get winRanksData(): WinRanksData {
return this._winRanksData;
}
/**
* 游戏奖品
*/
public get getOptionsData(): GetOptionsData {
return this._getOptionsData;
}
/**
* 游戏规则
*/
public get getRuleData(): GetRuleData {
return this._getRuleData;
}
/**
* 活动次数
*/
public get addTimesForActivityData(): AddTimesForActivityData {
return this._addTimesForActivityData;
}
/**
* 集卡规则
*/
public get getCollectRuleData(): GetCollectRuleData {
return this._getCollectRuleData;
}
/**
* 集卡开奖
*/
public get openCollectGoodsPrizeData(): OpenCollectGoodsPrizeData {
return this._openCollectGoodsPrizeData;
}
/**
* 实时排行榜
*/
public get realTimeRankData(): RealTimeRankData {
return this._realTimeRankData;
}
/**
* 插件
*/
public get doJoinPlugDrawData(): DoJoinPlugDrawData {
return this._doJoinPlugDrawData;
}
/**
* 插件订单结果
*/
public get getPlugOrderStatusData(): GetPlugOrderStatusData {
return this._getPlugOrderStatusData;
}
/**
* 设置角色
*/
public get setRoleData(): SetRoleData {
return this._setRoleData;
}
/**
* 活动工具基础信息
*/
public get ajaxElementData(): AjaxElementData {
return this._ajaxElementData;
}
/**
* 闯关游戏基础信息
*/
public get ajaxThroughInfoData(): AjaxThroughInfoData {
return this._ajaxThroughInfoData;
}
/**
* 活动工具抽奖
*/
public get doJoinData(): DoJoinData {
return this._doJoinData;
}
/**
* 活动工具订单结果
*/
public get getCustomOrderStatusData(): GetCustomOrderStatusData {
return this._getCustomOrderStatusData;
}
/**
* 前置抽奖
*/
public get getOrderInfoData(): GetOrderInfoData {
return this._getOrderInfoData;
}
/**
* 闯关游戏提交
*/
public get throughSubmitData(): ThroughSubmitData {
return this._throughSubmitData;
}
/**
* 前置开奖提交
*/
public get beforSubmitData(): BeforSubmitData {
return this._beforSubmitData;
}
/**
* 答题提交
*/
public get questionSubmitData(): QuestionSubmitData {
return this._questionSubmitData;
}
/**
* 猜扑克
*/
public get guessPokerData(): GuessPokerData {
return this._guessPokerData;
}
/**
* 插件奖品信息
*/
public get optionInfoData(): OptionInfoData {
return this._optionInfoData;
}
/**
* 解锁插件
*/
public get unblockingData(): UnblockingData {
return this._unblockingData;
}
/**
* 防作弊阶段提交
*/
public get datapashData(): DatapashData {
return this._datapashData;
}
public get summerBuyPropData(): any {
return this._summerBuyPropData;
}
public get summerOrderStatus(): any {
return this._summerOrderStatus;
}
public get summerToyInfo(): any {
return this._summerToyInfo;
}
/**
* 养成
* 宠物基础数据
*/
public get petHomeInfoData(): PetHomeInfoData {
return this._petHomeInfoData;
}
/**
* 养成
* 宠物喂食回调数据
*/
public get petFeedData(): PetFeedData {
return this._petFeedData;
}
/**
* 养成
* 签到信息
*/
public get signInfoData(): SignInfoData {
return this._signInfoData;
}
/**
* 插件列表
*/
public get getPrizeInfoList(): any {
return this._getPrizeInfoList;
}
/**
* 喂养排名信息
*/
public get getRankListData(): GetRankListData {
return this._getRankListData;
}
/**
* 查询待领取粮食信息
*/
public get getFoodPilesData(): GetFoodPilesData {
return this._getFoodPilesData;
}
/**
* 查询我的奖品记录
*/
public get getRecordData():GetRecordData{
return this._getRecordData;
}
/**
* 外来宠物养成--活动主信息接口
*/
public get getHomeInfoData():GetHomeInfoData{
return this._getHomeInfoData;
}
public set getHomeInfoData(d:GetHomeInfoData){
this._getHomeInfoData = d;
}
/**
* 收取猫草回调数据
*/
public get gtBatchollectFoodData():Data{
return this._batchollectFoodData;
}
/**
* 外来宠物养成--商店道具接口
*/
public get getActToysListData():GetActToysListData[]{
return this._getActToysListData;
}
public set getActToysListData(d:GetActToysListData[]){
this._getActToysListData = d;
}
/**
* 外来宠物养成--商店道具接口
*/
public get getUserToysListData():GetUserToysListData{
return this._getUserToysListData;
}
public set getUserToysListData(d:GetUserToysListData){
this._getUserToysListData = d;
}
/**
* 外来宠物养成--来访统计
*/
public get visitStatisticsData():VisitStatisticsData{
return this._visitStatisticsData;
}
/**
* 外来宠物养成--动态信息列表
*/
public get getVisitInfoData():GetVisitInfoData{
return this._getVisitInfoData;
}
/**
* 外来宠物养成--到访记录详情
*/
public get visitDetailData():VisitDetailData{
return this._visitDetailData;
}
/**
* 外来宠物养成--礼物收取
*/
public get collectGiftRecord():Data{
return this._collectGiftRecord;
}
// tslint:disable-next-line:max-file-line-count
}
\ No newline at end of file
import { Data } from './../data/Data';
// import { ABNetManager, GTime, INetData, GDispatcher } from "duiba-tc";
import { TwLang } from "../util/TwLang";
import { DataManager } from "./DataManager";
import { NetName } from '../enum/NetName';
import { ABNetManager } from '../../tc/manager/ABNetManager';
import { INetData } from '../../tc/interface/INetData';
import { GTime } from '../../tc/util/GTime';
import { IExposureData } from '../data/common/IExposureData';
import { GDispatcher } from '../../tc/util/GDispatcher';
// import { IExposureData } from '..';
export class NetManager extends ABNetManager {
private static instance: NetManager;
public static get ins(): NetManager {
if (!this.instance) {
this.instance = new NetManager();
}
return this.instance;
}
private isInit: boolean;
constructor() {
super();
if (this.isInit) {
throw Error(TwLang.lang_001);
}
this.isInit = true;
}
/**
* 获取用户角色信息
* @param {number} roleActivityId 角色id
* @param {number} type 类型
*/
public getRole(callback: Function, roleActivityId: string, type = 1): void {
const net: INetData = {
name: NetName.GET_ROLE,
uri: '/activityCommon/getRole',
type: 'get',
dataType: 'json',
param: {
id: roleActivityId,
type: type
},
callback: callback
};
this.send(net);
}
/**
* 活动设置用户角色信息
* @param {number} actId 活动id
* @param {number} type 活动类型 0:插件活动; 1:入库活动
* @param {string} role 角色信息,不能超过32个字符
*/
public setRole(callback: Function, actId: number, type: number, role: string): void {
const net: INetData = {
name: NetName.SET_ROLE,
uri: '/activityCommon/setRole',
type: 'post',
dataType: 'json',
param: {
id: actId,
type: type,
role: role
},
callback: callback
};
this.send(net);
}
/**
* 查询用户现在的剩余积分
*/
public getCredits(callback: Function): void {
const net: INetData = {
name: NetName.GET_CREDITS,
uri: '/ctool/getCredits',
type: 'get',
dataType: 'json',
param: null,
callback: callback
};
this.send(net);
}
/**
* 增加活动免费次数
* @param {number} type 1游戏、2活动工具
* @param {number} count 次数
* @param {number} validType 如果不传该参数,代表增加的次数是该用户可以永久使用的次数;如果传该参数,代表增加的次数是仅当天可用的,该参数值只能是1
*/
public addTimesForActivity(callback: Function, type: number, count: number, validType: number): void {
let activityId: number;
if (type == 1) {
activityId = DataManager.ins.gameCfgData.gameInfo.oaId;
} else {
activityId = DataManager.ins.customCfgData.oaId;
}
const param: any = {
timestamp: GTime.getTimestamp(),
addCount: count,
activityId: activityId
};
if (validType) {
param.validType = validType;
}
const net: INetData = {
name: NetName.ADD_TIMES,
uri: '/activityVist/addTimesForActivity',
type: 'post',
dataType: 'json',
param: param,
callback: callback
};
this.send(net);
}
/**
* 获取集卡数据
* @param {number} collectRuleId 集卡规则ID
*/
public getCollectRule(callback: Function, collectRuleId: number): void {
const net: INetData = {
name: NetName.COLLECT_RULE,
uri: '/collectRule/getCollectRule',
type: 'get',
dataType: 'json',
param: {
collectRuleId: collectRuleId
},
callback: callback
};
this.send(net);
}
/**
* 集卡开奖
* @param {number} collectRuleId 集卡规则ID
* @param {number} type 1游戏、2活动工具、其他类型可以不传,发接口actid也不用传
*/
public openCollectGoodsPrize(callback: Function, collectRuleId: number, type?: number): void {
let actId: number;
let param: any;
if (type == 1) {
actId = DataManager.ins.gameCfgData.gameInfo.oaId;
} else if (type == 2) {
actId = DataManager.ins.customCfgData.oaId;
}
if (type) {
param = { collectRuleId: collectRuleId, actId: actId }
} else {
param = { collectRuleId: collectRuleId };
}
const net: INetData = {
name: NetName.OPEN_COLLECT,
uri: '/collectRule/openCollectGoodsPrize',
type: 'get',
dataType: 'json',
param: param,
callback: callback
};
this.send(net);
}
//--------------------------------------------游戏-----------------------------------------
/**
* 游戏基础信息
*/
public getInfo(callback: Function): void {
const net: INetData = {
name: NetName.GAME_INFO,
uri: '/ngame/new/getInfo',
type: 'get',
dataType: 'json',
param: {
id: DataManager.ins.gameCfgData.gameInfo.gameId
},
callback: callback
};
this.send(net);
}
/**
* 夏日活动游戏基础信息
*/
public getSummerInfo(callback: Function, rankBaseConfigId: number): void {
const net: INetData = {
name: NetName.GAME_SUMMERINFO,
uri: '/summer/getUserActivityInfo',
type: 'get',
dataType: 'json',
param: {
rankBaseConfigId: rankBaseConfigId,
isMainActivity: false
},
callback: callback
};
this.send(net);
}
/**
* 购买鱼钩鱼线道具
* @param callback
* @param operatingActivityId 活动oaid
* @param type 道具类型 0:鱼线 1:鱼钩
*/
public summerBuyProp(callback: Function, operatingActivityId: number, type: number): void {
const net: INetData = {
name: NetName.GAME_SUMMER_BUYPROP,
uri: '/summer/buyProp',
type: 'post',
dataType: 'json',
param: {
operatingActivityId: operatingActivityId,
type: type
},
callback: callback, hideMsg: true
};
this.send(net);
}
/**
* 获取鱼钩鱼线数量
* @param callback
*/
public summerGetToyInfo(operatingActivityId, callback: Function): void {
const net: INetData = {
name: NetName.GAME_SUMMER_GET_TOY_INFO,
uri: '/summer/getToyInfo',
type: 'get',
dataType: 'json',
param: { operatingActivityId: operatingActivityId },
callback: callback
};
this.send(net);
}
/**
* 开始游戏
* @param {string} isAgain 是否是再来一次
* @param {number} credits 主动要求花费多少积分玩游戏
* @param {number} customizedType xx类型
*/
public doStart(callback: Function, isAgain: boolean, credits?: number, customizedType?: number): void {
let addUrl = '';
if (isAgain) {
addUrl += '?dpm=' + DataManager.ins.gameGetSubmitResultData.againExposure.dpm;
}
const param: any = {
id: DataManager.ins.gameCfgData.gameInfo.gameId,
oaId: DataManager.ins.gameCfgData.gameInfo.oaId
};
if (credits) {
param.credits = credits;
}
if (customizedType) {
param.customizedType = customizedType;
}
const net: INetData = {
name: NetName.GAME_START,
uri: '/ngapi/dostart',
type: 'post',
dataType: 'json',
param: param,
callback: callback,
addUrl: addUrl
};
this.getToken(net);
}
/**
* 查询开始游戏状态
* @param {number} ticketId 订单ID
* @param {Function} pollingCheck 轮询条件 返回true继续轮询
* @param {number} pollingCount 最大轮询次数
* @param {number} customizedType
*/
public getStartStatus(callback: Function, ticketId: number, pollingCheck: Function, pollingCount = 5, customizedType?: number): void {
const param: any = {
ticketId: ticketId
};
if (customizedType) {
param.customizedType = customizedType
}
const net: INetData = {
name: NetName.GAME_START_STATUS,
uri: '/ngapi/getStartStatus',
type: 'post',
dataType: 'json',
param: param,
callback: callback,
pollingCount: pollingCount,
pollingCheck: pollingCheck
};
this.send(net);
}
public getSummerOrderStatus(callback: Function, orderNum: number, pollingCheck: Function, pollingCount = 5, customizedType?: number): void {
const param: any = {
orderNum: orderNum
};
const net: INetData = {
name: NetName.GAME_SUMMER_GET_ORDER_STATUS,
uri: '/summer/getOrderStatus',
type: 'post',
dataType: 'json',
param: param,
callback: callback,
pollingCount: pollingCount,
pollingCheck: pollingCheck
};
this.send(net);
}
/**
* 复活
*/
public doRevive(callback: Function, collectRuleId: number, itemId: number): void {
const net: INetData = {
name: NetName.GAME_REVIVE,
uri: '/summer/doRevive',
type: 'post',
dataType: 'json',
param: {
collectRuleId: collectRuleId,
itemId: itemId
},
callback: callback,
};
this.getToken(net);
}
/**
* 获得复活卡数量
*/
public getReviveCardNum(callback: Function, collectRuleId: number, itemId: number): void {
const net: INetData = {
name: NetName.GAME_REVIVE_STATUS,
uri: '/summer/getReviveCardNum',
type: 'post',
dataType: 'json',
param: {
collectRuleId: collectRuleId,
itemId: itemId
},
callback: callback,
};
this.getToken(net);
}
/**
* 猜扑克
* @param {number} pluginId 插件ID
* @param {number} ticketId 订单ID
* @param {number} prizeId 集卡规则ID
* @param {number} betting 下注方式 0:大 1:小 2:红 3:黑
*/
public guessPoker(callback: Function, plugId: number, ticketId: number, prizeId: number, betting: number): void {
const net: INetData = {
name: NetName.GAME_GUESS_POKER,
uri: '/ngapi/guessPoker',
type: 'post',
dataType: 'json',
param: {
pluginId: plugId,
ticketId: ticketId,
prizeId: prizeId,
betting: betting
},
callback: callback
};
this.send(net);
}
/**
* 游戏阶段性数据提交
* @param ticketId
* @param dynamicData 阶段性交互数据
*/
public datapash(callback: Function, ticketId: number, dynamicData: string): void {
const net: INetData = {
name: NetName.GAME_DATA_PASH,
uri: '/ngame/new/datapash',
type: 'post',
dataType: 'json',
param: {
ticketId: ticketId,
gameId: DataManager.ins.gameCfgData.gameInfo.id,
dynamicData: dynamicData
},
callback: callback
};
this.send(net);
}
/**
* 提交游戏数据
*
* @param {number} ticketId 订单ID
* @param {number} score 分数
* @param {any} gameData 防作弊信息
* @param {string} submitToken
* @param {string} dynamicData 行为数据
* @param {boolean} checkScore 是否校验分数
* @param {number} customizedType
*/
public gameSubmit(callback: Function,
ticketId: number,
score: number,
gameData: any,
submitToken: string,
dynamicData: string,
checkScore?: boolean,
customizedType?: number): void {
const sign = this.createSgin(ticketId, score, gameData, submitToken);
const param: any = {
ticketId: ticketId,
score: score,
gameData: gameData,
sgin: sign,
dynamicData: dynamicData
};
if (checkScore) {
param.checkScore = checkScore;
}
if (customizedType) {
param.customizedType = customizedType;
}
const net: INetData = {
name: NetName.GAME_SUBMIT,
uri: '/ngame/new/submit',
type: 'post',
dataType: 'json',
param: param,
callback: callback
};
this.send(net);
}
/**
* 生成签名
* @param {number} ticketId
* @param {number} score
* @param {any} gameData
* @param {string} submitToken
* @returns {string} 签名
*/
private createSgin(ticketId: number, score: number, gameData: any, submitToken: string): string {
return window['duiba_md5'](ticketId + '' + score + '' + gameData + '' + submitToken);
}
/**
* 游戏结束获取奖品数据
* @param {number} orderId 订单ID
* @param {Function} pollingCheck 轮询条件 返回true继续轮询
* @param {number} 最大轮询次数
*/
public getSubmitResult(callback: Function, orderId: number, pollingCheck: Function, pollingCount = 5): void {
const net: INetData = {
name: NetName.GAME_SUBMIT_STATUS,
uri: '/ngame/new/getSubmitResult',
type: 'get',
dataType: 'json',
param: {
orderId: orderId
},
callback: callback,
pollingCount: pollingCount,
pollingCheck: pollingCheck
};
this.send(net);
}
/**
* 查看中奖名单
* @param {boolean} showName 是否返回昵称
*/
public winRanks(callback: Function, showName = false): void {
const net: INetData = {
name: NetName.GAME_RANKS,
uri: '/ngapi/winranks',
type: 'post',
dataType: 'json',
param: {
id: DataManager.ins.gameCfgData.gameInfo.gameId,
showName: showName
},
callback: callback
};
this.send(net);
}
/**
* 获取奖项
*/
public getOptions(callback: Function): void {
const net: INetData = {
name: NetName.GAME_OPTIONS,
uri: '/ngapi/getOptions',
type: 'post',
dataType: 'json',
param: {
id: DataManager.ins.gameCfgData.gameInfo.gameId
},
callback: callback
};
this.send(net);
}
/**
* 获取规则
*/
public getRule(callback: Function): void {
const net: INetData = {
name: NetName.GAME_RULE,
uri: '/ngapi/getRule',
type: 'post',
dataType: 'html',
param: {
id: DataManager.ins.gameCfgData.gameInfo.gameId
},
callback: callback
};
this.send(net);
}
/**
* 实时排行榜
* @param {number} type 0总排行榜 1今日排行榜 2 多游戏总排行榜 3 昨日排行榜
* @param {number} count 返回榜单长度 最大50
*/
public realtimerank(callback: Function, type: number, count = 50): void {
const net: INetData = {
name: NetName.GAME_REAL_TIME_RANK,
uri: '/ngapi/realtimerank',
type: 'get',
dataType: 'json',
param: {
id: DataManager.ins.gameCfgData.gameInfo.gameId,
count: count,
},
callback: callback,
addUrl: '/' + type
};
this.send(net);
}
/**
* 获取成长值
* @param {number} gametotalid 游戏中心榜单ID
*/
public getUserTotalScore(callback: Function, gametotalid: number): void {
const net: INetData = {
name: NetName.GAME_TOTAL_SCORE,
uri: '/ngapi/getUserTotalScore',
type: 'get',
dataType: 'json',
param: {
id: gametotalid
},
callback: callback
};
this.send(net);
}
//--------------------------------------------插件-----------------------------------------
/**
* 插件抽奖
* @param {number} activityId 插件ID
*/
public doJoinPlugDraw(callback: Function, activityId: number, deductCredits?: boolean): void {
const net: INetData = {
name: NetName.PLUG_DO_JOIN,
uri: '/activityPlugDrawInfo/doJoinPlugdraw',
type: 'post',
dataType: 'json',
param: {
activityId: activityId,
deductCredits: deductCredits ? deductCredits : false
},
callback: callback
};
this.send(net);
}
/**
* 查询插件抽奖订单
* @param {number} orderId 订单ID
* @param {number} prizeLevel 开奖等级,暂未开放
*/
public getPlugOrderStatus(callback: Function, orderId: number, pollingCheck: Function, pollingCount = 5, prizeLevel?: number): void {
const net: INetData = {
name: NetName.PLUG_ORDER_STATUS,
uri: '/plugin/getOrderStatus',
type: 'get',
dataType: 'json',
param: {
orderId: orderId
},
callback: callback,
pollingCheck: pollingCheck,
pollingCount: pollingCount
};
this.send(net);
}
/**
* 查询插件信息
* @param {string} orderId 订单ID
*/
public getPrizeInfo(callback: Function, plugId: number): void {
const net: INetData = {
name: NetName.PLUG_PRIZE_INFO,
uri: '/activityPlugDrawInfo/getPrizeInfo',
type: 'post',
dataType: 'json',
param: {
activityId: plugId
},
callback: callback
};
this.send(net);
}
/**
* 插件-批量查询奖项信息
* @param {string} ids 插件ID 用,间隔
*/
public optionInfo(callback: Function, ids: string): void {
const net: INetData = {
name: NetName.PLUG_OPTION_INFO,
uri: '/activityPlugin/optionInfo',
type: 'get',
dataType: 'json',
param: {
ids: ids
},
callback: callback
};
this.send(net);
}
/**
* 插件校验解锁纪录
* @param {number} id 插件ID
*/
public unblocking(callback: Function, id: number): void {
const net: INetData = {
name: NetName.PLUG_UNBLOCKING,
uri: 'activityPlugin/unblocking',
type: 'post',
dataType: 'json',
param: {
id: id
},
callback: callback
};
this.send(net);
}
//--------------------------------------------自定义活动工具-----------------------------------------
/**
* 获取基础信息
*/
public ajaxElement(callback: Function): void {
const net: INetData = {
name: NetName.CUSTOM_ELEMENT,
uri: window['CFG'].getElement,
type: 'post',
dataType: 'json',
param: {
hdType: DataManager.ins.customCfgData.hdType,
hdToolId: DataManager.ins.customCfgData.hdToolId,
actId: DataManager.ins.customCfgData.actId,
preview: DataManager.ins.customCfgData.preview
},
callback: callback
};
this.send(net);
}
/**
* 查询闯关游戏 配置信息
* @param {number} throughId
*/
public ajaxThroughInfo(callback: Function, throughId = 1): void {
const net: INetData = {
name: NetName.CUSTOM_THROUGH_INFO,
uri: window['CFG'].ajaxThroughInfo,
type: 'post',
dataType: 'json',
param: {
hdtoolId: DataManager.ins.customCfgData.hdToolId,
throughId: 1
},
callback: callback
};
this.send(net);
}
/**
* 活动工具抽奖
* @param {number} collectRuleId 集卡规则ID,活动与集卡规则关联才能获得发卡资格
*/
public doJoin(callback: Function, collectRuleId?: number): void {
const param: any = {
actId: DataManager.ins.customCfgData.actId,
oaId: DataManager.ins.customCfgData.oaId
};
if (collectRuleId) {
param.collectRuleId = collectRuleId;
}
const net: INetData = {
name: NetName.CUSTOM_THROUGH_INFO,
uri: window['CFG'].doJoin,
type: 'post',
dataType: 'json',
param: param,
callback: callback
};
this.getToken(net);
}
/**
* 活动工具查询订单结果
* @param orderId
*/
public getCustomOrderStatus(callback: Function, orderId: number, pollingCheck: Function, pollingCount = 5): void {
const net: INetData = {
name: NetName.CUSTOM_ORDER_STATUS,
uri: window['CFG'].quireOrder,
type: 'post',
dataType: 'json',
param: {
orderId: orderId
},
callback: callback,
pollingCheck: pollingCheck,
pollingCount: pollingCount
};
this.send(net);
}
/**
* 获取抽奖前置信息
* @param {string} orderId 订单ID
*/
public getOrderInfo(callback: Function, orderId: number, showMsg = true): void {
const net: INetData = {
name: NetName.CUSTOM_ORDER_INFO,
uri: window['CFG'].gameGetOrder,
type: 'post',
dataType: 'json',
param: {
orderId: orderId
},
callback: callback,
hideMsg: true
};
this.send(net);
}
/**
* 前置开奖提交
* @param {string} orderId 订单ID
* @param {string} facePrice 前置开奖所需分值
*/
public beforSubmit(callback: Function, orderId: number, facePrice: number): void {
const net: INetData = {
name: NetName.CUSTOM_BEFOR_SUBMIT,
uri: window['CFG'].gameSubmit,
type: 'post',
dataType: 'json',
param: {
orderId: orderId,
facePrice: facePrice
},
callback: callback
};
this.send(net);
}
/**
* 答题提交
*/
public questionSubmit(): void {
}
/**
* 闯关游戏提交
*/
public throughSubmit(callback: Function, orderId: number): void {
const net: INetData = {
name: NetName.CUSTOM_THROUGH_SUBMIT,
uri: window['CFG'].throughSubmit,
type: 'post',
dataType: 'json',
param: {
orderId: orderId
},
callback: callback
};
this.send(net);
}
//--------------------------------------------养成-----------------------------------------
/**
* 宠物领养
* @param {number} activityId 宠物养成活动ID
*/
public petAdopte(callback: Function, activityId: number): void {
const net: INetData = {
name: NetName.PET_ADOPTE,
uri: '/signpet/adopte',
type: 'post',
dataType: 'json',
param: {
activityId: activityId
},
callback: callback
};
this.send(net);
}
/**
* 宠物状态刷新
* @param {number} petId 宠物ID
*/
public getPetStatus(callback: Function, petId: number): void {
const net: INetData = {
name: NetName.PET_STATUS,
uri: '/signpet/status',
type: 'get',
dataType: 'json',
param: {
petId: petId
},
callback: callback
};
this.send(net);
}
/**
* 宠物喂食
* @param {number} petId 宠物ID
* @param {number} feedNum 喂食数量
*/
public petFeed(callback: Function, petId: number, feedNum: number): void {
const net: INetData = {
name: NetName.PET_FEED,
uri: '/signpet/feed',
type: 'post',
dataType: 'json',
param: {
petId: petId,
feedNum: feedNum
},
callback: callback
};
this.send(net);
}
/**
* 获取宠物信息
* @param callback
* @param activityId
*/
public getPetInfo(callback: Function, activityId: number): void {
const net: INetData = {
name: NetName.PET_INFO,
uri: '/signpet/getPetInfo',
type: 'get',
dataType: 'json',
param: {
activityId: activityId
},
callback: callback
};
this.send(net);
}
/**
* 签到信息查询
* @param {Function} callback
* @param {number} signActivityId 签到活动ID
*/
public getSignInfo(callback: Function, signActivityId: number): void {
const net: INetData = {
name: NetName.SIGN_INFO,
uri: '/signactivity/getSignInfo',
type: 'post',
dataType: 'json',
param: {
signActivityId: signActivityId
},
callback: callback
};
this.send(net);
}
/**
* 签到接口
* @param {Function} callback
* @param {number} signActivityId 签到活动ID
* @param {number} activityId 插件活动ID,用于加抽奖次数,不传则使用签到身上配置的插件活动ID,否则不加抽奖次数
*/
public doSign(callback: Function, signActivityId: number, activityId: number): void {
const net: INetData = {
name: NetName.SIGN_DO_SIGN,
uri: '/signactivity/doSign',
type: 'post',
dataType: 'json',
param: {
id: signActivityId,
activityId: activityId
},
callback: callback
};
this.send(net);
}
/**
* 道具展示接口
* @param callback
* @param {number} actId 宠物活动ID
*/
public getToys(callback: Function, actId: number): void {
const net: INetData = {
name: NetName.PET_TOYS,
uri: '/signpet/addition/getToys',
type: 'get',
dataType: 'json',
param: {
actId: actId
},
callback: callback
};
this.send(net);
}
/**
* 道具兑换接口
* @param callback
* @param {number} toyId 道具id
* @param {number} credits 兑换所需积分
*/
public toyExchange(callback: Function, toyId: number, credits: number): void {
const net: INetData = {
name: NetName.PET_TOY_EXCHANGE,
uri: '/signpet/addition/toyExchange',
type: 'post',
dataType: 'json',
param: {
toyId: toyId,
credits: credits
},
callback: callback
};
this.send(net);
}
/**
* 道具使用接口
* @param callback
* @param {string} identifier 道具唯一标识
* @param {number} petId 宠物id
*/
public toyUse(callback: Function, identifier: string, petId: number): void {
const net: INetData = {
name: NetName.PET_TOY_USE,
uri: '/signpet/addition/toyUse',
type: 'post',
dataType: 'json',
param: {
identifier: identifier,
petId: petId
},
callback: callback
};
this.send(net);
}
/**
* 收取礼物接口
* @param callback
* @param {number} giftId 礼物id
* @param {string} giftName 礼物名称
* @param {string} giftDesc 礼物描述
* @param {number} giftType 礼物类型 1:用户自定义, 2:食物
* @param {string} giftLink 礼物链接
* @param {number} petId 宠物id
*/
public collect(callback: Function,
giftId: number,
giftNum: number,
giftName: string,
giftDesc: string,
giftType: number,
giftLink: string,
petId: number): void {
const net: INetData = {
name: NetName.PET_COLLECT,
uri: '/signpet/addition/collect',
type: 'post',
dataType: 'json',
param: {
giftId: giftId,
giftNum: giftNum,
giftName: giftName,
giftDesc: giftDesc,
giftType: giftType,
giftLink: giftLink,
petId: petId
},
callback: callback
};
this.send(net);
}
/**
* 群内喂食排行榜
* @param callback
* @param {number} petId 宠物id
* @param {number} topNum 排行榜显示top个数
*/
public getRankList(callback: Function, petId: number, topNum: number, pollingCheck: Function, pollingCount?: number): void {
const net: INetData = {
name: NetName.PET_GET_RANK_LIST,
uri: '/signpet/getRankList',
type: 'get',
dataType: 'json',
param: {
petId: petId,
topNum: topNum,
pollingCheck: pollingCheck,
pollingCount: pollingCount
},
callback: callback
};
this.send(net);
}
/**
* 查询待领取粮食
* @param callback
*/
public getFoodPiles(callback: Function): void {
const net: INetData = {
name: NetName.PET_GET_FOOD_PILES,
uri: '/signpet/getFoodPiles',
type: 'get',
dataType: 'json',
param: {},
callback: callback
};
this.send(net);
}
/**
* 待领取粮食收取
* @param callback
* @param {number} id 待领取粮食主键ID
* @param {number} activityId 活动id
*/
public collectFood(callback: Function, id: number, activityId: number): void {
const net: INetData = {
name: NetName.PET_COLLECT_FOOD,
uri: '/signpet/collectFood',
type: 'post',
dataType: 'json',
param: {
id: id,
activityId: activityId
},
callback: callback
};
this.send(net);
}
//--------------------------------------------------------------------外来宠物养成--------------------------------------------------------------------------
/**
* 活动主信息接口
* @param callback
* @param activityId
*/
public getHomeInfo(callback: Function, activityId: number): void {
const net: INetData = {
name: NetName.PETS_GET_HOME_INFO,
uri: '/sign/wander/getHomeInfo',
type: 'get',
dataType: 'json',
param: {
activityId: activityId
},
callback: callback
};
this.send(net);
}
/**
* 商店道具接口
* @param callback
* @param actId
* @param actType 2-日历 4-养成 5-契约 6-外来宠物
* @param toyType 1-状态 2-装饰 3-功能 4-食物 5-玩具
*/
public getActToys(callback: Function, actId: number, actType: number, toyType: number): void {
const net: INetData = {
name: NetName.PETS_GET_ACT_TOYS,
uri: '/sign/addition/getActToys',
type: 'get',
dataType: 'json',
param: {
actId: actId,
actType: actType,
toyType: toyType
},
callback: callback
};
this.send(net);
}
/**
* 外来宠物养成-道具兑换接口
* @param callback
* @param {number} toyId 道具id
*/
public toyExchanges(callback: Function, toyId: number): void {
const net: INetData = {
name: NetName.PETS_TOY_EXCHANGE,
uri: '/sign/addition/toyExchange',
type: 'post',
dataType: 'json',
param: {
toyId: toyId
},
callback: callback
};
this.send(net);
}
/**
* 道具使用接口
* @param callback
* @param {number} actId 活动id
* @param {any[]} toyList 使用的道具列表 [{identifier:'道具标识', position:'投放位置'}, {identifier:'道具标识', position:'投放位置'}]
*/
public useToy(callback: Function, actId: number, toyList: any[]): void {
const net: INetData = {
name: NetName.PETS_USE_TOYS,
uri: '/sign/addition/useToy',
type: 'post',
dataType: 'json',
param: {
actId: actId,
toyList: JSON.stringify(toyList)
},
callback: callback
};
this.send(net);
}
/**
* 已购买的道具接口
* @param callback
* @param petId 宠物id 没有传0
* @param toyType 1-状态 2-装饰 3-功能 4-食物 5-玩具
*/
public getUserToys(callback: Function, petId: number, toyType: number): void {
const net: INetData = {
name: NetName.PETS_GET_USER_TOYS,
uri: '/sign/addition/getUserToys',
type: 'get',
dataType: 'json',
param: {
petId: petId,
toyType: toyType
},
callback: callback
};
this.send(net);
}
/**
* 粮食收取
* @param callback
* @param actId 活动id
* @param ids 收取粮食堆的主键id列表[1,2,3,4]
*/
public batchollectFood(callback: Function, actId: number, ids: number[]): void {
const net: INetData = {
name: NetName.PETS_BATCHOLLECT_FOOD,
uri: '/sign/addition/batchollectFood',
type: 'post',
dataType: 'json',
param: {
ids: JSON.stringify(ids),
actId: actId
},
callback: callback
};
this.send(net);
}
/**
* 来访统计
* @param callback
* @param actId
*/
public visitStatistics(callback: Function, actId: number): void {
const net: INetData = {
name: NetName.PETS_VISI_STATISTICS,
uri: '/sign/wander/visitStatistics',
type: 'get',
dataType: 'json',
param: {
actId: actId
},
callback: callback
};
this.send(net);
}
/**
* 动态信息列表
* @param callback
* @param actId 活动id
* @param showNum 显示条数
*/
public getVisitInfo(callback: Function, actId: number, showNum: number): void {
const net: INetData = {
name: NetName.PETS_GET_VISIT_INFO,
uri: '/sign/wander/getVisitInfo',
type: 'get',
dataType: 'json',
param: {
showNum: showNum,
actId: actId
},
callback: callback
};
this.send(net);
}
/**
* 到访记录详情
* @param callback
* @param actId :活动id
* @param identifier :宠物唯一标识
*/
public visitDetail(callback: Function, actId: number, identifier: string): void {
const net: INetData = {
name: NetName.PETS_VISIT_DETAIL,
uri: '/sign/wander/visitDetail',
type: 'get',
dataType: 'json',
param: {
actId: actId,
identifier: identifier
},
callback: callback
};
this.send(net);
}
/**
* 礼物收取
* @param callback
* @param recordId 礼物记录ID
*/
public collectGiftRecord(recordId: number, callback: Function): void {
const net: INetData = {
name: NetName.PETS_COLLECT_GIFT_RECORD,
uri: '/sign/wander/collectGiftRecord',
type: 'post',
dataType: 'json',
param: {
recordId: recordId
},
callback: callback
};
this.send(net);
}
/**
* 获取token
* @param net
*/
public getToken(net: INetData): void {
if (window['getDuibaToken']) {
window['getDuibaToken']((tokenObj: any) => {
net.param.token = tokenObj.token;
this.send(net);
}, (key: string, messageObj: any) => {
this.onError(net);
});
} else {
this.send(net);
}
}
/**
* 查询我的奖品记录
* @param callback
* @param {number} page 当前页数
*/
public getRecord(callback: Function, page: number): void {
const net: INetData = {
name: NetName.GET_RECORD,
uri: (window['recordUrl'] ? window['recordUrl'] : '') + '/Crecord/getRecord',
type: 'get',
dataType: 'json',
param: {
page: page
},
callback: callback
};
let gTime: string = '?_=' + GTime.getTimestamp();
let realUrl: string = net.uri;
if (realUrl.indexOf('?') != -1) {
gTime = '&_=' + GTime.getTimestamp();
}
//url加参数等特殊需求(例如再玩一次需要在dostart接口的url上加埋点)
if (net.addUrl) {
realUrl += net.addUrl;
}
$.ajax({
type: net.type,
// url: realUrl + gTime,
url: realUrl,
dataType: net.dataType,
data: net.param,
async: true,
xhrFields: {
withCredentials: true
},
crossDomain: true,
cache: false,
success: (result) => {
this.onResponse(net, result);
},
error: (message) => {
this.onError(net);
}
});
}
/**
* 推啊曝光埋点(福袋)
* @param {IExposureData} exposure
*/
public spmshow(exposure: IExposureData): void {
const domain = (exposure.domain ? exposure.domain : '') + '/engine/';
const net: INetData = {
name: 'spmshow',
uri: domain + 'spmshow',
type: 'get',
dataType: 'jsonp',
param: exposure,
callback: null,
hideMsg: true
};
this.send(net);
}
/**
* 推啊点击埋点(福袋)
* @param {IExposureData} exposure
*/
public spmclick(exposure: IExposureData): void {
const domain = (exposure.domain ? exposure.domain : '') + '/engine/';
const net: INetData = {
name: 'spmclick',
uri: domain + 'spmclick',
type: 'get',
dataType: 'jsonp',
param: exposure,
callback: null,
hideMsg: true
};
this.send(net);
}
/**
* 兑吧点击埋点
* @param {IExposureData} exposure
*/
public clickLog(exposure: IExposureData): void {
const net: INetData = {
name: 'clickLog',
uri: '/log/click',
type: 'get',
dataType: 'jsonp',
param: exposure,
callback: null,
hideMsg: true
};
this.send(net);
}
/**
* 兑吧曝光埋点
* @param {IExposureData} exposure
*/
public showLog(exposure: IExposureData): void {
const net: INetData = {
name: 'showLog',
uri: exposure.domain + '/exposure/standard',
type: 'get',
dataType: 'jsonp',
param: exposure,
callback: null,
hideMsg: true
};
this.send(net);
}
/**
* 消息响应
* @param net
* @param result 结果
*/
protected onResponse(net: INetData, result: any): void {
//数据处理
const data: Data = DataManager.ins.updateData(net.name, result, net.param);
//接口成功
if (net.pollingCount && net.pollingCheck(data)) {
net.pollingCount -= 1;
//轮询接口特殊处理
setTimeout(() => {
this.send(net);
}, 500);
} else if (net.callback) {
net.callback(data.success, data || result);
}
if (!data.success && !net.hideMsg) {
GDispatcher.dispatchEvent(ABNetManager.ERROR, net, result.message || result.desc || result.msg);
}
}
/**
* 通讯底层错误
* @param net
* @param message
*/
protected onError(net: INetData): void {
if (net.callback) {
net.callback(false);
}
if (!net.hideMsg) {
GDispatcher.dispatchEvent(ABNetManager.ERROR, net);
}
}
// tslint:disable-next-line:max-file-line-count
}
\ No newline at end of file
export abstract class Model {
constructor() {
}
}
\ No newline at end of file
import { DoJoinPlugDrawData } from './../../data/plug/doJoinPlugDraw/DoJoinPlugDrawData';
import { DataManager } from './../../manager/DataManager';
import { Model } from './../Model';
import { LotteryData } from '../../data/common/lottery/LotteryData';
import { LotteryType } from '../../enum/LotteryType';
import { NetManager } from '../../manager/NetManager';
import { IExposureData } from '../..';
/**
* 兑吧活动领域模型
*/
export class ActivityModel extends Model {
/**
* 插件抽奖
* @param callback
* @param plugId
*/
public plugDoJoin(callback: Function, plugId: number): void {
NetManager.ins.doJoinPlugDraw((success: boolean) => {
if(success) {
this.getPlugOrderStatus(callback);
} else {
callback(success);
}
}, plugId);
}
/**
* 插件抽奖订单结果
* @param net
*/
public getPlugOrderStatus(callback: Function): void {
NetManager.ins.getPlugOrderStatus(callback, DataManager.ins.doJoinPlugDrawData.orderId, () => {
return DataManager.ins.getPlugOrderStatusData.result == 0;
});
}
/**
* 插件结果弹窗
*/
public get plugIsWinning(): boolean {
return DataManager.ins.getPlugOrderStatusData.lottery ? true : false;
}
/**
* 曝光埋点
*/
public showLog(): void {
//曝光埋点
if (this.lottery.imgExposure) {
NetManager.ins.showLog(this.lottery.imgExposure);
}
//如果是福袋还需要推啊曝光
if (this.lottery.type == "lucky") {
NetManager.ins.spmshow(this.exposure);
}
}
/**
* 奖品图尺寸
*/
public get optionImgSize(): string {
let size: string;
if (this.lottery.type == LotteryType.ALIPAY ||
this.lottery.type == LotteryType.VIRTUAL ||
this.lottery.type == LotteryType.OBJECT) {
size = 's';
} else {
size = 'b';
}
return size;
}
/**
* 奖品图片链接
*/
public get optionImg(): string {
return this.lottery.img;
}
/**
* 奖品名字
*/
public get optionName(): string {
return this.lottery.name;
}
/**
* 奖品数据
*/
protected get lottery(): LotteryData {
return;
}
/**
* 福袋埋点数据
*/
protected get exposure(): IExposureData {
return;
}
/**
* 立即使用
*/
public onUse(): void {
if (this.lottery.type == LotteryType.COUPON || this.lottery.type == LotteryType.LUCKY) {
window["downloadAppConfig"] =
{
openUrl: this.lottery.openUrl,
iosDownloadUrl: this.lottery.iosDownloadUrl,
androidDownloadUrl: this.lottery.androidDownloadUrl,
confirm: this.lottery.confirm ? this.lottery.confirm : false
};
window["downloadApp"]();
if (this.lottery.type == "lucky") {
NetManager.ins.spmclick(this.exposure);
}
}
else {
window.location.href = this.lottery.link;
}
}
}
\ No newline at end of file
import { ActivityModel } from './ActivityModel';
import { NetManager } from '../../manager/NetManager';
import { DataManager } from '../../manager/DataManager';
/**
* 自定义活动工具业务模型
*/
export class CustomModel extends ActivityModel {
/**
* 抽奖
* @param callback
* @param nextStep 下一步做什么,轮询结果或者前置开奖等
*/
public customDoJoin(callback: Function, nextStep: Function, collectRuleId?: number): void {
if(window['uid'] == 'not_login') {
window['requirelogin']();
return;
}
NetManager.ins.doJoin((success: boolean) => {
if(nextStep && success) {
nextStep(callback);
} else {
callback(success);
}
}, collectRuleId);
}
/**
* 获取活动工具抽奖结果
* @param callback
*/
public getCustomOrderStatus(callback: Function): void {
NetManager.ins.getCustomOrderStatus(callback, DataManager.ins.doJoinData.orderId, () => {
return DataManager.ins.getCustomOrderStatusData.result == 0;
});
}
/**
* 获取前置开奖信息
* @param callback
*/
public getOrderInfo(callback: Function): void {
NetManager.ins.getOrderInfo(callback, DataManager.ins.doJoinData.orderId);
}
/**
* 前置抽奖提交
* @param callback
*/
public beforSubmit(callback: Function): void {
NetManager.ins.beforSubmit((success: boolean) => {
if(success) {
this.getCustomOrderStatus(callback);
} else {
callback(success);
}
},
DataManager.ins.doJoinData.orderId,
DataManager.ins.getOrderInfoData.facePrice);
}
/**
* 闯关游戏提交
* @param callback
*/
public throughSubmit(callback: Function): void {
NetManager.ins.throughSubmit(callback, DataManager.ins.doJoinData.orderId);
}
/**
* 活动工具是否中奖
*/
public get customIsWinning(): boolean {
return DataManager.ins.getCustomOrderStatusData.lottery ? true : false;
}
}
\ No newline at end of file
import { DataManager } from './../../manager/DataManager';
import { NetManager } from "../../manager/NetManager";
import { ActivityModel } from "../common/ActivityModel";
import { IDynamicData } from '../..';
export class GameModel extends ActivityModel {
/**
* 获取规则数据
*/
public getRule(callback: Function): void {
if (DataManager.ins.getRuleData) {
callback(true);
} else {
NetManager.ins.getRule(callback);
}
}
/**
* 获取活动奖品数据
*/
public getOptions(callback: Function): void {
if (DataManager.ins.getOptionsData) {
callback(true);
} else {
NetManager.ins.getOptions(callback);
}
}
/**
* 开始游戏
* @param callback
* @param isAgain
* @param credits
* @param customizedType
*/
public doStart(callback: Function, isAgain = false, credits?: number, customizedType?: number): void {
if(window['requirelogin']) {
window['requirelogin']();
return;
}
NetManager.ins.doStart((success: boolean) => {
if(success) {
this.getStartOrderStatus(callback, customizedType);
} else {
callback(success);
}
},
isAgain,
credits,
customizedType);
}
/**
* 查询订单结果
* @param callback
* @param ticketId
* @param customizedType
*/
private getStartOrderStatus(callback: Function, customizedType?: number): void {
NetManager.ins.getStartStatus(
callback,
DataManager.ins.doStartData.ticketId,
() => { return DataManager.ins.getStartStatusData.code != 1; },
5,
customizedType);
}
/**
* 获取用户数据
* @param callback
*/
public getInfo(callback: Function): void {
NetManager.ins.getInfo(callback);
}
/**
* 获取夏日活动用户数据
* @param callback
*/
public getSummerInfo(callback: Function, rankBaseConfigId:number): void {
NetManager.ins.getSummerInfo(callback, rankBaseConfigId);
}
/**
* 阶段数据提交
* @param callback
* @param dynamicStr 数据
*/
protected datapashData(callback: Function, dynamicStr: string): void {
NetManager.ins.datapash(null, DataManager.ins.doStartData.ticketId, dynamicStr);
}
/**
* 猜扑克
* @param callback
* @param plugId 插件ID
* @param ruleId 集卡规则ID
* @param betting 0大1小2红3黑
*/
public guessPoker(callback: Function, plugId: number, ruleId: number, betting: number): void {
NetManager.ins.guessPoker(callback, plugId, DataManager.ins.doStartData.ticketId, ruleId, betting)
}
/**
* 提交游戏成绩
* @param callback
* @param score 得分
* @param allDynamics 防作弊数据
* @param checkScore 是否校验得分
* @param customizedType 定制类型 1推币机
*/
protected gameSubmitData(callback: Function, score: number, allDynamics: IDynamicData[][], checkScore?: boolean, customizedType?: number): void {
NetManager.ins.gameSubmit(
(success: boolean) => {
if(success) {
this.getSubmitResult(callback, DataManager.ins.gameSubmitData.orderId);
} else {
callback(success);
}
},
DataManager.ins.doStartData.ticketId,
score,
'[]',
DataManager.ins.doStartData.submitToken,
JSON.stringify(allDynamics),
checkScore,
customizedType);
}
/**
* 查询提交结果
* @param callback
* @param orderId
*/
private getSubmitResult(callback: Function, orderId: number): void {
NetManager.ins.getSubmitResult(callback, orderId, () => {
return DataManager.ins.gameGetSubmitResultData.flag;
});
}
/**
* 获取实时排行榜数据
* @param callback
* @param type 0总排行榜 1今日排行榜 2 多游戏总排行榜 3 昨日排行榜
* @param count
*/
public realtimerank(callback: Function, type = 0, count = 30): void {
NetManager.ins.realtimerank(callback, type, count)
}
}
\ No newline at end of file
import { DataManager } from './../../manager/DataManager';
import { Model } from '../Model';
export class RuleModel extends Model {
/**
* 规则文案
*/
public get ruleTxt(): any {
return DataManager.ins.getRuleData ? DataManager.ins.getRuleData.ruleText :
(DataManager.ins.ajaxElementData ? DataManager.ins.ajaxElementData.rule :
(window['ruleCFG'] ? window['ruleCFG'] : "规则")
);
}
}
\ No newline at end of file
import { SignInfoData } from './../../data/pet/SignInfoData';
import { PetHomeInfoData } from './../../data/pet/PetHomeInfoData';
import { ActivityModel } from "./ActivityModel";
import { NetManager, DataManager } from "../..";
import { PetIndexData } from "../../data/pet/PetIndexData";
export class SignModel extends ActivityModel {
/**
* 领养
* @param callback
*/
public petAdopte(callback:Function):void{
NetManager.ins.petAdopte(callback, DataManager.ins.petIndexData.activityId);
}
/**
* 获取宠物信息
* @param callback
*/
public getPetInfo(callback:Function):void{
NetManager.ins.getPetInfo(callback, DataManager.ins.petIndexData.activityId);
}
/**
* 宠物喂食
* @param callback
* @param feedNum:喂食数量
*/
public petFeed(callback:Function, feedNum:number):void {
NetManager.ins.petFeed(callback, DataManager.ins.petHomeInfoData.petId, feedNum);
}
/**
* 宠物状态刷新
* @param callback
*/
public getPetStatus(callback: Function): void {
NetManager.ins.getPetStatus(callback, DataManager.ins.petHomeInfoData.petId);
}
/**
* 签到接口
* @param {Function} callback
* @param {number} signActivityId 签到插件ID
*/
public doSign(callback: Function, signActivityId: number): void {
NetManager.ins.doSign(callback, signActivityId, DataManager.ins.petIndexData.activityId);
}
/**
* 收取礼物接口
* @param callback
* @param {number} giftId 礼物id
* @param {string} giftName 礼物名称
* @param {string} giftDesc 礼物描述
* @param {number} giftType 礼物类型 1:用户自定义, 2:食物
* @param {string} giftLink 礼物链接
* @param {number} petId 宠物id
*/
public collect(callback: Function, giftId: number, giftNum: number, giftName: string, giftDesc: string, giftType: number, giftLink: string): void {
NetManager.ins.collect(callback, giftId, giftNum, giftName, giftDesc, giftType, giftLink, DataManager.ins.petHomeInfoData.petId);
}
/**
* 用户基础数据
*/
public get petIndexData():PetIndexData
{
return DataManager.ins.petIndexData;
}
/**
* 宠物基础数据
*/
public get petHomeInfoData():PetHomeInfoData
{
return DataManager.ins.petHomeInfoData;
}
/**
* 签到详情数据
*/
public get signInfoData():SignInfoData
{
return DataManager.ins.signInfoData;
}
}
\ No newline at end of file
import { Model } from './../Model';
export class CustomOptionInfoModel extends Model {
constructor() {
super();
}
}
\ No newline at end of file
import { DataManager } from './../../manager/DataManager';
import { CustomPlayModel } from './CustomPlayModel';
import { NetManager } from '../../manager/NetManager';
import { GetOrderInfoData } from '../../data/custom/getOrderInfo/GetOrderInfoData';
import { BeforSubmitData } from '../../data/custom/beforSubmit/BeforSubmitData';
export class CustomPlayBeforModel extends CustomPlayModel {
/**
* 中奖资格
*/
public getFacePrice(): boolean {
return DataManager.ins.getOrderInfoData.facePrice != null && DataManager.ins.getOrderInfoData.facePrice != -1;
}
/**
* 中奖类型
*/
public getOptionType(): string {
return DataManager.ins.getOrderInfoData.type;
}
}
\ No newline at end of file
import { CustomModel } from './../common/CustomModel';
import { DataManager } from '../../manager/DataManager';
import { TwLang } from '../../util/TwLang';
import { GFun } from "duiba-tc";
import { ICustomOptionData, IPlugOptionData } from '../..';
/**
* 自定义活动工具玩法模型
*/
export class CustomPlayModel extends CustomModel {
/**
* 次数文案
*/
public get countTxt(): string {
let str: string;
switch (DataManager.ins.ajaxElementData.element.status) {
case 0:
break;
case 1:
str = TwLang.lang_002;
break;
case 3:
str = TwLang.lang_004 + TwLang.lang_003;
break;
case 4:
str = TwLang.lang_003;
break;
case 5:
str = TwLang.lang_004 + GFun.replace(TwLang.lang_005, [DataManager.ins.ajaxElementData.element.freeLimit]);
break;
case 6:
str = GFun.replace(TwLang.lang_006, [DataManager.ins.ajaxElementData.element.needCredits, DataManager.ins.customCfgData.unitName]);
break;
case 7:
str = GFun.replace(TwLang.lang_005, [DataManager.ins.ajaxElementData.element.freeLimit]);
break;
case 18:
str = TwLang.lang_007;
break;
}
return str;
}
/**
* 奖品列表
*/
public get optionList(): ICustomOptionData[] {
return DataManager.ins.ajaxElementData.options;
}
/**
* 活动规则
*/
public get rule(): any {
return DataManager.ins.ajaxElementData.rule;
}
}
\ No newline at end of file
import { CustomPlayModel } from './CustomPlayModel';
import { NetManager } from '../../manager/NetManager';
import { ThroughSubmitData } from '../../data/custom/throughSubmit/ThroughSubmitData';
import { DataManager } from '../../manager/DataManager';
export class CustomPlayThroughModel extends CustomPlayModel {
}
\ No newline at end of file
import { CustomModel } from './../common/CustomModel';
import { LotteryData } from './../../data/common/lottery/LotteryData';
import { DataManager } from './../../manager/DataManager';
import { IExposureData } from '../..';
export class CustomWinModel extends CustomModel {
/**
* 奖品数据
*/
protected get lottery(): LotteryData {
return DataManager.ins.getCustomOrderStatusData.lottery;
}
/**
* 埋点数据
*/
protected get exposure(): IExposureData {
return DataManager.ins.getCustomOrderStatusData.exposure;
}
}
\ No newline at end of file
import { DataManager } from './../../manager/DataManager';
import { GFun } from "duiba-tc";
import { TwLang } from '../../util/TwLang';
import { GameModel } from '../common/GameModel';
export class GameEndModel extends GameModel {
/**
* 获取积分文案
*/
public getScoreTxt(totalStr: string = TwLang.lang_011, maxStr: string = TwLang.lang_010): string {
let str: string;
if (DataManager.ins.gameCfgData.gameInfo.openTotalScoreSwitch) {
str = GFun.replace(totalStr, [DataManager.ins.getInfoData.totalScore || '0']);
} else {
str = GFun.replace(maxStr, [DataManager.ins.getInfoData.maxScore || '0']);
}
return str;
}
}
\ No newline at end of file
import { GameModel } from '../common/GameModel';
import { DataManager } from './../../manager/DataManager';
import { IRankData } from '../../data/game/winranks/IRankData';
// import { IRankData } from '../..';
export class GameEndRankModel extends GameModel {
/**
* 排行榜列表
*/
public get rankList(): IRankData[] {
return DataManager.ins.winRanksData.rankList;
}
}
\ No newline at end of file
import { GameModel } from '../common/GameModel';
import { DataManager } from './../../manager/DataManager';
import { TwLang } from '../../util/TwLang';
import { GFun } from "duiba-tc";
export class GameLoseModel extends GameModel {
/**
* 剩余次数文案
*/
public get costTxt(): string {
return DataManager.ins.getInfoData.status.text;
}
/**
* 排名文案
* @param str
*/
public getRankTxt(str: string = TwLang.lang_018): string {
return GFun.replace(str, [DataManager.ins.getInfoData.rank]);
}
/**
* 排名百分比
* @param str
*/
public getPercentageTxt(str: string = TwLang.lang_017): string {
return GFun.replace(str, [DataManager.ins.getInfoData.percentage]);
}
/**
* 当前得分文案
* @param str
*/
public getCurrScoreTxt(str: string = TwLang.lang_009): string {
return GFun.replace(str, [DataManager.ins.gameGetSubmitResultData.score]);
}
/**
* 获取最高积分
* @param maxStr
* @param totalStr
*/
public getMaxScoreTxt(maxStr: string = TwLang.lang_010, totalStr: string = TwLang.lang_011): string {
let str: string;
if (DataManager.ins.gameCfgData.gameInfo.openTotalScoreSwitch) {
str = GFun.replace(totalStr, [DataManager.ins.getInfoData.totalScore]);
} else {
str = GFun.replace(maxStr, [DataManager.ins.getInfoData.maxScore]);
}
return str;
}
}
\ No newline at end of file
import { GameModel } from '../common/GameModel';
import { DataManager } from '../../manager/DataManager';
import { TwLang } from '../../util/TwLang';
import { GFun } from "duiba-tc";
import { IGameOptionData } from '../..';
export class GameOptionModel extends GameModel {
/**
* 活动结束时间
*/
public getEndTimeTxt(endTimeTxt: string = TwLang.lang_012, openPrizeTimeTxt: string = TwLang.lang_013): string {
let str: string;
str = GFun.replace(endTimeTxt, [DataManager.ins.gameCfgData.gameInfo.offDate]);
if (DataManager.ins.gameCfgData.gameInfo.rankPrize) {
str += "\n" + openPrizeTimeTxt;
}
return str;
}
/**
* 奖品列表
*/
public get optionList(): IGameOptionData[] {
return DataManager.ins.getOptionsData.optionList;
}
}
\ No newline at end of file
import { NetManager } from './../../manager/NetManager';
import { DataManager } from './../../manager/DataManager';
import { GameModel } from '../common/GameModel';
import { GMath, GCache } from "duiba-tc";
import { IDynamicData } from '../..';
export class GamePlayModel extends GameModel {
/**
* 阶段提交次数
*/
private datapashCount: number;
/**
* 阶段动态数据
*/
private dynamics: IDynamicData[];
/**
* 游戏全程动态数据
*/
private allDynamics: IDynamicData[][];
public update(): void {
this.dynamics = [];
this.allDynamics = [];
this.datapashCount = 0;
}
/**
* 是否达到阶段提交的条件
*/
public checkDatapash(score: number): boolean {
const interfaceLimit = DataManager.ins.gameCfgData.defenseStrategy.interfaceLimit || 50;
const scoreUnit = DataManager.ins.gameCfgData.defenseStrategy.scoreUnit;
const nextDatapashScore: number = score - this.datapashCount * scoreUnit;
if (nextDatapashScore >= scoreUnit && this.datapashCount < interfaceLimit) {
return true;
}
return false;
}
/**
* 阶段提交
* @param net
*/
public datapash(): void {
const dynamicStr: string = JSON.stringify(this.dynamics);
this.allDynamics.push(this.dynamics);
this.datapashData(null, dynamicStr);
this.dynamics = [];
this.datapashCount++;
}
/**
* 添加防作弊数据
* @param dynamic
*/
public addDynamic(dynamic: IDynamicData, ...args): void {
this.dynamics.push(dynamic);
}
/**
* 缓存最高分
*/
public cacheMaxScore(score: number): void {
//将最高纪录缓存
let maxScore: number = GMath.int(GCache.readCache("maxScore"));
if (!maxScore) {
maxScore = 0;
}
maxScore = Math.max(maxScore, score);
GCache.writeCache('maxScore', maxScore);
}
/**
* 复活操作
* @param callback
* @param collectRuleId 集卡规则id
* @param itemId 复活卡id
*/
public doRevive(callback: Function, collectRuleId:number, itemId:number): void {
if(window['requirelogin']) {
window['requirelogin']();
return;
}
NetManager.ins.doRevive((success: boolean) => {
callback(success);
},
collectRuleId,
itemId
);
}
/**
* 获得复活次数
* @param callback
* @param collectRuleId 集卡规则id
* @param itemId 复活卡id
*/
public getReviveCardNum(callback:Function, collectRuleId:number, itemId:number): void {
if(window['requirelogin']) {
window['requirelogin']();
return;
}
NetManager.ins.getReviveCardNum((success: boolean) => {
callback(success);
},
collectRuleId,
itemId
);
}
/**
* 提交游戏成绩
* @param callback
* @param score 得分
* @param checkScore 是否校验得分
* @param customizedType 定制类型 1推币机
*/
public submit(callback: Function, score: number, checkScore?: boolean, customizedType?: number): void {
this.allDynamics.push(this.dynamics);
this.gameSubmitData(callback, score, this.allDynamics, checkScore, customizedType);
this.dynamics = [];
}
/**
* 游戏结束弹窗
*/
public get gameIsWinning(): boolean {
return DataManager.ins.gameGetSubmitResultData.lottery ? true : false;
}
}
\ No newline at end of file
import { GameModel } from '../common/GameModel';
import { DataManager } from './../../manager/DataManager';
import { TwLang } from '../../util/TwLang';
import { GFun } from "duiba-tc";
import { IUserData } from '../..';
export class GameRealTimeRankModel extends GameModel {
/**
* 我得排行文案
* @param inRankStr
* @param unitName 单位
* @param outRankStr
*/
public getRankTxt(inRankStr: string = TwLang.lang_015, unitName: string = TwLang.lang_016, outRankStr: string = TwLang.lang_014): string {
let str: string;
if (DataManager.ins.realTimeRankData.myUserData && DataManager.ins.realTimeRankData.myUserData.rank) {
str = GFun.replace(inRankStr,
[DataManager.ins.realTimeRankData.myUserData.maxScore, unitName, DataManager.ins.realTimeRankData.myUserData.rank]);
} else {
str = outRankStr;
}
return str;
}
/**
* 用户列表
*/
public get userList(): IUserData[] {
return DataManager.ins.realTimeRankData.userList;
}
}
\ No newline at end of file
import { GameModel } from '../common/GameModel';
import { DataManager } from '../../manager/DataManager';
import { NetManager } from '../../manager/NetManager';
export class GameStartModel extends GameModel {
/**
* 剩余次数
* 为了按钮字体的美观,不展示开始游戏之外的文案,非常规状态由业务文案代替展示。
*/
public get countTxt(): string {
let txt: string;
if (DataManager.ins.getInfoData.status.code != 0) {
txt = DataManager.ins.getInfoData.status.btnText;
} else {
txt = DataManager.ins.getInfoData.status.text;
}
return txt;
}
/**
* 开始游戏按钮状态
*/
public get startBtnEnable(): boolean {
let enable: boolean;
if (DataManager.ins.getInfoData.status.btnDisable || DataManager.ins.getInfoData.status.code == 6) {
enable = false;
} else {
enable = true;
}
return enable;
}
}
import { GameModel } from '../common/GameModel';
import { DataManager } from './../../manager/DataManager';
import { LotteryData } from '../../data/common/lottery/LotteryData';
import { TwLang } from '../../util/TwLang';
import { GFun } from '../../../tc/util/GFun';
import { IExposureData } from '../../data/common/IExposureData';
// import { GFun } from "duiba-tc";
// import { IExposureData } from '../..';
export class GameWinModel extends GameModel {
/**
* 剩余次数文案
*/
public get costTxt(): string {
return DataManager.ins.getInfoData.status.text;
}
/**
* 排名文案
* @param str
*/
public getRankTxt(str: string = TwLang.lang_018): string {
return GFun.replace(str, [DataManager.ins.getInfoData.rank]);
}
/**
* 排名百分比
* @param str
*/
public getPercentageTxt(str: string = TwLang.lang_017): string {
return GFun.replace(str, [DataManager.ins.getInfoData.percentage]);
}
/**
* 当前得分文案
* @param str
*/
public getCurrScoreTxt(str: string = TwLang.lang_009): string {
return GFun.replace(str, [DataManager.ins.gameGetSubmitResultData.score]);
}
/**
* 获取最高积分
* @param maxStr
* @param totalStr
*/
public getMaxScoreTxt(maxStr: string = TwLang.lang_010, totalStr: string = TwLang.lang_011): string {
let str: string;
if (DataManager.ins.gameCfgData.gameInfo.openTotalScoreSwitch) {
str = GFun.replace(totalStr, [DataManager.ins.getInfoData.totalScore]);
} else {
str = GFun.replace(maxStr, [DataManager.ins.getInfoData.maxScore]);
}
return str;
}
/**
* 奖品数据
*/
protected get lottery(): LotteryData {
return DataManager.ins.gameGetSubmitResultData.lottery;
}
/**
* 埋点数据
*/
protected get exposure(): IExposureData {
return DataManager.ins.gameGetSubmitResultData.exposure;
}
}
\ No newline at end of file
import { GameModel } from '../common/GameModel';
import { DataManager } from './../../manager/DataManager';
import { TwLang } from '../../util/TwLang';
import { GFun } from '../../../tc/util/GFun';
import { IRankData } from '../../data/game/winranks/IRankData';
export class GameWinnerModel extends GameModel {
/**
* 排名文案
* @param rankStr
*/
public getRankTxt(rankStr: string = TwLang.lang_020): string {
if(DataManager.ins.winRanksData.consumer.rank == "?") {
return GFun.replace(TwLang.lang_019, [DataManager.ins.winRanksData.consumer.rank || '0']);
}
return GFun.replace(rankStr, [DataManager.ins.winRanksData.consumer.rank]);
}
/**
* 奖品文案
* @param winningStr
* @param notWinningStr
* @param notJoinStr
*/
public getOptionTxt(winningStr: string = TwLang.lang_021, notWinningStr: string = TwLang.lang_022, notJoinStr: string = TwLang.lang_024): string {
let str: string;
//是否参与过游戏
if (DataManager.ins.winRanksData.consumer.join) {
//是否中奖
if (DataManager.ins.winRanksData.consumer.option) {
str = GFun.replace(winningStr, [DataManager.ins.winRanksData.consumer.option]);
} else {
str = notWinningStr;
}
} else {
str = notJoinStr;
}
return str;
}
/**
* 用户ID文案
* @param str
*/
public getConsumerTxt(str: string = TwLang.lang_023): string {
return GFun.replace(str, [DataManager.ins.winRanksData.consumer.cid])
}
/**
* 排行列表
*/
public get rankList(): IRankData[] {
return DataManager.ins.winRanksData.rankList;
}
}
\ No newline at end of file
import { ActivityModel } from './../common/ActivityModel';
import { DataManager } from './../../manager/DataManager';
import { NetManager } from '../../manager/NetManager';
import { LotteryData } from '../../data/common/lottery/LotteryData';
import { IExposureData } from '../../data/common/IExposureData';
// import { IExposureData } from '../..';
export class PlugWinModel extends ActivityModel {
/**
* 奖品数据
*/
protected get lottery(): LotteryData {
return DataManager.ins.getPlugOrderStatusData.lottery;
}
/**
* 福袋埋点数据
*/
protected get exposure(): IExposureData {
return DataManager.ins.getPlugOrderStatusData.exposure;
}
}
\ No newline at end of file
import { SignModel } from '../common/SignModel';
import { PetIndexData } from '../../data/pet/PetIndexData';
import { DataManager } from '../../manager/DataManager';
export class SignAdopteModel extends SignModel {
}
import { SignModel } from '../common/SignModel';
export class SignPlayModel extends SignModel {
}
import { DataManager } from './../manager/DataManager';
import { IExposureData } from '../data/common/IExposureData';
// import { IExposureData } from '..';
export class Buried {
private static appId: number;
private static consumerId: number;
private static oaId: number;
/**
* 初始化
*/
public static init(): void {
if(DataManager.ins.gameCfgData) {
this.appId = DataManager.ins.gameCfgData.appInfo.appId;
this.consumerId = DataManager.ins.getInfoData.consumerId;
this.oaId = DataManager.ins.gameCfgData.gameInfo.oaId;
} else if(DataManager.ins.customCfgData){
this.appId = DataManager.ins.customCfgData.appId;
this.consumerId = DataManager.ins.customCfgData.consumerId;
this.oaId = DataManager.ins.customCfgData.oaId ;
} else if(DataManager.ins.petIndexData && DataManager.ins.petIndexData.appId && DataManager.ins.petIndexData.activityId){
this.appId = DataManager.ins.petIndexData.appId;
this.consumerId = DataManager.ins.petIndexData.consumerId;
this.oaId = DataManager.ins.petIndexData.activityId ;
} else if(DataManager.ins.petsIndexData && DataManager.ins.petsIndexData.appId && DataManager.ins.petsIndexData.activityId){
this.appId = DataManager.ins.petsIndexData.appId;
this.consumerId = DataManager.ins.petsIndexData.consumerId;
this.oaId = DataManager.ins.petsIndexData.activityId ;
}
}
/**
* 创建dpm埋点数据
* @param {string} dpm 点击埋点
* @param {string} dcm 曝光埋点
* @param {string} embedDomain 埋点域名
* @returns {{dpm: string; consumerId: number; domain: string; appId: number}}
*/
public static createExposure(dpm: string, dcm: string, embedDomain = '//embedlog.duiba.com.cn'): IExposureData {
const exposure: IExposureData = {
dpm: dpm,
dcm: dcm,
consumerId: Buried.consumerId,
appId: Buried.appId,
domain: embedDomain
};
return exposure;
}
/**
* dpm拼接
* @param pageId 页面ID
* @param area 区域
* @param dpm 埋点号
* @returns {string}
*/
public static connectDpm(pageId: number, area: number, dpm: number): string {
return Buried.appId + '.' + pageId + '.' + area + '.' + dpm;
}
/**
* dcm拼接
* @param typeId 类型ID
* @param contentInfo 内容信息
* @param dcm 埋点号
* @returns {string}
*/
public static connectDcm(typeId: number, contentInfo: number, dcm: number): string {
return typeId + '.' + Buried.oaId + '.' + contentInfo + '.' + dcm;
}
/**
* 插件dcm拼接
* @param plugId 插件ID
* @param type 1 活动工具 2 主会场 4 楼层 5 游戏 7 子页面
* @returns {string}
*/
public static connectPlugDcm(plugId: number, type: number): string {
return 212 + '.' + plugId + '.' + type + '.' + Buried.oaId;
}
/**
* 活动dcm拼接
* @param type 1 活动工具 2 主会场 4 楼层 5 游戏 7 子页面
* @returns {string}
*/
public static connectActivityDcm(type: number): string {
return 202 + '.' + Buried.oaId + '.' + type + '.' + Buried.oaId;
}
}
import { IShareData } from "../data/common/IShareData";
// import { IShareData } from "..";
export class Share {
/**
* 分享
*/
public static doShare(sd: IShareData): void {
switch (sd.appName) {
case '360手机卫士':
//360手机卫士
this.sjws360(sd);
break;
case '360清理大师':
//360清理大师
this.clean360(sd);
break;
case '腾讯视频':
//腾讯视频
break;
case '百度宝宝':
//百度宝宝
this.baiduBB(sd);
break;
case 'QQ阅读':
//QQ阅读
this.qqRead(sd);
break;
case 'QQ浏览器':
//QQ浏览器
this.qqBrowser(sd);
break;
case '饿了么':
//饿了么
this.elm(sd);
break;
case '书旗小说':
//书旗小说
this.bookChess(sd);
break;
case '优酷视频':
//优酷视频
this.youku(sd);
break;
}
}
/**
* 360手机卫士分享
* @param {IShareData} sd
*/
private static sjws360(sd: IShareData) {
if (navigator.userAgent.match(/iphone|ipod|ipad/gi)) {
window['SESDK']['share']({
contexts: [{
type: 'weibo',
text: sd.desc,
url: sd.link,
img: sd.imgUrl
},
{
type: 'wechat.friend.link',
title: sd.title,
desc: sd.desc,
thumb: sd.imgUrl,
url: sd.link
},
{
type: 'wechat.timeline.link',
title: sd.title,
thumb: sd.imgUrl,
url: sd.link
}]
});
} else {
window['MobileSafeJsInterface']['share'](JSON.stringify({
weixin: {
title: sd.title,
desc: sd.desc,
link: sd.link,
type: "0",
img_url: sd.imgUrl
},
weibo: {
desc: sd.desc, //微博分享内容
type: "0",
img_url: sd.imgUrl //微博分享的长图
}
}));
}
}
/**
* 360清理大师分享
* @param {IShareData} sd
*/
private static clean360(sd: IShareData) {
//分享前需要先初始化分享图片
window['android']['prepareShare'](JSON.stringify({ "iconUrl": sd.imgUrl }));
//调起分享面板
window['android']['share'](JSON.stringify({
content: sd.desc,
weiboContent: sd.desc,
weixinContent: sd.desc,
weixinTitle: sd.title,
shareUrl: sd.link
}));
}
/**
* 腾讯视频分享
* @param {ShareData} sd
*/
private static txTv(sd: IShareData) {
}
/**
* 百度宝宝分享
* @param {ShareData} sd
*/
private static baiduBB(sd: IShareData) {
//自定义右上角分享
window['hybridApi']['exec']('setShare', { title: sd.title, text: sd.desc, url: sd.link, image: sd.imgUrl });
//调起分享面板
window['hybridApi']['exec']('share', { title: sd.title, text: sd.desc, url: sd.link, image: sd.imgUrl });
}
/**
* QQ阅读分享
* @param {ShareData} sd
*/
private static qqRead(sd: IShareData) {
// 1.调起分享页面
window["Local"].shareTopic(sd.link, sd.imgUrl, sd.title, sd.desc);
// 2.右上角“...”分享添加
window['Local'].setIconForShareing(sd.link, sd.imgUrl, sd.title, sd.desc);
}
/**
* QQ浏览器分享
* @param {ShareData} sd
*/
private static qqBrowser(sd: IShareData) {
const options = {
url: sd.link,
title: sd.title,
description: sd.desc,
img_url: sd.imgUrl
}
window["share"](options, null);
}
/**
* 汽车报价大全
* @param {ShareData} sd
*/
private static carPrice(sd: IShareData) {
}
/**
* 饿了么分享
* @param {ShareData} sd
*/
private static elm(sd: IShareData) {
window['hybridAPI']['sharePanel']({
source: 'stage', //来源,用于统计
targets: ['weixin', 'weixin_timeline', 'weibo', 'qq', 'qzone'], // 分享按钮
title: sd.title,
text: sd.desc,
url: sd.link,
image_url: sd.imgUrl,
image_only: true, // 7.14 新增,分享整张图片(image_url),只支持微信、朋友圈、QQ。
})
}
/**
* 书旗小说分享
* @param {ShareData} sd
*/
private static bookChess(sd: IShareData) {
const data = {
shareUrl: sd.link,
shareTitle: sd.title,
shareContent: sd.desc
}
window['anShuqiForSqWebJS']['openAppSendShareData'](JSON.stringify(data));
}
/**
* 书旗小说分享
* @param {ShareData} sd
*/
private static youku(sd: IShareData) {
window['']['setShare']({
title: sd.title,
link: sd.link,
img: sd.imgUrl,
img_only: false
});
}
}
\ No newline at end of file
import { DataManager } from "../manager/DataManager";
export class TwFun {
/**
* 获取兑换记录地址
* @param actId 活动ID
* @param type 入库活动(游戏、新活动工具、自定义活动工具、竞猜、答题) — 00
* 插件活动、插件式抽奖工具 — 01
* 开心码 — 02
* 集卡开奖 — 03
*/
public static getRecordUrl(type: string ,ids?: number[]): string {
let recordUrl: string;
let oaId: number;
if (DataManager.ins.customCfgData) {
oaId = DataManager.ins.customCfgData.oaId;
recordUrl = DataManager.ins.customCfgData.recordUrl;
} else {
oaId = DataManager.ins.gameCfgData.gameInfo.oaId;
recordUrl = window['recordUrl'];
}
if(!ids) {
ids = [oaId];
}
let i = 0;
const len = ids.length;
for(i; i < len; i++) {
recordUrl += '?origins=' + ids[i] + type;
}
return recordUrl;
}
/**
* 生成活动链接
* @param type 1游戏、2活动工具
* @param activityId 活动ID
* @param dpm 点击埋点
* @param dcm 曝光埋点
*/
public static createActivityUrl(type: number, activityId: number, dpm: string, dcm: string): string {
let url: string;
switch (type) {
case 1:
url = '//activity.m.duiba.com.cn/ngame/duiba?id=';
break;
case 2:
url = '//activity.m.duiba.com.cn/newActivity/duiba?id=';
break;
}
return url + activityId + '&dbnewopen&dpm=' + dpm + '&dcm=' + dcm;
}
/**
* 获取指定app指定索引的的活动ID
* @param appId appId
* @param pool 活动池
* pool格式
* {
* appId1: [activityId1, activityId2, activityId3, activityId4],
* appId2: [activityId1, activityId2, activityId3, activityId4]
* }
* 默认必须有内测的appId和对应的活动ID组
* 当查找不到指定的appId则获取默认的内测数据
* @param index 活动索引
*/
public static getActivityIdByAppId(appId: number, pool: any, index: number): number {
return pool[appId] ? pool[appId][index] : pool[1][index];
}
}
export class TwLang {
public static lang_001 = "单例模式,无法重复初始化";
public static lang_002 = "积分不足";
public static lang_003 = "次数不足";
public static lang_004 = "今日";
public static lang_005 = "剩余{0}次";
public static lang_006 = "{0}{1}/次";
public static lang_007 = "请先登录";
public static lang_008 = '您成功击败了{0}的玩家';
public static lang_009 = '本次成绩:{0}';
public static lang_010 = '最佳成绩:{0}';
public static lang_011 = '累计总成绩:{0}';
public static lang_012 = '游戏结束时间为:{0}';
public static lang_013 = '游戏结束一天内开奖';
public static lang_014 = "对不起,你还未有通关成绩";
public static lang_015 = "你的最佳成绩为{0}{1},排名第{2}名";
public static lang_016 = '分';
public static lang_017 = '成功击败了{0}%的玩家';
public static lang_018 = '当前排名:{0}';
public static lang_019 = '抱歉,您未上榜';
public static lang_020 = '您的排名第{0}';
public static lang_021 = '恭喜您获得了:{0}';
public static lang_022 = '很遗憾,没有中奖哦!';
public static lang_023 = '您的用户ID是:{0}';
public static lang_024 = '您未参与游戏';
// public static lang_026 = '最佳成绩:{0}';
// public static lang_027 = '累计总成绩:{0}';
}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"alert_3","version":5,"files":["../assets/alert/Bitmap-4.png","../assets/alert/Bitmap-2.png","../assets/alert/Bitmap-1.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"loading_2","version":5,"files":["../assets/loading/bg.png","../assets/loading/progress.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"msg_0","version":5,"files":["../assets/msg/msgBg.png","../assets/msg/x.png","../assets/msg/sureBtn.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"playScene_1","version":5,"files":["../assets/playScene/wheelBg2.png","../assets/playScene/wating.png","../assets/playScene/startBtnBg.png","../assets/playScene/sideLightL.png","../assets/playScene/sideLightD.png","../assets/playScene/ruleBtn.png","../assets/playScene/redPacket.png","../assets/playScene/outShell.png","../assets/playScene/myCreditsBg.png","../assets/playScene/multiple3.png","../assets/playScene/multiple.png","../assets/playScene/heartB.png","../assets/playScene/go.png","../assets/playScene/gift.png","../assets/playScene/finger.png","../assets/playScene/earnPanel.png","../assets/playScene/coinIcon.png","../assets/playScene/coinf8.png","../assets/playScene/coinf7.png","../assets/playScene/coinf6.png","../assets/playScene/coinf5.png","../assets/playScene/coinf4.png","../assets/playScene/coinf3.png","../assets/playScene/coinf2.png","../assets/playScene/coinf1.png","../assets/playScene/circleLight2.png","../assets/playScene/circleLight1.png","../assets/playScene/+.png","../assets/playScene/-_.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"preload_0","version":5,"files":["../assets/circle.png","../assets/rect.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"rule_4","version":5,"files":["../assets/rule/ruleBg.png","../assets/rule/X.png"]}
\ No newline at end of file
{"mc":{
"coin":{
"frameRate":24,
"labels":[
{"name":"rotate","frame":1,"end":8}
],
"events":[
],
"frames":[
{
"res":"DB0A020",
"x":0,
"y":0
},
{
"res":"11118EED",
"x":0,
"y":0
},
{
"res":"3ED3A22C",
"x":8,
"y":0
},
{
"res":"EA81E94D",
"x":20,
"y":0
},
{
"res":"9D677726",
"x":37,
"y":0
},
{
"res":"7A80B82A",
"x":20,
"y":0
},
{
"res":"AA7CF946",
"x":8,
"y":0
},
{
"res":"2E51F51A",
"x":0,
"y":0
}
]
}},
"res":{
"AA7CF946":{"x":176,"y":97,"w":78,"h":94},
"11118EED":{"x":1,"y":1,"w":93,"h":94},
"EA81E94D":{"x":191,"y":1,"w":53,"h":94},
"2E51F51A":{"x":96,"y":1,"w":93,"h":94},
"7A80B82A":{"x":1,"y":193,"w":53,"h":94},
"3ED3A22C":{"x":96,"y":97,"w":78,"h":94},
"9D677726":{"x":56,"y":193,"w":20,"h":94},
"DB0A020":{"x":1,"y":97,"w":93,"h":94}
}}
\ No newline at end of file
{"mc":{
"go":{
"frameRate":20,
"labels":[
{"name":"light","frame":1,"end":30}
],
"events":[
],
"frames":[
{
"res":"A9D1D9F7",
"x":8,
"y":5
},
{
"res":"A9D1D9F7",
"x":8,
"y":5
},
{
"res":"165B8393",
"x":8,
"y":5
},
{
"res":"165B8393",
"x":8,
"y":5
},
{
"res":"C533ADB8",
"x":8,
"y":5
},
{
"res":"C533ADB8",
"x":8,
"y":5
},
{
"res":"7C56153B",
"x":6,
"y":5
},
{
"res":"C3226410",
"x":6,
"y":5
},
{
"res":"C3226410",
"x":6,
"y":5
},
{
"res":"8A450EA9",
"x":8,
"y":5
},
{
"res":"764FAFD2",
"x":8,
"y":5
},
{
"res":"A86D3DEA",
"x":8,
"y":5
},
{
"res":"F8A55074",
"x":8,
"y":4
},
{
"res":"6DDF7B77",
"x":8,
"y":4
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"10E93F01",
"x":8,
"y":5
}
]
}},
"res":{
"10E93F01":{"x":709,"y":1,"w":174,"h":176},
"C3226410":{"x":1,"y":1,"w":176,"h":176},
"764FAFD2":{"x":1,"y":179,"w":174,"h":176},
"C533ADB8":{"x":1,"y":357,"w":174,"h":176},
"6DDF7B77":{"x":533,"y":1,"w":174,"h":177},
"F8A55074":{"x":357,"y":1,"w":174,"h":177},
"A86D3DEA":{"x":177,"y":179,"w":174,"h":176},
"165B8393":{"x":709,"y":179,"w":174,"h":176},
"A9D1D9F7":{"x":353,"y":180,"w":174,"h":176},
"AF8A3362":{"x":529,"y":180,"w":174,"h":176},
"7C56153B":{"x":179,"y":1,"w":176,"h":176},
"8A450EA9":{"x":177,"y":357,"w":174,"h":176}
}}
\ No newline at end of file
{
"groups": [
{
"keys": "bg_jpg,circle_png,jj_jpg,rect_png",
"keys": "msgBg_png,x_png,sureBtn_png",
"name": "msg"
},
{
"keys": "wheelBg2_png,wating_png,startBtnBg_png,sideLightL_png,sideLightD_png,ruleBtn_png,redPacket_png,outShell_png,myCreditsBg_png,multiple3_png,multiple_png,heartB_png,goBtn_png,goBtn_json,go_png,gift_png,finger_png,earnPanel_png,coinIcon_png,coinf8_png,coinf7_png,coinf6_png,coinf5_png,coinf4_png,coinf3_png,coinf2_png,coinf1_png,coin_png,coin_json,circleLight2_png,circleLight1_png,+_png,-__png,playSceneBg_jpg",
"name": "playScene"
},
{
"keys": "bg_png,progress_png",
"name": "loading"
},
{
"keys": "Bitmap-4_png,Bitmap-2_png,Bitmap-1_png",
"name": "alert"
},
{
"keys": "ruleBg_png,X_png",
"name": "rule"
},
{
"keys": "playSceneBg_jpg",
"name": "preload"
}
],
"resources": [
{
"url": "assets/bg.jpg",
"url": "assets/alert/Bitmap-1.png",
"type": "image",
"name": "Bitmap-1_png"
},
{
"url": "assets/alert/Bitmap-2.png",
"type": "image",
"name": "Bitmap-2_png"
},
{
"url": "assets/alert/Bitmap-4.png",
"type": "image",
"name": "Bitmap-4_png"
},
{
"url": "assets/msg/msgBg.png",
"type": "image",
"name": "msgBg_png"
},
{
"url": "assets/msg/sureBtn.png",
"type": "image",
"name": "sureBtn_png"
},
{
"url": "assets/msg/x.png",
"type": "image",
"name": "x_png"
},
{
"url": "assets/playScene/+.png",
"type": "image",
"name": "+_png"
},
{
"url": "assets/playScene/-_.png",
"type": "image",
"name": "-__png"
},
{
"url": "assets/playScene/circleLight1.png",
"type": "image",
"name": "circleLight1_png"
},
{
"url": "assets/playScene/circleLight2.png",
"type": "image",
"name": "circleLight2_png"
},
{
"url": "assets/playScene/coin.png",
"type": "image",
"name": "coin_png"
},
{
"url": "assets/playScene/coinIcon.png",
"type": "image",
"name": "coinIcon_png"
},
{
"url": "assets/playScene/coinf1.png",
"type": "image",
"name": "coinf1_png"
},
{
"url": "assets/playScene/coinf2.png",
"type": "image",
"name": "coinf2_png"
},
{
"url": "assets/playScene/coinf3.png",
"type": "image",
"name": "coinf3_png"
},
{
"url": "assets/playScene/coinf4.png",
"type": "image",
"name": "coinf4_png"
},
{
"url": "assets/playScene/coinf5.png",
"type": "image",
"name": "coinf5_png"
},
{
"url": "assets/playScene/coinf6.png",
"type": "image",
"name": "coinf6_png"
},
{
"url": "assets/playScene/coinf7.png",
"type": "image",
"name": "bg_jpg"
"name": "coinf7_png"
},
{
"name": "circle_png",
"url": "assets/playScene/coinf8.png",
"type": "image",
"url": "assets/circle.png"
"name": "coinf8_png"
},
{
"name": "jj_jpg",
"url": "assets/playScene/earnPanel.png",
"type": "image",
"url": "assets/jj.jpg"
"name": "earnPanel_png"
},
{
"url": "assets/playScene/finger.png",
"type": "image",
"name": "finger_png"
},
{
"url": "assets/playScene/gift.png",
"type": "image",
"name": "gift_png"
},
{
"url": "assets/playScene/go.png",
"type": "image",
"name": "go_png"
},
{
"url": "assets/playScene/goBtn.png",
"type": "image",
"name": "goBtn_png"
},
{
"url": "assets/playScene/heartB.png",
"type": "image",
"name": "heartB_png"
},
{
"url": "assets/playScene/multiple.png",
"type": "image",
"name": "multiple_png"
},
{
"url": "assets/playScene/multiple3.png",
"type": "image",
"name": "multiple3_png"
},
{
"url": "assets/playScene/myCreditsBg.png",
"type": "image",
"name": "myCreditsBg_png"
},
{
"url": "assets/playScene/outShell.png",
"type": "image",
"name": "outShell_png"
},
{
"url": "assets/playScene/redPacket.png",
"type": "image",
"name": "redPacket_png"
},
{
"url": "assets/playScene/ruleBtn.png",
"type": "image",
"name": "ruleBtn_png"
},
{
"url": "assets/playScene/sideLightD.png",
"type": "image",
"name": "sideLightD_png"
},
{
"url": "assets/playScene/sideLightL.png",
"type": "image",
"name": "sideLightL_png"
},
{
"url": "assets/playScene/startBtnBg.png",
"type": "image",
"name": "startBtnBg_png"
},
{
"url": "assets/playScene/wating.png",
"type": "image",
"name": "wating_png"
},
{
"url": "assets/playScene/wheelBg2.png",
"type": "image",
"name": "wheelBg2_png"
},
{
"url": "assets/loading/bg.png",
"type": "image",
"name": "bg_png"
},
{
"url": "assets/loading/progress.png",
"type": "image",
"name": "progress_png"
},
{
"url": "assets/rule/X.png",
"type": "image",
"name": "X_png"
},
{
"url": "assets/rule/ruleBg.png",
"type": "image",
"name": "ruleBg_png"
},
{
"url": "assets/playScene/coin.json",
"type": "json",
"name": "coin_json"
},
{
"url": "assets/playScene/goBtn.json",
"type": "json",
"name": "goBtn_json"
},
{
"name": "rect_png",
"url": "assets/playScene/playSceneBg.jpg",
"type": "image",
"url": "assets/rect.png"
"name": "playSceneBg_jpg"
}
]
}
\ No newline at end of file
{
"skins": {
"eui.Button": "resource/eui_skins/ButtonSkin.exml",
"eui.CheckBox": "resource/eui_skins/CheckBoxSkin.exml",
"eui.HScrollBar": "resource/eui_skins/HScrollBarSkin.exml",
"eui.HSlider": "resource/eui_skins/HSliderSkin.exml",
"eui.Panel": "resource/eui_skins/PanelSkin.exml",
"eui.TextInput": "resource/eui_skins/TextInputSkin.exml",
"eui.ProgressBar": "resource/eui_skins/ProgressBarSkin.exml",
"eui.RadioButton": "resource/eui_skins/RadioButtonSkin.exml",
"eui.Scroller": "resource/eui_skins/ScrollerSkin.exml",
"eui.ToggleSwitch": "resource/eui_skins/ToggleSwitchSkin.exml",
"eui.VScrollBar": "resource/eui_skins/VScrollBarSkin.exml",
"eui.VSlider": "resource/eui_skins/VSliderSkin.exml",
"eui.ItemRenderer": "resource/eui_skins/ItemRendererSkin.exml"
},
"skins": {},
"autoGenerateExmlsList": true,
"exmls": [
"resource/eui_skins/ButtonSkin.exml",
"resource/eui_skins/CheckBoxSkin.exml",
"resource/eui_skins/HScrollBarSkin.exml",
"resource/eui_skins/HSliderSkin.exml",
"resource/eui_skins/ItemRendererSkin.exml",
"resource/eui_skins/PanelSkin.exml",
"resource/eui_skins/ProgressBarSkin.exml",
"resource/eui_skins/RadioButtonSkin.exml",
"resource/eui_skins/ScrollerSkin.exml",
"resource/eui_skins/TextInputSkin.exml",
"resource/eui_skins/ToggleSwitchSkin.exml",
"resource/eui_skins/VScrollBarSkin.exml",
"resource/eui_skins/VSliderSkin.exml"
"resource/skins/AlertSkin.exml",
"resource/skins/LoadingSkin.exml",
"resource/skins/MsgSkin.exml",
"resource/skins/PlaySkin.exml",
"resource/skins/RuleSkin.exml",
"resource/skins/component/ResultPanel.exml",
"resource/skins/component/WheelBg.exml",
"resource/skins/component/WheelGift.exml",
"resource/skins/ui/IconButtonSkin.exml",
"resource/skins/ui/ProgressBarSkin.exml",
"resource/skins/ui/StartButtonSkin.exml"
],
"path": "resource/default.thm.json"
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<e:Skin class="skins.ButtonSkin" states="up,down,disabled" minHeight="50" minWidth="100" xmlns:e="http://ns.egret.com/eui">
<e:Image width="100%" height="100%" scale9Grid="1,3,8,8" alpha.disabled="0.5"
source="button_up_png"
source.down="button_down_png"/>
<e:Label id="labelDisplay" top="8" bottom="8" left="8" right="8"
size="20"
textColor="0xFFFFFF" verticalAlign="middle" textAlign="center"/>
<e:Image id="iconDisplay" horizontalCenter="0" verticalCenter="0"/>
</e:Skin>
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="skins.CheckBoxSkin" states="up,down,disabled,upAndSelected,downAndSelected,disabledAndSelected" xmlns:e="http://ns.egret.com/eui">
<e:Group width="100%" height="100%">
<e:layout>
<e:HorizontalLayout verticalAlign="middle"/>
</e:layout>
<e:Image fillMode="scale" alpha="1" alpha.disabled="0.5" alpha.down="0.7"
source="checkbox_unselect_png"
source.upAndSelected="checkbox_select_up_png"
source.downAndSelected="checkbox_select_down_png"
source.disabledAndSelected="checkbox_select_disabled_png"/>
<e:Label id="labelDisplay" size="20" textColor="0x707070"
textAlign="center" verticalAlign="middle"
fontFamily="Tahoma"/>
</e:Group>
</e:Skin>
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="skins.HScrollBarSkin" minWidth="20" minHeight="8" xmlns:e="http://ns.egret.com/eui">
<e:Image id="thumb" source="roundthumb_png" scale9Grid="3,3,2,2" height="8" width="30" verticalCenter="0"/>
</e:Skin>
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="skins.HSliderSkin" minWidth="20" minHeight="8" xmlns:e="http://ns.egret.com/eui">
<e:Image id="track" source="track_sb_png" scale9Grid="1,1,4,4" width="100%"
height="6" verticalCenter="0"/>
<e:Image id="thumb" source="thumb_png" verticalCenter="0"/>
</e:Skin>
<?xml version="1.0" encoding="utf-8" ?>
<e:Skin class="skins.ItemRendererSkin" states="up,down,disabled" minHeight="50" minWidth="100" xmlns:e="http://ns.egret.com/eui">
<e:Image width="100%" height="100%" scale9Grid="1,3,8,8" alpha.disabled="0.5"
source="button_up_png"
source.down="button_down_png"/>
<e:Label id="labelDisplay" top="8" bottom="8" left="8" right="8"
size="20" fontFamily="Tahoma"
textColor="0xFFFFFF" text="{data}" verticalAlign="middle" textAlign="center"/>
</e:Skin>
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="skins.PanelSkin" minHeight="230" minWidth="450" xmlns:e="http://ns.egret.com/eui">
<e:Image left="0" right="0" bottom="0" top="0" source="border_png" scale9Grid="2,2,12,12" />
<e:Group id="moveArea" left="0" right="0" top="0" height="45">
<e:Image left="0" right="0" bottom="0" top="0" source="header_png"/>
<e:Label id="titleDisplay" size="20" fontFamily="Tahoma" textColor="0xFFFFFF"
wordWrap="false" left="15" right="5" verticalCenter="0"/>
</e:Group>
<e:Button id="closeButton" label="close" bottom="5" horizontalCenter="0"/>
</e:Skin>
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="skins.ProgressBarSkin" minWidth="30" minHeight="18" xmlns:e="http://ns.egret.com/eui">
<e:Image source="track_pb_png" scale9Grid="1,1,4,4" width="100%"
height="100%" verticalCenter="0"/>
<e:Image id="thumb" height="100%" width="100%" source="thumb_pb_png"/>
<e:Label id="labelDisplay" textAlign="center" verticalAlign="middle"
size="15" fontFamily="Tahoma" textColor="0x707070"
horizontalCenter="0" verticalCenter="0"/>
</e:Skin>
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="skins.RadioButtonSkin" states="up,down,disabled,upAndSelected,downAndSelected,disabledAndSelected" xmlns:e="http://ns.egret.com/eui">
<e:Group width="100%" height="100%">
<e:layout>
<e:HorizontalLayout verticalAlign="middle"/>
</e:layout>
<e:Image fillMode="scale" alpha="1" alpha.disabled="0.5" alpha.down="0.7"
source="radiobutton_unselect_png"
source.upAndSelected="radiobutton_select_up_png"
source.downAndSelected="radiobutton_select_down_png"
source.disabledAndSelected="radiobutton_select_disabled_png"/>
<e:Label id="labelDisplay" size="20" textColor="0x707070"
textAlign="center" verticalAlign="middle"
fontFamily="Tahoma"/>
</e:Group>
</e:Skin>
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="skins.ScrollerSkin" minWidth="20" minHeight="20" xmlns:e="http://ns.egret.com/eui">
<e:HScrollBar id="horizontalScrollBar" width="100%" bottom="0"/>
<e:VScrollBar id="verticalScrollBar" height="100%" right="0"/>
</e:Skin>
\ No newline at end of file
<?xml version='1.0' encoding='utf-8'?>
<e:Skin class="skins.TextInputSkin" minHeight="40" minWidth="300" states="normal,disabled,normalWithPrompt,disabledWithPrompt" xmlns:e="http://ns.egret.com/eui">
<e:Image width="100%" height="100%" scale9Grid="1,3,8,8" source="button_up_png"/>
<e:Rect height="100%" width="100%" fillColor="0xffffff"/>
<e:EditableText id="textDisplay" verticalCenter="0" left="10" right="10"
textColor="0x000000" textColor.disabled="0xff0000" width="100%" height="24" size="20" />
<e:Label id="promptDisplay" verticalCenter="0" left="10" right="10"
textColor="0xa9a9a9" width="100%" height="24" size="20" touchEnabled="false" includeIn="normalWithPrompt,disabledWithPrompt"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="skins.ToggleSwitchSkin" states="up,down,disabled,upAndSelected,downAndSelected,disabledAndSelected" xmlns:e="http://ns.egret.com/eui">
<e:Image source="on_png"
source.up="off_png"
source.down="off_png"
source.disabled="off_png"/>
<e:Image source="handle_png"
horizontalCenter="-18"
horizontalCenter.upAndSelected="18"
horizontalCenter.downAndSelected="18"
horizontalCenter.disabledAndSelected="18"
verticalCenter="0"/>
</e:Skin>
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="skins.VScrollBarSkin" minWidth="8" minHeight="20" xmlns:e="http://ns.egret.com/eui">
<e:Image id="thumb" source="roundthumb_png" scale9Grid="3,3,2,2" height="30" width="8" horizontalCenter="0"/>
</e:Skin>
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="skins.VSliderSkin" minWidth="25" minHeight="30" xmlns:e="http://ns.egret.com/eui">
<e:Image id="track" source="track_png" scale9Grid="1,1,4,4" width="7" height="100%" horizontalCenter="0"/>
<e:Image id="thumb" source="thumb_png" horizontalCenter="0" />
</e:Skin>
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="AlertSkin" width="750" height="1206" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Image source="Bitmap-1_png" y="175" horizontalCenter="0"/>
<e:Button id="confirmBtn" label="{data.btnTxt}" y="361" horizontalCenter="0">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="Bitmap-2_png" source.down="Bitmap-2_png" source.disabled="Bitmap-2_png" horizontalCenter.down="0" verticalCenter.down="0"/>
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0"/>
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="closeBtn" label="" x="586.18" y="143">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="Bitmap-4_png" source.down="Bitmap-4_png" source.disabled="Bitmap-4_png"/>
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0"/>
</e:Skin>
</e:skinName>
</e:Button>
<e:Label text="{data.message}" y="239" textColor="0x000000" horizontalCenter="0"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="loadingSkin" width="750" height="1206" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing" xmlns:tween="egret.tween.*">
<w:Declarations>
</w:Declarations>
<e:Image y="288" source="bg_png" horizontalCenter="0"/>
<e:Image id="waitImg" source="progress_png" y="380" anchorOffsetX="28" anchorOffsetY="28" horizontalCenter="0" rotation="{data.speed}"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="MsgSkin" width="750" height="1624" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Rect id="dark" width="750" height="1624" x="0" y="0" fillAlpha="0.5"/>
<e:Image id="bg" y="160" x="105.5" source="msgBg_png"/>
<e:Button id="confirmBtn" label="{data.btnTxt}" y="610" x="209.5">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="sureBtn_png" source.down="sureBtn_png" source.disabled="sureBtn_png"/>
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="closeBtn" label="" x="562.83" y="398.51">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="x_png" source.down="x_png" source.disabled="x_png"/>
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0"/>
</e:Skin>
</e:skinName>
</e:Button>
<e:Label id="msgTxt" text="{data.message}" y="469.51" textColor="0xeeeeee" anchorOffsetX="0" width="380.66" anchorOffsetY="0" height="113.34" size="34" textAlign="center" horizontalCenter="0"/>
<e:Button id="creditsOutBtn" label="" x="209.33" y="610">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="sureBtn_png" source.down="sureBtn_png" source.disabled="sureBtn_png"/>
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0"/>
</e:Skin>
</e:skinName>
</e:Button>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="PlaySkin" width="750" height="1206" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing" >
<e:Image id="gamebg" x="0" y="0" source="playSceneBg_jpg"/>
<e:Button id="ruleBtn" label="" skinName="ui.IconButtonSkin" icon="ruleBtn_png" name="ruleBtn" horizontalCenter="-340" verticalCenter="-522.5"/>
<e:Button id="addBtn" label="" icon="+_png" name="addBtn" skinName="ui.IconButtonSkin" horizontalCenter="129.5" verticalCenter="388"/>
<e:Button id="reduceBtn" label="" icon="-__png" name="reduceBtn" skinName="ui.IconButtonSkin" anchorOffsetX="0" anchorOffsetY="0" horizontalCenter="-61.5" verticalCenter="388"/>
<e:Component id="WheelBg" skinName="WheelBg" width="603" height="603" horizontalCenter="0" verticalCenter="-23.5"/>
<e:Image id="outShell" source="outShell_png" verticalCenter="-20.5" horizontalCenter="3.5"/>
<e:Button id="startBtn" label="" icon="startBtnBg_png" horizontalCenter="0.5" verticalCenter="-40" skinName="ui.StartButtonSkin"/>
<e:Label id="unitTxt" text="投入积分" x="201.61" y="960" anchorOffsetX="0" width="63.39" anchorOffsetY="0" height="63.97" textAlign="center" textColor="0xffc303" fontFamily="微软雅黑"/>
<e:Label id="costTxt" text="40" size="40" anchorOffsetX="0" width="132" x="343" y="974.24" textAlign="center"/>
<e:Image id="myCreditsBg" source="myCreditsBg_png" y="884" horizontalCenter="0"/>
<e:Image x="233.31" y="893" anchorOffsetX="0" width="36" anchorOffsetY="0" height="36" source="coinIcon_png"/>
<e:Label id="userCreditsUnitName" text="总积分积分" x="276.8" y="898.34" anchorOffsetX="0" width="156.03" size="22" textColor="0xf7de4c" fontFamily="微软雅黑" height="25.33" anchorOffsetY="0"/>
<e:Label id="userCreditsNum" text="2000" x="384.33" y="895" anchorOffsetX="0" width="129.87" size="30" textAlign="center" textColor="0xf7de4c" height="24"/>
<e:Image id="circleLight1" source="circleLight1_png" y="265" height="630" width="630" horizontalCenter="0"/>
<e:Image id="circleLight2" source="circleLight2_png" width="630" height="630" horizontalCenter="0" verticalCenter="-23"/>
<e:Image id="sideLightD" source="sideLightD_png" x="46" y="396"/>
<e:Image id="sideLightL" source="sideLightL_png" x="-10" y="361.67"/>
<e:Image id="finger" source="finger_png" horizontalCenter="87.5" verticalCenter="44"/>
<e:Panel id="resulePanel" width="374" height="159" skinName="component.ResultPanel" anchorOffsetX="187" anchorOffsetY="79.5" scaleX="0" scaleY="0" horizontalCenter="-1" verticalCenter="-23.5"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="RuleSkin" width="750" height="1624" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Rect id="dark" width="750" height="1624" x="0" y="0" fillAlpha="0.5"/>
<e:Image id="ruleBg" source="ruleBg_png" horizontalCenter="0.5" verticalCenter="-231"/>
<e:Button id="closeBtn" label="" horizontalCenter="296.5" verticalCenter="-561">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="X_png" source.down="X_png" source.disabled="X_png"/>
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0"/>
</e:Skin>
</e:skinName>
</e:Button>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="component.ResultPanel" width="378" height="164" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Image id="bg" source="earnPanel_png" x="0" y="0"/>
<e:Label id="credits" text="0" x="41.5" y="65" size="64" anchorOffsetX="0" width="292" textAlign="center"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="WheelBg" width="603" height="603" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Image id="wheelBg" source="wheelBg2_png" anchorOffsetX="301.5" anchorOffsetY="301.5" left="0" top="0"/>
<e:Image source="gift_png" x="176.5" y="76.5" rotation="-22.5"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="WheelGift" width="92" height="300" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Image id="gift" source="gift_png" y="61" horizontalCenter="0"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="ui.IconButtonSkin" xmlns:e="http://ns.egret.com/eui" xmlns:ns1="*" states="up,down,disabled" >
<e:Image id="iconDisplay" source="" horizontalCenter="0" verticalCenter="0" scaleX.down="0.95" scaleY.down="0.95"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="ui.ProgressBarSkin" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Image id="thumb" source="loading_progress_thumb" x="3" y="3"/>
<e:Image id="track" source="loading_progress_track" scale9Grid="16,13,2,2" width="404"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="ui.StartButtonSkin" xmlns:e="http://ns.egret.com/eui" xmlns:ns1="*" states="up,down,disabled,wating" >
<e:Image id="iconDisplay" source="" horizontalCenter="0" verticalCenter="0" scaleX.down="0.95" scaleY.down="0.95"/>
<e:Image source="startBtnBg_png" includeIn="wating" x="0" y="0"/>
<e:Image source="wating_png" includeIn="wating" horizontalCenter="0" verticalCenter="23.5"/>
<e:Image source="startBtnBg_png" includeIn="disabled" x="0" y="0"/>
<e:Image source="go_png" includeIn="disabled" x="62" y="143"/>
<e:Image source="startBtnBg_png" includeIn="down" x="0" y="0" scaleX="0.95" scaleY="0.95"/>
<e:Image source="go_png" includeIn="down" horizontalCenter="0.5" verticalCenter="25.5" scaleX="0.95" scaleY="0.95"/>
<e:Image source="startBtnBg_png" includeIn="up" horizontalCenter="0" verticalCenter="0"/>
<e:Image source="go_png" includeIn="up" horizontalCenter="0.5" verticalCenter="25.5"/>
</e:Skin>
\ No newline at end of file
export default class LoadingUI extends egret.Sprite implements RES.PromiseTaskReporter {
public constructor() {
super();
this.createView();
}
private textField: egret.TextField;
private createView(): void {
this.textField = new egret.TextField();
this.addChild(this.textField);
this.textField.y = 300;
this.textField.width = 480;
this.textField.height = 100;
this.textField.textAlign = "center";
}
public onProgress(current: number, total: number): void {
this.textField.text = `Loading...${current}/${total}`;
}
}
import { DataManager } from "../libs/tw/manager/DataManager";
import { NetManager } from "../libs/tw/manager/NetManager";
import Msg from "./alert/Msg";
import AssetAdapter from "./AssetAdapter";
import PanelCtrl from "./ctrls/panelCtrl";
import SceneCtrl from "./ctrls/sceneCtrl";
import Loading from "./loading/Loading";
import PlayScene from "./playScene/PlayScene";
import RulePanel from "./rulePanel/RulePanel";
import ThemeAdapter from "./ThemeAdapter";
import { ModuleTypes } from "./types/sceneTypes";
import { getResPath } from "./utils";
import layers from "./views/layers";
class Main extends eui.UILayer {
/**
* 创建场景界面
* Create scene interface
*/
protected createGameScene(): void {
alert(1);
let img: egret.Bitmap = new egret.Bitmap();
img = this.createBitmapByName("bg_jpg");
img.width = this.stage.stageWidth;
img.height = this.stage.stageHeight;
this.addChild(img);
this.CreateWorld();
this.CreatePlane();
this.addEventListener(egret.Event.ENTER_FRAME, this.update, this);
this.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onButtonClick, this);
}
//使用P2物理引擎创建物理应用的过程大致分为5个步骤:
// 1创建world世界
// 2创建shape形状
// 3创建body刚体
// 4实时调用step()函数,更新物理模拟计算
// 5基于形状、刚体,使用Egret渲染,显示物理模拟效果
//创建Word世界
private world: p2.World;
private CreateWorld() {
this.world = new p2.World();
//设置world为睡眠状态
this.world.sleepMode = p2.World.BODY_SLEEPING;
// gravity=[x,y] x为水平方向重力,正数表示方向向右。y为垂直方向重力,正数表示方向向下。
this.world.gravity = [0, 10];
// this.world.gravity = [0, 10];
}
//生成地板Plane
private planeBody: p2.Body;
private CreatePlane() {
let planeShape: p2.Plane = new p2.Plane();
this.planeBody = new p2.Body({
type: p2.Body.STATIC, //刚体类型
position: [0, this.stage.stageHeight], //刚体的位置
});
this.planeBody.angle = Math.PI;//Plane相当于地面,默认面向Y轴方向。将地面翻转180度
this.planeBody.displays = [];
this.planeBody.addShape(planeShape);
this.world.addBody(this.planeBody);
}
private shpeBody: p2.Body;
//贴图显示对象
private display: egret.DisplayObject;
private onButtonClick(e: egret.TouchEvent) {
if (Math.random() > 0.5) {
//添加方形刚体
var boxShape = new p2.Box({ width: 140, height: 80 });
this.shpeBody = new p2.Body({
mass: 1,
position: [e.stageX, e.stageY],
angularVelocity: 1//下落时旋转的速度
});
this.shpeBody.addShape(boxShape);
this.world.addBody(this.shpeBody);
this.display = this.createBitmapByName("rect_png");
this.display.width = boxShape.width;
this.display.height = boxShape.height;
console.log(e.stageX, e.stageY);
}
else {
//添加圆形刚体
var circleShape = new p2.Circle({ radius: 60 });
this.shpeBody = new p2.Body({ mass: 1, position: [e.stageX, e.stageY] });
this.shpeBody.addShape(circleShape);
this.world.addBody(this.shpeBody);
this.display = this.createBitmapByName("circle_png");
this.display.width = circleShape.radius * 2
this.display.height = circleShape.radius * 2
}
//Egret中加载进来的图像,其原点默认为左上角,而P2中刚体的原点处于其中心位置,如下图(盗了一张图)
this.display.anchorOffsetX = this.display.width / 2
this.display.anchorOffsetY = this.display.height / 2;
this.display.x = -100;
this.display.y = -100;
this.display.rotation = 270
this.shpeBody.displays = [this.display];
this.addChild(this.display);
}
//帧事件,步函数
private update() {
this.world.step(1);
var l = this.world.bodies.length;
for (var i: number = 0; i < l; i++) {
var boxBody: p2.Body = this.world.bodies[i];
var box: egret.DisplayObject = boxBody.displays[0];
if (box) {
box.x = boxBody.position[0];
box.y = boxBody.position[1];
//这里刷新图片旋转
box.rotation = boxBody.angle * 180 / Math.PI;
if (boxBody.sleepState == p2.Body.SLEEPING) {
box.alpha = 0.5;
}
else {
box.alpha = 1;
}
}
}
}
/**
* 根据name关键字创建一个Bitmap对象。name属性请参考resources/resource.json配置文件的内容。
*/
private createBitmapByName(name: string): egret.Bitmap {
var result: egret.Bitmap = new egret.Bitmap();
var texture: egret.Texture = RES.getRes(name);
result.texture = texture;
return result;
}
protected createChildren(): void {
super.createChildren();
// alert(1)
egret.lifecycle.addLifecycleListener((context) => {
// custom lifecycle plugin
......@@ -147,6 +35,22 @@ class Main extends eui.UILayer {
egret.registerImplementation("eui.IAssetAdapter", assetAdapter);
egret.registerImplementation("eui.IThemeAdapter", new ThemeAdapter());
egret.ImageLoader.crossOrigin = "anonymous";
DataManager.ins.gameCfgData = window['CFG'];
DataManager.ins.gameCfgData.gameInfo.gameId = window["gameId"];
NetManager.ins.getCredits(()=>{});
layers.init(this);
Loading.init(layers.topLayer);
PanelCtrl.instance.init(layers.popupLayer);
SceneCtrl.instance.init(layers.sceneLayer);
this.stage.scaleMode = egret.StageScaleMode.FIXED_WIDTH;
PanelCtrl.instance.registerPanelClass(ModuleTypes.MSG_PANEL, Msg);
PanelCtrl.instance.registerPanelClass(ModuleTypes.RULE_PANEL, RulePanel);
SceneCtrl.instance.registerSceneClass(ModuleTypes.PALY_SCENE, PlayScene);
this.runGame().catch(e => {
console.log(e);
......@@ -156,11 +60,7 @@ class Main extends eui.UILayer {
private async runGame() {
await this.loadResource()
this.createGameScene();
const result = await RES.getResAsync("description_json")
await platform.login();
const userInfo = await platform.getUserInfo();
console.log(userInfo);
RES.loadGroup("msg", 10);
}
private async loadResource() {
......@@ -169,7 +69,8 @@ class Main extends eui.UILayer {
// this.stage.addChild(loadingView);
await RES.loadConfig("default.res.json", getResPath() + "resource/");
await this.loadTheme();
await RES.loadGroup("preload", 0);
// await RES.loadGroup("msg", 10);
// this.stage.removeChild(loadingView);
}
catch (e) {
console.error(e);
......@@ -187,6 +88,32 @@ class Main extends eui.UILayer {
})
}
private textfield: egret.TextField;
/**
* 创建场景界面
* Create scene interface
*/
protected createGameScene(): void {
NetManager.ins.getInfo(() => {
// 等待开奖 ↓
if (DataManager.ins.getInfoData.status.code == 4) {
// 已开奖 ↓
} else if (DataManager.ins.getInfoData.status.code == 5) {
// 正常游戏 ↓
} else {
SceneCtrl.instance.change(ModuleTypes.PALY_SCENE)
}
});
// setTimeout(() => {
// // panelCtrl.showAlertPanel('te111st');
// // Loading.instace.show()
// }, 3000);
}
}
window['Main'] = Main;
\ No newline at end of file
......@@ -12,7 +12,7 @@ declare interface Platform {
}
class DebugPlatform implements Platform {
export class DebugPlatform implements Platform {
async getUserInfo() {
return { nickName: "username" }
}
......@@ -22,15 +22,9 @@ class DebugPlatform implements Platform {
}
if (!window.platform) {
window.platform = new DebugPlatform();
}
declare let platform: Platform;
export declare let platform: Platform;
declare interface Window {
export declare interface Window {
platform: Platform
}
......
import Panel from "../views/Panel";
export default class Alert extends Panel {
set message(val) {
}
set btnTxt(val) {
}
start(data) {
const { message, btnTxt } = data;
this.data.message = message;
this.data.btnTxt = btnTxt || '确定';
}
protected get skinKey() { return 'Alert' }
protected get closeBtns(): eui.Button[] {
return [this['closeBtn'], this['confirmBtn']]
}
}
\ No newline at end of file
import Panel from "../views/Panel";
export default class Msg extends Panel {
constructor(){
super()
}
set message(val) {
}
set btnTxt(val) {
}
start(data) {
const { msg } = data;
this.data.message = msg;
this['msgTxt'].text = `${this.data.message }`
switch(data.type){
case 'creditsOut':
if(this['creditsOutBtn']){
this['creditsOutBtn'].visible = true;
this['creditsOutBtn'].enabled = true;
}
if(this['confirmBtn']){
this['confirmBtn'].visible = false;
this['confirmBtn'].enabled = false;
}
break;
case 'err':
if(this['creditsOutBtn']){
this['creditsOutBtn'].visible = false;
this['creditsOutBtn'].enabled = false;
}
if(this['confirmBtn']){
this['confirmBtn'].visible = true;
this['confirmBtn'].enabled = true;
}
break;
default:
if(this['creditsOutBtn']){
this['creditsOutBtn'].visible = false;
this['creditsOutBtn'].enabled = false;
}
if(this['confirmBtn']){
this['confirmBtn'].visible = true;
this['confirmBtn'].enabled = true;
}
break;
}
}
protected get creditsOutBtns(): eui.Button[] {
return [this['creditsOutBtn']]
}
protected get closeBtns(): eui.Button[] {
return [this['closeBtn']]
}
protected get skinKey() { return 'Msg' }
}
\ No newline at end of file
import { getSkinPath } from "../utils";
export default class ComponentBase extends eui.Component {
protected data: any;
constructor() {
super();
this.data = {};
this.skinName = getSkinPath(this.skinKey);
this.addEventListener(egret.Event.COMPLETE, this.onSkinComplete, this);
if (this.skin) {
this.onSkinComplete();
}
}
protected initEvents() { }
protected removeEvents() { }
start(data?) {
}
protected get skinKey() { return null }
protected onSkinComplete() {
this.initEvents();
}
destroy() {
this.removeEvents();
}
}
\ No newline at end of file
import Loading from "../../loading/Loading";
import { NetManager } from "../../../libs/tw/manager/NetManager";
import { DataManager } from "../../../libs/tw/manager/DataManager";
const getStartOrderStatus = (callback: Function, customizedType?: number) => {
NetManager.ins.getStartStatus(
callback,
DataManager.ins.doStartData.ticketId,
() => { return DataManager.ins.getStartStatusData.code != 1; },
5,
customizedType);
}
/**
* 开始游戏
* @param {string} isAgain 是否是再来一次
* @param {number} credits 主动要求花费多少积分玩游戏
* @param {number} customizedType xx类型
*/
export default
(isAgain = false, credits?: number, customizedType?: number) => new Promise((resolve) => {
if (window['requirelogin']) {
window['requirelogin']();
return;
}
const callback = (data) => {
Loading.instace.hide();
resolve(data);
}
Loading.instace.show();
NetManager.ins.doStart((success: boolean) => {
if (success) {
getStartOrderStatus(callback, customizedType);
} else {
callback(success);
}
},
isAgain,
credits,
customizedType);
});
\ No newline at end of file
import { DataManager, NetManager } from "duiba-tw";
import Loading from "../../loading/Loading";
export default
() => new Promise((resolve) => {
const _callback = (data) => {
Loading.instace.hide();
resolve(data);
}
Loading.instace.show();
if (DataManager.ins.getRuleData) {
_callback(true);
} else {
NetManager.ins.getRule(_callback);
}
})
import { NetManager } from "duiba-tw";
import Loading from "../../loading/Loading";
/**
* 实时排行榜
* @param {number} type 0总排行榜 1今日排行榜 2 多游戏总排行榜 3 昨日排行榜
* @param {number} count 返回榜单长度 最大50
*/
export default (callback, type, count) => {
const _callback = (data) => {
Loading.instace.hide();
callback(data);
}
Loading.instace.show();
NetManager.ins.realtimerank(_callback, type, count);
}
\ No newline at end of file
import { ModuleTypes } from "../types/sceneTypes";
import Panel from "../views/Panel";
export default class PanelCtrl {
private _parent: egret.Sprite;
private _mask: egret.Shape;
static _instance: PanelCtrl;
static get instance() {
return PanelCtrl._instance || (PanelCtrl._instance = new PanelCtrl())
}
init(parent: egret.Sprite) {
this._parent = parent;
}
show(type: ModuleTypes, data?) {
const cls = this._panelClassMap[type];
const panel: Panel = new cls(data);
this._current = panel;
panel.start(data);
this.add(panel);
}
private add(panel: Panel) {
this._parent.addChild(panel);
panel.addEventListener('onDestroy', this.onPanelHide, this);
panel.addEventListener('onCreditsOut', this.onCreditsOut, this);
}
private remove(panel: Panel) {
this._parent.removeChild(panel);
}
private onPanelHide(e: egret.Event) {
const panel = e.target as Panel;
panel.removeEventListener('onDestroy', this.onPanelHide, this);
panel.removeEventListener('onCreditsOut', this.onCreditsOut, this);
this.remove(panel);
}
private onCreditsOut(e: egret.Event){
if(!window['CFG'] || !window['CFG'].appInfo) return;
window.location.href = window['CFG'].appInfo.earnCreditsUrl;
}
private _panelClassMap: any;
registerPanelClass(name, definition) {
this._panelClassMap = this._panelClassMap || {};
this._panelClassMap[name] = definition;
}
private _current: Panel;
closeCurrent() {
if (this._current)
this.remove(this._current);
}
}
\ No newline at end of file
import { ModuleTypes } from "../types/sceneTypes";
import Scene from "../views/Scene";
export default class SceneCtrl {
private _parent: egret.Sprite;
private _currentScene: Scene;
static _instance: SceneCtrl;
static get instance() {
return SceneCtrl._instance || (SceneCtrl._instance = new SceneCtrl())
}
init(parent: egret.Sprite) {
this._parent = parent;
}
change(type: ModuleTypes) {
if (this._currentScene) {
this._currentScene.destroy();
this._parent.removeChild(this._currentScene);
}
const cls = this._sceneClassMap[type];
const scene: Scene = new cls();
scene.start();
this.addToStage(scene);
}
private addToStage(scene: Scene) {
this._currentScene = scene;
this._parent.addChild(scene);
}
private _sceneClassMap: any;
registerSceneClass(name, definition) {
this._sceneClassMap = this._sceneClassMap || {};
this._sceneClassMap[name] = definition;
}
}
\ No newline at end of file
import { ModuleTypes } from "../types/sceneTypes";
import PanelCtrl from "./panelCtrl";
export default (message: string, btnTxt?: string) => {
PanelCtrl.instance.show(ModuleTypes.ALERT_PANEL, { message: message, btnTxt: btnTxt })
}
\ No newline at end of file
import ComponentBase from "../components/ComponentBase";
export default class Loading extends ComponentBase {
private static _parent: egret.Sprite;
private static _instance: Loading;
static get instace(): Loading {
return Loading._instance || (Loading._instance = new Loading());
}
constructor() {
super();
this.horizontalCenter = 0;
this.verticalCenter = 0;
}
show() {
Loading._parent.addChild(this);
if (this.skin && !this.hasEventListener(egret.Event.ENTER_FRAME))
this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
}
hide() {
Loading._parent.removeChild(this);
if (this.hasEventListener(egret.Event.ENTER_FRAME))
this.removeEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
}
static init(parent: egret.Sprite) {
Loading._parent = parent;
}
onSkinComplete(): any {
super.onSkinComplete();
if (!this.hasEventListener(egret.Event.ENTER_FRAME))
this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
}
onEnterFrame() {
this.data.speed += 5;
}
protected get skinKey() { return 'Loading' }
}
import { INetData } from 'duiba-tc';
import { NetManager, DataManager, NetName } from 'duiba-tw';
import Scene from "../views/Scene";
import PanelCtrl from '../ctrls/panelCtrl';
import { ModuleTypes } from '../types/sceneTypes';
const { TouchEvent } = egret;
export default class PlayScene extends Scene {
// 游戏参数
private userCredits:number = 0;
private unitNum:number = 10;
private unitName:string;
private currCostCredits:number = 0;
private lightCount:number = 0;
private lightRate = 30;
private isLight:boolean = false;
private wbgloop:any;
private multiplesArr:any[] = [];
private angleArr:any[] = [];
private ranArr:any[] = [];
private coinsArr:any[] = [];
private gravity:number = 4.5;
private multiple:number;
// 导出的元件
public bg:eui.Image;
public ruleBtn:eui.Button;
public addBtn:eui.Button;
public reduceBtn:eui.Button;
public WheelBg:eui.Component;
public outShell:eui.Image;
public startBtn:eui.Button;
public unitTxt:eui.Label;
public costTxt:eui.Label;
public myCreditsBg:eui.Image;
public userCreditsUnitName:eui.Label;
public userCreditsNum:eui.Label;
public circleLight1:eui.Image;
public circleLight2:eui.Image;
public sideLightD:eui.Image;
public sideLightL:eui.Image;
public finger:eui.Image;
public resulePanel:eui.Panel;
public rulePanel:eui.Panel;
initEvents() {
this.startBtn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick_startBtn,this);
this.reduceBtn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick_reduceBtn,this);
this.addBtn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick_addBtn,this);
this.ruleBtn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick_ruleBtn,this);
}
removeEvents() {
this.startBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick_startBtn,this);
this.reduceBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick_reduceBtn,this);
this.addBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick_addBtn,this);
this.ruleBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick_ruleBtn,this);
}
start() {
this.once(egret.Event.ADDED_TO_STAGE,this.onLoad,this);
this.circleLight1.$touchEnabled = false;
this.circleLight2.$touchEnabled = false;
this.finger.$touchEnabled = false;
this.sideLightL.visible = false;
this.userCredits = DataManager.ins.getInfoData ? DataManager.ins.getInfoData.credits : 0;
this.unitName = DataManager.ins.getCreditsData ? `${DataManager.ins.getCreditsData.unitName}` : `积分`;
if(this.userCredits<10){
this.currCostCredits = 0;
}else if(this.userCredits <= 200){
this.currCostCredits = 10;
}else if(this.userCredits <= 500){
this.currCostCredits = 20;
}else if(this.userCredits <= 1000){
this.currCostCredits = 30;
}else if(this.userCredits <= 5000){
this.currCostCredits = 50;
}else if(this.userCredits <= 10000){
this.currCostCredits = 100;
}else if(this.userCredits > 10000){
this.currCostCredits = 200;
}
this.costTxt.text = `${this.currCostCredits}`;
this.unitTxt.text = `投入${this.unitName}`;
this.userCreditsUnitName.text = `总${this.unitName}`;
this.userCreditsNum.text = `${this.userCredits}`;
let fingerTw = egret.Tween.get( this.finger, {loop: true} );
fingerTw.to({scaleX:0.9, scaleY:0.9}, 500).to({scaleX:1, scaleY:1}, 500)
this.WheelBg['realRotation'] = 0;
console.log(this.WheelBg)
// 按从小到大排序
this.multiplesArr = [0, 0.2, 0.4, 0.5, 0.8, 1.0, 1.1, 1.2, 1.4, 1.5, 2];
let unitAngle = 360/16;
this.angleArr = [13*unitAngle, 11*unitAngle, 0, 5*unitAngle, 8*unitAngle, 14*unitAngle, 12*unitAngle, 6*unitAngle, 10*unitAngle, 3*unitAngle, 2*unitAngle];
this.ranArr = [1/11,1/11,1/11,1/11,1/11,1/11,1/11,1/11,1/11,1/11,1/11];
}
private timeOnEnterFrame:number = 0;
private onLoad(event:egret.Event) {
this.addEventListener(egret.Event.ENTER_FRAME,this.onEnterFrame,this);
}
private onEnterFrame(e:egret.Event){
let scope = this;
scope.lightCount ++;
if(scope.lightCount%scope.lightRate == 0){
scope.isLight = !scope.isLight;
}
scope.circleLight2.visible = scope.isLight;
if(scope.coinsArr.length > 0){
for(let c = scope.coinsArr.length-1; c>=0;c--){
scope.coinsArr[c].x += scope.coinsArr[c].dirX * scope.coinsArr[c].vx;
scope.coinsArr[c].y -= scope.coinsArr[c].vy;
scope.coinsArr[c].vy -= scope.gravity;
}
}
}
// 开始游戏
private onClick_startBtn(e:egret.TouchEvent){
if(window['requirelogin']) {
window['requirelogin']();
return;
}
if(this.userCredits < 10){
let data = {msg:`${this.unitName}不足最小投值10${this.unitName}快去赚取${this.unitName}吧`, type:'creditsOut'}
PanelCtrl.instance.show(ModuleTypes.MSG_PANEL, data)
return;
}
let scope = this;
let wbg = egret.Tween.get( this.WheelBg, {onChange: scope.onWbgRotationChange.bind(scope)});
scope.removeChild(scope.goAni)
let func:Function;
wbg.to({realRotation:(scope.WheelBg['realRotation'] + 3600)}, 2000, egret.Ease.quartIn).call( func = function(){
let _rotation = scope.WheelBg['realRotation'] + 360;
scope.wbgloop = egret.Tween.get( scope.WheelBg, {onChange: scope.onWbgRotationChange.bind(scope), loop: true});
scope.wbgloop.to({realRotation: _rotation}, 300).call(()=>{
_rotation = scope.WheelBg['realRotation'] + 360;
});
});
this.finger.visible = false;
this.lightRate = 5;
this.sideLightL.visible = true;
this.buttonEnable(false);
this.startBtn.currentState = 'wating';
this.doStart(this.doStartResult.bind(this), false, this.currCostCredits, 1);
}
// 开始游戏接口
public doStart(callback: Function, isAgain = false, credits?: number, customizedType?: number): void {
if(window['requirelogin']) {
window['requirelogin']();
return;
}
NetManager.ins.doStart((success: boolean) => {
if(success) {
this.getStartStatus(callback, customizedType);
} else {
callback(success);
}
},
isAgain,
credits,
customizedType);
}
// 查询开始状态
private getStartStatus(callback: Function, customizedType?: number): void {
const param: any = {
ticketId: DataManager.ins.doStartData.ticketId
};
if (customizedType) {
param.customizedType = customizedType
}
const net: INetData = {
name: 'getStartStatus',
uri: '/ngapi/getStartStatus',
type: 'post',
dataType: 'json',
param: param,
callback: callback,
pollingCount: 5,
pollingCheck: () => { return DataManager.ins.getData('getStartStatus').code != 1; }
};
NetManager.ins.send(net)
}
// 开始的回调
private doStartResult(success:boolean){
let scope = this;
if(!success) {
this.defaultErr()
return;
}
let upperCreditsLimit = DataManager.ins.getData('getStartStatus').upperCreditsLimit ? DataManager.ins.getData('getStartStatus').upperCreditsLimit : scope.currCostCredits;
// 取得的返回最大倍数
let maxMultiple = upperCreditsLimit/scope.currCostCredits;
console.log(`最大倍数:${maxMultiple}`)
// 改变数组
let newMultiplesArr:any[] = [];
for(let m = 0; m<scope.multiplesArr.length; m++){
if(scope.multiplesArr[m] < maxMultiple){
newMultiplesArr.push(scope.multiplesArr[m]);
}
}
// 更新用户积分文案
scope.userCreditsNum.text = `${DataManager.ins.getInfoData ? DataManager.ins.getInfoData.credits : scope.userCredits}`
// 拿到倍数
let newAngleArr:any[] = [];
let newRanArr:any[] = [];
let arr:any[] = [];
for(let i = 0; i < newMultiplesArr.length; i++){
newAngleArr.push(scope.angleArr[i]);
newRanArr.push(scope.ranArr[i]);
let num = Math.round(120 * newRanArr[i]);
let a = (new Array(num))["fill"](newAngleArr[i]);
arr = arr.concat(a);
}
let randomT = (e, n?) => {
return e && "number" == typeof e.length && e.length ? e[Math.floor(Math.random() * e.length)] : ("number" != typeof n && (n = e || 1, e = 0), e + Math.random() * (n - e))
}
let targetAngle = randomT(arr);
let i = scope.angleArr.indexOf(targetAngle);
let multiple = scope.multiplesArr[i];
this.multiple = multiple;
console.log(`随机倍数:${multiple}`)
let timeout = setTimeout(() => {
clearTimeout(timeout)
egret.Tween.removeTweens( scope.WheelBg );
let tw = egret.Tween.get( scope.WheelBg, {onChange:scope.onWbgRotationChange.bind(scope)} );
let _rotation = Math.random() > 0.5 ? scope.WheelBg['realRotation'] + ( 360 - scope.WheelBg['realRotation'] % 360 ) + targetAngle + 1440 + Math.random() * 8 : scope.WheelBg['realRotation'] + ( 360 - scope.WheelBg['realRotation'] % 360 ) + targetAngle + 1440 - Math.random() * 8;
tw.to({realRotation:_rotation}, 8000 ,egret.Ease.quartOut).call(()=>{
scope.startBtn.currentState = 'up';
scope.buttonEnable(false)
scope.sideLightL.visible = false;
scope.lightRate = 30;
scope.coinsFall(true)
});
}, 1000);
// 延时提交分数
let timeout2 = setTimeout(()=>{
this.gameSubmitData(this.gameSubmitResult.bind(this), this.currCostCredits * multiple, false, 1);
},500)
}
private gameSubmitResult(){
NetManager.ins.getInfo(()=>{})
console.log('提交成功')
}
/**
* 提交游戏成绩
* @param callback
* @param score 得分
* @param allDynamics 防作弊数据
* @param checkScore 是否校验得分
* @param customizedType 定制类型 1推币机
*/
protected gameSubmitData(callback: Function, score: number, checkScore?: boolean, customizedType?: number): void {
NetManager.ins.gameSubmit(
(success: boolean) => {
if(success) {
this.getSubmitResult(callback, DataManager.ins.gameSubmitData.orderId);
} else {
callback(success);
}
},
DataManager.ins.doStartData.ticketId,
score,
'[]',
DataManager.ins.doStartData.submitToken,
'',
checkScore,
customizedType);
}
/**
* 查询提交结果
* @param callback
* @param orderId
*/
private getSubmitResult(callback: Function, orderId: number): void {
NetManager.ins.getSubmitResult(callback, orderId, () => {
return DataManager.ins.gameGetSubmitResultData.flag;
});
}
// 默认出错——转到0后弹错误窗
private defaultErr(){
let timeout = setTimeout(() => {
clearTimeout(timeout)
egret.Tween.removeTweens( this.WheelBg );
let tw = egret.Tween.get( this.WheelBg, {onChange:this.onWbgRotationChange.bind(this)} );
this.multiple = 0;
let _rotation = this.WheelBg['realRotation'] + ( 360 - this.WheelBg['realRotation'] % 360 ) + 360*13/16 + 1440;
tw.to({realRotation:_rotation}, 8000 ,egret.Ease.quartOut).call(()=>{
this.startBtn.currentState = 'up';
this.buttonEnable(true);
this.sideLightL.visible = false;
this.lightRate = 30;
this.coinsFall(false)
});
}, 2000);
}
private onWbgRotationChange(){
this.WheelBg.rotation = this.WheelBg['realRotation'];
}
// 减号
private onClick_reduceBtn(e:egret.TouchEvent){
if(window['requirelogin']) {
window['requirelogin']();
return;
}
if((this.currCostCredits - this.unitNum) > 0 && (this.userCredits - this.unitNum) > 0 ){
this.currCostCredits -= this.unitNum;
}
this.costTxt.text = `${this.currCostCredits}`;
}
// 加号
private onClick_addBtn(e:egret.TouchEvent){
if(window['requirelogin']) {
window['requirelogin']();
return;
}
if((this.currCostCredits + this.unitNum) <= this.userCredits && this.currCostCredits < 500){
this.currCostCredits += this.unitNum;
}
this.costTxt.text = `${this.currCostCredits}`;
}
// 规则按钮
private onClick_ruleBtn(e:egret.TouchEvent){
PanelCtrl.instance.show(ModuleTypes.RULE_PANEL);
}
// 加载动画资源
private goAni:any;
protected childrenCreated():void{
super.childrenCreated();
this.ayncLoad2Mc("goBtn_json");
this.ayncLoad2Mc("coin_json");
}
private ayncLoad2Mc( resname : string) : void{
let scope = this;
RES.getResAsync(resname,
(data: any,key: string): void => {
if(key == "coin_json") {
scope.ayncLoad2Mc("coin_png");
}else if(key == "coin_png") {
for(let i=0;i<100;i++){
let data2mc = RES.getRes("coin_json");
let texture2mc = RES.getRes("coin_png");
let mcFactory : egret.MovieClipDataFactory = new egret.MovieClipDataFactory(data2mc,texture2mc);
let mc:egret.MovieClip = new egret.MovieClip(mcFactory.generateMovieClipData("coin"));
scope.coinsArr.push(mc);
}
}else if(key == "goBtn_json") {
scope.ayncLoad2Mc("goBtn_png");
}else if(key == "goBtn_png") {
let data2mc = RES.getRes("goBtn_json");
let texture2mc = RES.getRes("goBtn_png");
let mcFactory : egret.MovieClipDataFactory = new egret.MovieClipDataFactory(data2mc,texture2mc);
let mc:egret.MovieClip = new egret.MovieClip(mcFactory.generateMovieClipData("go"));
mc.gotoAndPlay('light', -1);
scope.goAni = mc;
scope.addChild(scope.goAni)
scope.addChild(scope.finger)
mc.x = 279;
mc.y = 494;
}
},
this);
}
// 金币掉落效果
private coinsFall(isSuccess:boolean):void{
let scope = this;
let count = 0;
let coinsFall = setInterval(()=>{
if(count<100){
scope.addChild(scope.coinsArr[count]);
scope.coinsArr[count].gotoAndPlay('rotate', -1);
if(Math.random()>0.5){
scope.coinsArr[count].dirX = 1;
}else{
scope.coinsArr[count].dirX = -1;
}
scope.coinsArr[count].vy = Math.random() * 60;
scope.coinsArr[count].vx = Math.random() * 30;
scope.coinsArr[count].x = this.stage.stageWidth/2 - scope.coinsArr[count].width/2;
scope.coinsArr[count].y = 500;
count++;
this.addChild(this.resulePanel)
}else{
if(!isSuccess){
// 失败
let msg = DataManager.ins.doStartData ? DataManager.ins.doStartData.message : `网络出了点小问题请退出后重试`;
let data = {msg:msg, type:'err'}
PanelCtrl.instance.show(ModuleTypes.MSG_PANEL, data)
}
clearInterval(coinsFall)
}
},10)
scope.showResultPanel()
}
private currEarnCredits:number = 0;
private showResultPanel(){
let scope = this;
scope.currEarnCredits = scope.currCostCredits * scope.multiple;
let resultPanelTw = egret.Tween.get( scope.resulePanel );
resultPanelTw.to({scaleX:1, scaleY:1}, 300).wait(2000).call(()=>{
scope.resulePanel.scaleX = 0;
scope.resulePanel.scaleY = 0;
scope.buttonEnable(true);
scope.addChild(scope.goAni);
})
this.resulePanel['credits'].text = `0`;
let credits:any = {num:0};
credits.num = Number(this.resulePanel['credits'].text);
let creditTw = egret.Tween.get( credits , { onChange:onCreditsChange});
creditTw.to({num: this.currEarnCredits},1000)
function onCreditsChange(){
let c = Math.floor(credits.num);
scope.resulePanel['credits'].text = `${c}`
}
}
// 按钮状态
private buttonEnable(enabled:boolean){
this.startBtn.enabled = enabled;
this.addBtn.enabled = enabled;
this.reduceBtn.enabled = enabled;
this.ruleBtn.enabled = enabled;
}
protected get skinKey() { return 'Play' }
}
\ No newline at end of file
import { NetManager } from 'duiba-tw';
import { DataManager } from 'duiba-tw';
import Panel from "../views/Panel";
export default class RulePanel extends Panel {
constructor(){
super()
NetManager.ins.getRule(()=>{
var tx:egret.TextField = new egret.TextField;
tx.width = this.stage.stageWidth - 220;
tx.textFlow = (new egret.HtmlTextParser).parser(
DataManager.ins.getRuleData ? DataManager.ins.getRuleData.ruleText :
(DataManager.ins.ajaxElementData ? DataManager.ins.ajaxElementData.rule :
(window['ruleCFG'] ? window['ruleCFG'] : "规则")
)
);
tx.x = 110;
tx.y = 330;
tx.textColor = 0x333333;
this.addChild( tx );
})
}
protected get skinKey() { return 'Rule' }
}
\ No newline at end of file
export enum ModuleTypes {
START_SCENE,
PALY_SCENE,
ALERT_PANEL,
RULE_PANEL,
MSG_PANEL
}
\ No newline at end of file
import ComponentBase from "../components/ComponentBase";
export default class Panel extends ComponentBase {
constructor() {
super();
}
initEvents() {
if(this.closeBtns && this.closeBtns.length > 0){
this.closeBtns.forEach(
btn => { if(btn) btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap, this) }
)
}
if(this.confirmBtns && this.confirmBtns.length > 0){
this.confirmBtns.forEach(
btn => { if(btn) btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap, this) }
)
}
if(this.creditsOutBtns && this.creditsOutBtns.length > 0){
this.creditsOutBtns.forEach(
btn => { if(btn) btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.creditsOut, this) }
)
}
}
removeEvents() {
if(this.closeBtns && this.closeBtns.length > 0){
this.closeBtns.forEach(
btn => { if(btn) btn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap, this) }
)
}
if(this.confirmBtns && this.confirmBtns.length > 0){
this.confirmBtns.forEach(
btn => { if(btn) btn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap, this) }
)
}
if(this.creditsOutBtns && this.creditsOutBtns.length > 0){
this.creditsOutBtns.forEach(
btn => { if(btn) btn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.creditsOut, this) }
)
}
}
protected get closeBtns(): eui.Button[] { return [this['closeBtn']] }
protected get confirmBtns(): eui.Button[] { return [this['confirmBtn']]}
protected get creditsOutBtns(): eui.Button[] { return [this['creditsOutBtn']] }
onTouchTap(): any {
this.hidePanel();
}
hidePanel() {
this.destroy();
this.dispatchEvent(new egret.Event('onDestroy'));
}
creditsOut(){
this.destroy();
this.dispatchEvent(new egret.Event('onCreditsOut'));
}
}
\ No newline at end of file
import ComponentBase from "../components/ComponentBase";
export default class Scene extends ComponentBase {
}
\ No newline at end of file
class Layers extends eui.UILayer {
private _topLayer: egret.Sprite;
private _popupLayer: egret.Sprite;
private _sceneLayer: egret.Sprite;
init(root: eui.UILayer) {
root.addChild(this);
this._topLayer = new egret.Sprite();
this._popupLayer = new egret.Sprite();
this._sceneLayer = new egret.Sprite();
this.addChild(this._sceneLayer);
this.addChild(this._popupLayer);
this.addChild(this._topLayer);
}
get topLayer() { return this._topLayer }
get popupLayer() { return this._popupLayer }
get sceneLayer() { return this._sceneLayer }
}
const instance = new Layers();
export default instance
\ No newline at end of file
......@@ -12,15 +12,10 @@
"copy": "node build.js copy",
"cli": "node cli.js"
},
"repository": {
"type": "git",
"url": "http://gitlab2.dui88.com/frontend/duiba-games.git"
},
"author": "",
"license": "ISC",
"keywords": [],
"dependencies": {
},
"dependencies": {},
"devDependencies": {
"ali-oss": "^4.11.4",
"chalk": "^2.3.0",
......
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