zy_1995 7 mesi fa
parent
commit
c910e7a0e8

+ 429 - 41
assets/Scene/Lobby.fire

@@ -75,31 +75,31 @@
         "__id__": 5
       },
       {
-        "__id__": 191
+        "__id__": 199
       },
       {
-        "__id__": 193
+        "__id__": 201
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 200
+        "__id__": 208
       },
       {
-        "__id__": 201
+        "__id__": 209
       },
       {
-        "__id__": 202
+        "__id__": 210
       },
       {
-        "__id__": 203
+        "__id__": 211
       },
       {
-        "__id__": 204
+        "__id__": 212
       },
       {
-        "__id__": 205
+        "__id__": 213
       }
     ],
     "_prefab": null,
@@ -266,16 +266,16 @@
         "__id__": 11
       },
       {
-        "__id__": 181
+        "__id__": 189
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 189
+        "__id__": 197
       },
       {
-        "__id__": 190
+        "__id__": 198
       }
     ],
     "_prefab": null,
@@ -602,6 +602,9 @@
       },
       {
         "__id__": 176
+      },
+      {
+        "__id__": 181
       }
     ],
     "_active": true,
@@ -3799,7 +3802,7 @@
         "__id__": 85
       }
     ],
-    "_active": false,
+    "_active": true,
     "_components": [
       {
         "__id__": 87
@@ -8757,6 +8760,391 @@
     },
     "_id": "28Zeg6rZlK0YZIy3BT+35+"
   },
+  {
+    "__type__": "cc.Node",
+    "_name": "New Button",
+    "_objFlags": 0,
+    "_parent": {
+      "__id__": 11
+    },
+    "_children": [
+      {
+        "__id__": 182
+      }
+    ],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 187
+      }
+    ],
+    "_prefab": null,
+    "_opacity": 255,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 100,
+      "height": 40
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_trs": {
+      "__type__": "TypedArray",
+      "ctor": "Float64Array",
+      "array": [
+        -118.855,
+        -198.775,
+        0,
+        0,
+        0,
+        0,
+        1,
+        1,
+        1,
+        1
+      ]
+    },
+    "_eulerAngles": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_skewX": 0,
+    "_skewY": 0,
+    "_is3DNode": false,
+    "_groupIndex": 0,
+    "groupIndex": 0,
+    "_id": "2d/bWiLUdLV4SzBK4tsEoS"
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "Background",
+    "_objFlags": 512,
+    "_parent": {
+      "__id__": 181
+    },
+    "_children": [
+      {
+        "__id__": 183
+      }
+    ],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 185
+      },
+      {
+        "__id__": 186
+      }
+    ],
+    "_prefab": null,
+    "_opacity": 255,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 100,
+      "height": 40
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_trs": {
+      "__type__": "TypedArray",
+      "ctor": "Float64Array",
+      "array": [
+        0,
+        0,
+        0,
+        0,
+        0,
+        0,
+        1,
+        1,
+        1,
+        1
+      ]
+    },
+    "_eulerAngles": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_skewX": 0,
+    "_skewY": 0,
+    "_is3DNode": false,
+    "_groupIndex": 0,
+    "groupIndex": 0,
+    "_id": "3a+e2pWDVBBoCx84SjpM3V"
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "Label",
+    "_objFlags": 512,
+    "_parent": {
+      "__id__": 182
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 184
+      }
+    ],
+    "_prefab": null,
+    "_opacity": 255,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 0,
+      "g": 0,
+      "b": 0,
+      "a": 255
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 100,
+      "height": 40
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_trs": {
+      "__type__": "TypedArray",
+      "ctor": "Float64Array",
+      "array": [
+        0,
+        0,
+        0,
+        0,
+        0,
+        0,
+        1,
+        1,
+        1,
+        1
+      ]
+    },
+    "_eulerAngles": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_skewX": 0,
+    "_skewY": 0,
+    "_is3DNode": false,
+    "_groupIndex": 0,
+    "groupIndex": 0,
+    "_id": "0a/kXcMZ1H5IhxX6YRO+fK"
+  },
+  {
+    "__type__": "cc.Label",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 183
+    },
+    "_enabled": true,
+    "_materials": [
+      {
+        "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
+      }
+    ],
+    "_srcBlendFactor": 770,
+    "_dstBlendFactor": 771,
+    "_string": "NT$ 99",
+    "_N$string": "NT$ 99",
+    "_fontSize": 20,
+    "_lineHeight": 40,
+    "_enableWrapText": false,
+    "_N$file": null,
+    "_isSystemFontUsed": true,
+    "_spacingX": 0,
+    "_batchAsBitmap": false,
+    "_styleFlags": 0,
+    "_underlineHeight": 0,
+    "_N$horizontalAlign": 1,
+    "_N$verticalAlign": 1,
+    "_N$fontFamily": "Arial",
+    "_N$overflow": 1,
+    "_N$cacheMode": 1,
+    "_id": "89+o9k2Z9BTr6CIDCb6qhD"
+  },
+  {
+    "__type__": "cc.Sprite",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 182
+    },
+    "_enabled": true,
+    "_materials": [
+      {
+        "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
+      }
+    ],
+    "_srcBlendFactor": 770,
+    "_dstBlendFactor": 771,
+    "_spriteFrame": {
+      "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952"
+    },
+    "_type": 1,
+    "_sizeMode": 0,
+    "_fillType": 0,
+    "_fillCenter": {
+      "__type__": "cc.Vec2",
+      "x": 0,
+      "y": 0
+    },
+    "_fillStart": 0,
+    "_fillRange": 0,
+    "_isTrimmedMode": true,
+    "_atlas": null,
+    "_id": "66BuQgJbVFAYvZo+ml3rQy"
+  },
+  {
+    "__type__": "cc.Widget",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 182
+    },
+    "_enabled": true,
+    "alignMode": 0,
+    "_target": null,
+    "_alignFlags": 45,
+    "_left": 0,
+    "_right": 0,
+    "_top": 0,
+    "_bottom": 0,
+    "_verticalCenter": 0,
+    "_horizontalCenter": 0,
+    "_isAbsLeft": true,
+    "_isAbsRight": true,
+    "_isAbsTop": true,
+    "_isAbsBottom": true,
+    "_isAbsHorizontalCenter": true,
+    "_isAbsVerticalCenter": true,
+    "_originalWidth": 100,
+    "_originalHeight": 40,
+    "_id": "9759+4VvVDcbjTlQkXPUPS"
+  },
+  {
+    "__type__": "cc.Button",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 181
+    },
+    "_enabled": true,
+    "_normalMaterial": null,
+    "_grayMaterial": null,
+    "duration": 0.1,
+    "zoomScale": 1.2,
+    "clickEvents": [
+      {
+        "__id__": 188
+      }
+    ],
+    "_N$interactable": true,
+    "_N$enableAutoGrayEffect": false,
+    "_N$transition": 2,
+    "transition": 2,
+    "_N$normalColor": {
+      "__type__": "cc.Color",
+      "r": 230,
+      "g": 230,
+      "b": 230,
+      "a": 255
+    },
+    "_N$pressedColor": {
+      "__type__": "cc.Color",
+      "r": 200,
+      "g": 200,
+      "b": 200,
+      "a": 255
+    },
+    "pressedColor": {
+      "__type__": "cc.Color",
+      "r": 200,
+      "g": 200,
+      "b": 200,
+      "a": 255
+    },
+    "_N$hoverColor": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "hoverColor": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_N$disabledColor": {
+      "__type__": "cc.Color",
+      "r": 120,
+      "g": 120,
+      "b": 120,
+      "a": 200
+    },
+    "_N$normalSprite": {
+      "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952"
+    },
+    "_N$pressedSprite": {
+      "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a"
+    },
+    "pressedSprite": {
+      "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a"
+    },
+    "_N$hoverSprite": {
+      "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952"
+    },
+    "hoverSprite": {
+      "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952"
+    },
+    "_N$disabledSprite": {
+      "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e"
+    },
+    "_N$target": {
+      "__id__": 182
+    },
+    "_id": "62jfXBpipMfK9ZRqVntWPQ"
+  },
+  {
+    "__type__": "cc.ClickEvent",
+    "target": {
+      "__id__": 2
+    },
+    "component": "",
+    "_componentId": "3150dXIdf1DLpc84I60IcR0",
+    "handler": "onClick_Buy_Good",
+    "customEventData": ""
+  },
   {
     "__type__": "cc.Node",
     "_name": "TipsNode",
@@ -8766,7 +9154,7 @@
     },
     "_children": [
       {
-        "__id__": 182
+        "__id__": 190
       }
     ],
     "_active": true,
@@ -8824,20 +9212,20 @@
     "_name": "NoticeBG",
     "_objFlags": 0,
     "_parent": {
-      "__id__": 181
+      "__id__": 189
     },
     "_children": [
       {
-        "__id__": 183
+        "__id__": 191
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 187
+        "__id__": 195
       },
       {
-        "__id__": 188
+        "__id__": 196
       }
     ],
     "_prefab": null,
@@ -8893,17 +9281,17 @@
     "_name": "Mark",
     "_objFlags": 0,
     "_parent": {
-      "__id__": 182
+      "__id__": 190
     },
     "_children": [
       {
-        "__id__": 184
+        "__id__": 192
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 186
+        "__id__": 194
       }
     ],
     "_prefab": null,
@@ -8959,13 +9347,13 @@
     "_name": "LabMotice",
     "_objFlags": 0,
     "_parent": {
-      "__id__": 183
+      "__id__": 191
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 185
+        "__id__": 193
       }
     ],
     "_prefab": null,
@@ -9021,7 +9409,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 184
+      "__id__": 192
     },
     "_enabled": true,
     "_materials": [
@@ -9054,7 +9442,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 183
+      "__id__": 191
     },
     "_enabled": true,
     "_materials": [
@@ -9074,7 +9462,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 182
+      "__id__": 190
     },
     "_enabled": true,
     "_materials": [
@@ -9106,14 +9494,14 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 182
+      "__id__": 190
     },
     "_enabled": true,
     "m_MsgBg": {
-      "__id__": 187
+      "__id__": 195
     },
     "m_LabMsg": {
-      "__id__": 185
+      "__id__": 193
     },
     "_id": "3bssGnHExOZ5AJy8YyHIoJ"
   },
@@ -9187,7 +9575,7 @@
     "_active": true,
     "_components": [
       {
-        "__id__": 192
+        "__id__": 200
       }
     ],
     "_prefab": null,
@@ -9243,7 +9631,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 191
+      "__id__": 199
     },
     "_enabled": true,
     "alignMode": 1,
@@ -9274,16 +9662,16 @@
     },
     "_children": [
       {
-        "__id__": 194
+        "__id__": 202
       },
       {
-        "__id__": 197
+        "__id__": 205
       }
     ],
     "_active": false,
     "_components": [
       {
-        "__id__": 199
+        "__id__": 207
       }
     ],
     "_prefab": null,
@@ -9339,13 +9727,13 @@
     "_name": "NoClick",
     "_objFlags": 0,
     "_parent": {
-      "__id__": 193
+      "__id__": 201
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 195
+        "__id__": 203
       }
     ],
     "_prefab": null,
@@ -9401,7 +9789,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 194
+      "__id__": 202
     },
     "_enabled": true,
     "_normalMaterial": null,
@@ -9410,7 +9798,7 @@
     "zoomScale": 1.2,
     "clickEvents": [
       {
-        "__id__": 196
+        "__id__": 204
       }
     ],
     "_N$interactable": true,
@@ -9493,13 +9881,13 @@
     "_name": "logo",
     "_objFlags": 0,
     "_parent": {
-      "__id__": 193
+      "__id__": 201
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 198
+        "__id__": 206
       }
     ],
     "_prefab": null,
@@ -9555,7 +9943,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 197
+      "__id__": 205
     },
     "_enabled": true,
     "_materials": [
@@ -9587,7 +9975,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 193
+      "__id__": 201
     },
     "_enabled": true,
     "_materials": [

+ 15 - 1
assets/Scene/Script/Lobby.js

@@ -345,6 +345,16 @@ cc.Class({
             });
         });
     },
+
+    //商品购买按钮点击事件
+    onClick_Buy_Good: function () {
+        cc.gSoundRes.PlaySound('Button');
+        let goodInfo = { 
+            itemID: "coin_99"
+        };
+        ThirdPartyBuyGood(goodInfo);
+    },
+
     //设置按钮点击事件
     onClick_Bt_shezhi: function () {
         cc.gSoundRes.PlaySound('Button');
@@ -957,5 +967,9 @@ cc.Class({
         cc.resources.load("Image/BG/BG" + index, cc.SpriteFrame, function (err, spriteFrame) {
             bg.spriteFrame = spriteFrame;
         });
-    }
+    },
+
+    onBuyGoodCallback() {
+        this.ShowTips("购买商品成功,获得钻石99个!");
+    },
 });

+ 25 - 1
assets/Script/CustomClass/WebDataCenter.js

@@ -103,6 +103,30 @@ WebDataCenter = cc.Class({
         xhr.timeout = 5000;// 5 seconds for timeout
         xhr.open("POST", Url, true);
         xhr.send();
-    }
+    },
+
+    httpPOST(url, param = {}, callback) {
+        // url = HttpUtil.baseUrl + url;
+        this.m_LinkCount++;
+        var xhr = cc.loader.getXMLHttpRequest();
+        let dataStr = '';
+        Object.keys(param).forEach(key => {
+            dataStr += key + '=' + encodeURIComponent(param[key]) + '&';
+        })
+        if (dataStr !== '') {
+            dataStr = dataStr.substring(0, dataStr.lastIndexOf('&'));
+        }
+        xhr.open("POST", url, true);
+        xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+        xhr.onreadystatechange = function () {
+            if (xhr.readyState === 4 && (xhr.status >= 200 && xhr.status < 400)) {
+                this.m_LinkCount--;
+                let response = xhr.responseText;
+                callback(false, response);
+            }
+        };
+        xhr.send(dataStr);
+    },
+
 });
 WebCenter = new WebDataCenter();

+ 26 - 4
assets/Script/Define/ThirdParty.js

@@ -70,6 +70,15 @@ function onPickImageResult(base64) {
     image.src = "data:image/png;base64," + base64;
 }
 
+//#region 购买商品回调
+function CallBoughtGoodFunc(payData) {
+    if (window.LOG_NET_DATA) console.log("CallBoughtGoodFunc ", payData);
+    const callbackName = "onBuyGoodCallback"
+    if (g_Lobby != null && g_Lobby[callbackName]) {
+        g_Lobby[callbackName](payData);
+    }
+}
+
 //原生功能
 function ThirdPartyGetBattery() {
     var pLv = 1;
@@ -188,7 +197,7 @@ function ThirdPartyUpdateGame(url,apkName,ver) {
     }
 }
 
-//#region google相关
+//#region google登录
 function ThirdPartyGoogleLogin() {
     if (cc.sys.isNative) {
         if (cc.sys.OS_IOS == cc.sys.os) {
@@ -201,7 +210,7 @@ function ThirdPartyGoogleLogin() {
 
 //#endregion
 
-//#region line相关
+//#region line登录
 function ThirdPartyLINELogin() {
     if (cc.sys.isNative) {
         if (cc.sys.OS_IOS == cc.sys.os) {
@@ -214,7 +223,7 @@ function ThirdPartyLINELogin() {
 
 //#endregion
 
-//#region apple相关
+//#region apple登录
 function ThirdPartyIOSLogin() {
     if (cc.sys.isNative) {
         if (cc.sys.OS_IOS == cc.sys.os) {
@@ -225,7 +234,7 @@ function ThirdPartyIOSLogin() {
 
 //#endregion
 
-//微信相关
+//#region 微信登录
 function ThirdPartyWXLogin() {
     if (cc.sys.isNative) {
         if (cc.sys.OS_IOS == cc.sys.os) {
@@ -235,7 +244,20 @@ function ThirdPartyWXLogin() {
         }
     }
 }
+//#endregion
 
+//#region 商品购买
+//goodInfo { itemID }
+function ThirdPartyBuyGood(goodInfo) {
+    if (cc.sys.isNative) {
+        if (cc.sys.OS_IOS == cc.sys.os) {
+            jsb.reflection.callStaticMethod("AppController", "sendBuyGood", goodInfo);
+        } else if (cc.sys.OS_ANDROID == cc.sys.os) {
+            jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "sendBuyGood", "(Ljava/lang/String;)V", goodInfo);
+        }
+    }
+}
+//#endregion
 
 function ThirdPartyShareMessage(ShareInfo, isLine) {
     if (window.LOG_NET_DATA) console.log("WXShare ", isLine, " ", ShareInfo)