future 1 年之前
父節點
當前提交
90e54dacc8
共有 5 個文件被更改,包括 157 次插入98 次删除
  1. 18 18
      assets/scene/game.scene
  2. 9 1
      assets/script/config.ts
  3. 4 0
      assets/script/http.ts
  4. 38 32
      assets/script/run/loading_view/loading_view.ts
  5. 88 47
      assets/script/sdkUtil.ts

+ 18 - 18
assets/scene/game.scene

@@ -178,7 +178,7 @@
     "_priority": 0,
     "_fov": 45,
     "_fovAxis": 0,
-    "_orthoHeight": 960,
+    "_orthoHeight": 959.9999999999999,
     "_near": 0,
     "_far": 1000,
     "_color": {
@@ -347,7 +347,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 1080,
-      "height": 1920
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -651,7 +651,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 1080,
-      "height": 1920
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -1164,7 +1164,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 1080,
-      "height": 1920
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -2013,7 +2013,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 1080,
-      "height": 1920
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -4190,7 +4190,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 1080,
-      "height": 1920
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -4251,7 +4251,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": -540,
-      "y": -960,
+      "y": -959.9999999999999,
       "z": 0
     },
     "_lrot": {
@@ -4290,7 +4290,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 1080,
-      "height": 1920
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -5132,7 +5132,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0,
-      "y": 860,
+      "y": 859.9999999999999,
       "z": 0
     },
     "_lrot": {
@@ -9067,7 +9067,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 1080,
-      "height": 1920
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -9273,7 +9273,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": -540,
-      "y": -960,
+      "y": -959.9999999999999,
       "z": 0
     },
     "_lrot": {
@@ -9312,7 +9312,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 1080,
-      "height": 1920
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -14570,7 +14570,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 1080,
-      "height": 1920
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -23768,7 +23768,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 1080,
-      "height": 1920
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -23861,7 +23861,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 1080,
-      "height": 1920
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -24030,7 +24030,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 1080,
-      "height": 1920
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -24082,7 +24082,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 1080,
-      "height": 1920
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -24203,7 +24203,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 1080,
-      "height": 1920
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",

+ 9 - 1
assets/script/config.ts

@@ -3,7 +3,7 @@ import { scene_item_data, widget_item_data } from '../data/data';
 const { ccclass, property } = _decorator;
 
 export class config {
-    static debug = false;
+    static debug = true;
     static is_zb = false; //是否是主播模式
     static gameName = "神秘的笔记";
     static select_res_and_control_type = {
@@ -351,6 +351,14 @@ export class config {
         UN_LOCK: "",
         ADD_TIME: "",
     }
+    static KS_REWARD ={
+        RE_LIFE: "",
+        ANSWER: "",
+        LOOK_TIPS: "",
+        UN_LOCK_24: "",
+        UN_LOCK: "",
+        ADD_TIME: "",
+    }
     static STATISTICS_ACTION_TYPE = {
         UNKNOWN: 0,              //未知
         GUAN_KA_FU_HUO: 1,       //关卡复活

+ 4 - 0
assets/script/http.ts

@@ -69,6 +69,10 @@ export class http {
         return `/note/user/get_wxopen_id`
     }
 
+    public static get_ksopen_id(): string {
+        return `/note/user/get_ksopen_id`
+    }
+
     public static get_zbopen_id():string {
         return '/user/anchor'
     }

+ 38 - 32
assets/script/run/loading_view/loading_view.ts

@@ -3,6 +3,7 @@ import { getOpenidMessage, getTestUserListMessage, LevelMessage, sysMessage, Use
 import { gameManager } from '../gameManager';
 import { http } from '../../http';
 import { config } from '../../config';
+import { SdkUtil } from '../../sdkUtil';
 const { ccclass, property } = _decorator;
 
 @ccclass('loading_view')
@@ -89,6 +90,18 @@ export class loading_view extends Component {
                     }
                     
                     if(user_data.user_id==null){
+                        let third_login_success = (url,r_data,platform)=>{
+                            http.run_post(url,r_data, (err,data)=> {
+                                let _data:getOpenidMessage = JSON.parse(data)
+                                if(_data.code===config.MSG_CODE.SUCCESS){
+                                    user_data.user_id = _data.content.openid;
+                                    formData.openid = _data.content.openid;
+                                    formData.platform = platform
+                                    // console.log("_data",data)
+                                    login_call_back();
+                                }
+                            })
+                        }
                         if(sys.platform==sys.Platform.BYTEDANCE_MINI_GAME){
                             tt.login({
                                 force: true,
@@ -96,42 +109,35 @@ export class loading_view extends Component {
                                     let code = res.code;
                                     let anonymousCode = res.anonymousCode;
                                     console.log("tt_code",code,anonymousCode)
-                                    http.run_post(http.get_dyopen_id(),{"code":code,"anonymous_code":anonymousCode},(err,data)=>{
-                                        let _data:getOpenidMessage = JSON.parse(data)
-                                        if(_data.code===config.MSG_CODE.SUCCESS){
-                                            user_data.user_id = _data.content.openid;
-                                            formData.openid = _data.content.openid;
-                                            formData.platform = 'douyin'
-                                            // console.log("_data",_data)
-                                            login_call_back();
-                                        }
-                                    })
+                                    third_login_success(http.get_dyopen_id(),{"code": code,"anonymous_code":anonymousCode}, 'douyin')
                                 },
-                                fail(res) {
-                                    console.log(`tt_login 调用失败:`,res);
-                                }
+                                fail(res) { console.log(`tt_login 调用失败:`,res); }
                             });
                         }
                         else if(sys.platform==sys.Platform.WECHAT_GAME){
-                            wx.login({
-                                success(res) {
-                                    let code = res.code;
-                                    console.log("wx_code",code)
-                                    http.run_post(http.get_wxopen_id(),{"code": code}, (err,data)=> {
-                                        let _data:getOpenidMessage = JSON.parse(data)
-                                        if(_data.code===config.MSG_CODE.SUCCESS){
-                                            user_data.user_id = _data.content.openid;
-                                            formData.openid = _data.content.openid;
-                                            formData.platform = 'wx'
-                                            // console.log("_data",data)
-                                            login_call_back();
-                                        }
-                                    })
-                                },
-                                fali(err) {
-                                    console.log('wx_login 调用失败:',err)
-                                }
-                            })
+                            if(SdkUtil.KS_GAME) {
+                                user_data.user_id = "ks_test";
+                                formData.openid = user_data.user_id;
+                                formData.platform = 'ks'
+                                login_call_back();
+                                // ks.login({
+                                //     success(res) {
+                                //         let code = res.code;
+                                //         console.log("ks_code",code)
+                                //         // third_login_success(http.get_ksopen_id(),{"code": code}, 'ks')
+                                //     },
+                                //     fali(err) {  console.log('ks_login 调用失败:',err) }
+                                // })
+                            } else {
+                                wx.login({
+                                    success(res) {
+                                        let code = res.code;
+                                        console.log("wx_code",code)
+                                        third_login_success(http.get_wxopen_id(),{"code": code}, 'wx')
+                                    },
+                                    fali(err) { console.log('wx_login 调用失败:',err) }
+                                })
+                            }
                         }
                         else{
                             if(config.is_zb) {

+ 88 - 47
assets/script/sdkUtil.ts

@@ -18,7 +18,7 @@ export class SdkUtil {
     public static vibrateInterval: number = 100;//两次震动之间的间隔,AppActivity里面的震动间隔也是100
     public static vibratePreTime: number = 0;//上次震动时间
 
-
+    public static KS_GAME:boolean = false; //是否ks游戏
     public static videoAd:any =null;
     public static isLookAd:boolean = false; //是否在看广告
 
@@ -34,6 +34,11 @@ export class SdkUtil {
     //------------------------------  公共  ------------------------------//
 
     public static init() {
+        if(sys.platform==sys.Platform.WECHAT_GAME) {
+            let isKSGame = typeof KSGameGlobal != 'undefined'
+            // console.log('isKSGame=',isKSGame)                            
+            SdkUtil.KS_GAME = isKSGame
+        }
         this.ttGetSystemInfo(()=> {
             this.ttRegisterInfo()
         })
@@ -95,7 +100,11 @@ export class SdkUtil {
             }
         } else if(sys.platform == sys.Platform.WECHAT_GAME) {
             title = title + '好刺激、好好玩'
-            this.wxShare(title, imageUrl)
+            if(SdkUtil.KS_GAME) {
+                this.ksShare(title, imageUrl)
+            } else {
+                this.wxShare(title, imageUrl)
+            }
         }
     }
 
@@ -117,19 +126,36 @@ export class SdkUtil {
                 ad_id = config.TT_REWARD.ADD_TIME
             }
         } else if (sys.platform == sys.Platform.WECHAT_GAME) {
-            if(ad_type == config.AD_TYPE.RE_LIFE) {
-                ad_id = config.WX_REWARD.RE_LIFE
-            } else if (ad_type == config.AD_TYPE.ANSWER) {
-                ad_id = config.WX_REWARD.ANSWER
-            } else if (ad_type == config.AD_TYPE.LOOK_TIPS) {
-                ad_id = config.WX_REWARD.LOOK_TIPS
-            } else if (ad_type == config.AD_TYPE.UN_LOCK_24) {
-                ad_id = config.WX_REWARD.UN_LOCK_24
-            } else if (ad_type == config.AD_TYPE.UN_LOCK) {
-                ad_id = config.WX_REWARD.UN_LOCK
-            } else if (ad_type == config.AD_TYPE.ADD_TIME) {
-                ad_id = config.WX_REWARD.ADD_TIME
+            if(SdkUtil.KS_GAME) {
+                if(ad_type == config.AD_TYPE.RE_LIFE) {
+                    ad_id = config.KS_REWARD.RE_LIFE
+                } else if (ad_type == config.AD_TYPE.ANSWER) {
+                    ad_id = config.KS_REWARD.ANSWER
+                } else if (ad_type == config.AD_TYPE.LOOK_TIPS) {
+                    ad_id = config.KS_REWARD.LOOK_TIPS
+                } else if (ad_type == config.AD_TYPE.UN_LOCK_24) {
+                    ad_id = config.KS_REWARD.UN_LOCK_24
+                } else if (ad_type == config.AD_TYPE.UN_LOCK) {
+                    ad_id = config.KS_REWARD.UN_LOCK
+                } else if (ad_type == config.AD_TYPE.ADD_TIME) {
+                    ad_id = config.KS_REWARD.ADD_TIME
+                }
+            } else {
+                if(ad_type == config.AD_TYPE.RE_LIFE) {
+                    ad_id = config.WX_REWARD.RE_LIFE
+                } else if (ad_type == config.AD_TYPE.ANSWER) {
+                    ad_id = config.WX_REWARD.ANSWER
+                } else if (ad_type == config.AD_TYPE.LOOK_TIPS) {
+                    ad_id = config.WX_REWARD.LOOK_TIPS
+                } else if (ad_type == config.AD_TYPE.UN_LOCK_24) {
+                    ad_id = config.WX_REWARD.UN_LOCK_24
+                } else if (ad_type == config.AD_TYPE.UN_LOCK) {
+                    ad_id = config.WX_REWARD.UN_LOCK
+                } else if (ad_type == config.AD_TYPE.ADD_TIME) {
+                    ad_id = config.WX_REWARD.ADD_TIME
+                }
             }
+            
         }
         return ad_id
     }
@@ -140,49 +166,54 @@ export class SdkUtil {
             call_back({"isEnded":true})
             return
         }
-        if(sys.platform==sys.Platform.BYTEDANCE_MINI_GAME||sys.platform==sys.Platform.WECHAT_GAME){
+
+        if(sys.platform==sys.Platform.BYTEDANCE_MINI_GAME) {
             gameManager.Singleton.showLoadingLevel()
-            if(sys.platform==sys.Platform.BYTEDANCE_MINI_GAME) {
-                SdkUtil.videoAd = tt.createRewardedVideoAd({adUnitId: _adUnitId});
-            } else if(sys.platform==sys.Platform.WECHAT_GAME) {
-                gameManager.Singleton.hideLoadingLevel()
-                call_back({"isEnded":true})
-                return
-                // SdkUtil.videoAd = wx.createRewardedVideoAd({adUnitId: _adUnitId});
+            SdkUtil.videoAd = tt.createRewardedVideoAd({adUnitId: _adUnitId});
+        } else if(sys.platform==sys.Platform.WECHAT_GAME) {
+            call_back({"isEnded":true})
+            if(SdkUtil.KS_GAME) { console.log('ks ad') } 
+            else { console.log('wx ad') }
+            return
+            gameManager.Singleton.showLoadingLevel()
+            if(SdkUtil.KS_GAME) {
+                SdkUtil.videoAd = ks.createRewardedVideoAd({adUnitId: _adUnitId});
+            } else {
+                SdkUtil.videoAd = wx.createRewardedVideoAd({adUnitId: _adUnitId});
             }
+        }
 
-            if(SdkUtil.videoAd==null){ 
-                gameManager.Singleton.hideLoadingLevel()
-                return
-             }
+        if(SdkUtil.videoAd==null){ 
+            gameManager.Singleton.hideLoadingLevel()
+            return
+         }
 
-            SdkUtil.videoAd.onLoad(() => {
-                SdkUtil.isLookAd = true
-                SdkUtil.videoAd.show();
-                console.log("广告加载完成");
-            });
-            SdkUtil.videoAd.onClose((res) => {
-                call_back(res)
-                SdkUtil.isLookAd = false
-                SdkUtil.videoAd.destroy()
-                gameManager.Singleton.hideLoadingLevel()
-            });
-            SdkUtil.videoAd.onError((res) => {
-                let errorString = res.errCode + '-' + res.errMsg
-                call_back({isEnded:false,errorString:errorString})
-                SdkUtil.isLookAd = false
-                SdkUtil.videoAd.destroy()
-                gameManager.Singleton.hideLoadingLevel()
-            });
-            SdkUtil.videoAd.load()
-        }
+        SdkUtil.videoAd.onLoad(() => {
+            SdkUtil.isLookAd = true
+            SdkUtil.videoAd.show();
+            console.log("广告加载完成");
+        });
+        SdkUtil.videoAd.onClose((res) => {
+            call_back(res)
+            SdkUtil.isLookAd = false
+            SdkUtil.videoAd.destroy()
+            gameManager.Singleton.hideLoadingLevel()
+        });
+        SdkUtil.videoAd.onError((res) => {
+            let errorString = res.errCode + '-' + res.errMsg
+            call_back({isEnded:false,errorString:errorString})
+            SdkUtil.isLookAd = false
+            SdkUtil.videoAd.destroy()
+            gameManager.Singleton.hideLoadingLevel()
+        });
+        SdkUtil.videoAd.load()
     }
 
     //------------------------------  微信相关  ------------------------------//
 
     // 微信分享
     public static wxShare(title: string, imageUrl: string) {
-        // console.log('微信分享=',title, 'imageUrl=',imageUrl)
+        // console.log('wx分享=',title, 'imageUrl=',imageUrl)
         wx.showShareMenu({
             withShareTicket: true,
             // shareAppMessage(可以删除):显示分享给好友选项,shareTimeline(可以删除):显示分享至朋友圈选项
@@ -198,6 +229,16 @@ export class SdkUtil {
         });
     }
 
+    //------------------------------  快手相关  ------------------------------//
+
+    // 快手分享
+    public static ksShare(title: string, imageUrl: string) {
+        // console.log('ks分享=',title, 'imageUrl=',imageUrl)
+        ks.shareAppMessage({
+            success:(res)=>{ console.log('ks success=',res) },
+            fail:(err)=>{ console.log('ks fail=',err) }
+        });
+    }
 
     //------------------------------  抖音相关  ------------------------------//