浏览代码

消息接口

zouyong 5 年之前
父节点
当前提交
be1791d4d2

+ 59 - 7
assets/script/game/data/AdData.ts

@@ -2,25 +2,77 @@
  * @description 广告数据
  * @description 广告数据
  * @author 邹勇
  * @author 邹勇
  */
  */
- export class AdData{
+export class AdData {
 
 
-    
+    public placementId = '';
+    public adunit_format = '';
+    public network_type = '';
+    public network_placement_id = '';
+    public network_firm_id = '';
+    public adsource_id = '';
+    public adsource_index = '';
+    public adsource_price = '';
+    public adsource_isheaderbidding = '';
+    public publisher_revenue = '';
+    public precision = '';
+    public ecpm_level = '';
 
 
+    /** 广告类型(1:激励视频、2:插屏、3:信息流) */
+    public adType: number = 1;
+
+    /** 视频类型 */
+    public ad_subType: AdFun;
+
+    /** 看视频后回复的数据 每个功能回复的内容不一样,具体看接口文档 */
+    public data: any;
+
+
+    public init() {
 
 
-    public init(){
-        
     }
     }
-    
+
+
+    public async updateVideo(type: AdFun) {
+        this.ad_subType = type;
+        let data = {
+            "imei": g.appData.machineInfo.imei,
+            "idfa": g.appData.machineInfo.idfa,
+            "oaid": g.appData.machineInfo.oaid,
+            "uin": g.loginData.uin,
+            "version": g.appData.appVersion,
+            "tf_channel": g.appData.tfChannel,
+            "destoon_ad_place": this.placementId,
+            "adunit_format": this.adunit_format,
+            "network_type": this.network_type,
+            "network_placement_id": this.network_placement_id,
+            "network_firm_id": this.network_firm_id,
+            "adsource_id": this.adsource_id,
+            "adsource_index": this.adsource_index,
+            "adsource_price": this.adsource_price,
+            "adsource_isheaderbidding": this.adsource_isheaderbidding,
+            "publisher_revenue": this.publisher_revenue,
+            "precision": this.precision,
+            "ecpm_level": this.ecpm_level,
+            "ad_sbuType": this.ad_subType,
+            "ad_type": 1,
+        }
+        let response = await mk.http.sendData('updateVideo', data);
+        if (response.errcode != 0) {
+            return;
+        }
+        this.data = response.data;
+    }
+
 }
 }
 
 
 /**
 /**
  * 看视频类型
  * 看视频类型
  */
  */
-export enum AdFun{
+export enum AdFun {
     bubble = 1,         //气泡视频
     bubble = 1,         //气泡视频
     checkpoint = 2,     //关卡视频
     checkpoint = 2,     //关卡视频
     settlement = 3,     //关卡结算视频
     settlement = 3,     //关卡结算视频
     turntable = 4,      //转盘视频
     turntable = 4,      //转盘视频
     sign = 5,           //签到视频
     sign = 5,           //签到视频
-    bigCash =6,         //福袋视频
+    bigCash = 6,         //福袋视频
 }
 }

+ 20 - 10
assets/script/game/data/AppData.ts

@@ -2,25 +2,35 @@
  * @description 应用数据
  * @description 应用数据
  * @author 邹勇
  * @author 邹勇
  */
  */
-export class AppData{
+export class AppData {
 
 
     /** 错误日志游戏名标志,尽量短 */
     /** 错误日志游戏名标志,尽量短 */
-    public appNameBugly:string = '3xiao';
+    public appNameBugly: string = '3xiao';
 
 
-    public appVersion:string = '';
+    public appVersion: string = '';
 
 
     /** 投放渠道号 */
     /** 投放渠道号 */
-    public tfChannel:string = '';
+    public tfChannel: string = '';
 
 
     /** api版本 */
     /** api版本 */
-    public version:string = '1.0.0';
+    public version: string = '1.0.0';
 
 
-    public appId:string = 'wx17e502b5f230fd9a';
+    public appId: string = 'wx17e502b5f230fd9a';
 
 
-    public mac:string = 'c9:65:e2:1c:b0:23,f6:60:e4:1a:b7:27';
-    
+    public mac: string = 'c9:65:e2:1c:b0:23,f6:60:e4:1a:b7:27';
+
+    /** 设备信息 */
+    public machineInfo = {
+        "android_id": "",
+        "idfa": "",
+        "imei": "",
+        "mac": "",
+        "oaid": "",
+        "umid": ""
+    };
+
+
+    public init() {
 
 
-    public init(){
-        
     }
     }
 }
 }

+ 67 - 7
assets/script/game/data/GameData.ts

@@ -7,8 +7,16 @@ export class GameData {
 
 
     public dataFinish: boolean = false;
     public dataFinish: boolean = false;
 
 
-    
-    public configs:any = {};
+    public savePropFinish: boolean = false;
+
+    public savePropsFinish: boolean = false;
+
+    public getPropsFnish: boolean = false;
+
+
+    public configs: any = {};
+
+    public props: Map<number, object>;
 
 
 
 
     /**
     /**
@@ -29,22 +37,74 @@ export class GameData {
             return;
             return;
         }
         }
 
 
-        
+        this.initProps(response.data.gameUserData);
+
         this.dataFinish = true;
         this.dataFinish = true;
     }
     }
 
 
     /**
     /**
-     * 保存数据
+     * 保存单个数据
+     */
+    public async saveProp(key: GameProp, value: number | string) {
+        let data = {
+            key: key + '',
+            value: value + ''
+        };
+        await mk.http.sendData('savePlayerProp', data);
+        this.savePropFinish = true;
+    }
+
+    /**
+     * 保存多个数据
+     */
+    public async saveProps(arr: { key: GameProp, value: number | string }[]) {
+        let needProp = {};
+        for (let i = 0; i < arr.length; i++) {
+            needProp[arr[i].key + ''] = arr[i].value + "";
+        }
+        let data = {
+            needProp: needProp
+        };
+        await mk.http.sendData('saveAllPlayerProp', data);
+        this.savePropsFinish = true;
+    }
+
+    /**
+     * 向服务器请求所有属性后更新
      */
      */
-    public async saveProps(){
+    public async getAllProps() {
+        let response = await mk.http.sendData('getAllPlayerProp', {});
+        if (response.errcode != 0) {
+            return;
+        }
+
+        this.initProps(response.data);
 
 
+        this.getPropsFnish = true;
+    }
+
+    private initProps(data) {
+        if (this.props == null) {
+            this.props = new Map<number, object>();
+        }
+        for (let key in data) {
+            this.props.set(parseInt(key), JSON.parse(data[key]));
+        }
+    }
+
+    /** 获取属性 */
+    public getProp(key: GameProp): object {
+        if (this.props == null) {
+            return null;
+        }
+        return this.props.get(key);
     }
     }
 }
 }
 
 
 /**
 /**
- * 游戏数据
+ * 所有模块的非校验数据
  */
  */
-export enum GameProp{
+export enum GameProp {
     /** ------------------ 游戏核心数据 --------------------------- */
     /** ------------------ 游戏核心数据 --------------------------- */
 
 
 
 

+ 8 - 0
assets/script/game/data/module/TurnableData.ts

@@ -19,4 +19,12 @@
         // }
         // }
         this.dataFinish = true;
         this.dataFinish = true;
     }
     }
+    
+    public async draw(){
+        let data = {};
+        let response = await mk.http.sendRequest('turnable', 'POST', JSON.stringify(data));
+        if (response.errcode != 0) {
+            return;
+        }
+    }
 }
 }