Răsfoiți Sursa

updaet test pay

zy_1995 7 luni în urmă
părinte
comite
5b46b8582e
1 a modificat fișierele cu 31 adăugiri și 9 ștergeri
  1. 31 9
      assets/Scene/Script/Lobby.js

+ 31 - 9
assets/Scene/Script/Lobby.js

@@ -344,15 +344,6 @@ cc.Class({
         });
     },
 
-    //商品购买按钮点击事件
-    onClick_Buy_Good: function () {
-        cc.gSoundRes.PlaySound('Button');
-        let goodInfo = { 
-            itemID: "coin_99"
-        };
-        ThirdPartyBuyGood(JSON.stringify(goodInfo));
-    },
-
     //设置按钮点击事件
     onClick_Bt_shezhi: function () {
         cc.gSoundRes.PlaySound('Button');
@@ -975,6 +966,37 @@ cc.Class({
         this.onBuyGoodCallback(tempPayData);
     },
 
+    //商品购买按钮点击事件
+    onClick_Buy_Good: function () {
+        cc.gSoundRes.PlaySound('Button');
+        // this.orderId = "1_1755854553_2936_3416a75f";
+        // let goodInfo = { 
+        //     shopId: "coin_99"
+        // };
+        // ThirdPartyBuyGood(JSON.stringify(goodInfo));
+        let shopId = "coin_99";
+        let userId = g_GlobalUserInfo.GetGlobalUserData().dwUserID;
+        let sendData = {
+            userId: userId,
+            shopId: shopId,
+            platformId: 1
+        };
+        //info { return, data, timestamp }
+        let webUrl = `${PHP_HOME}/pay.php`;
+        WebCenter.httpPOST(webUrl, sendData, (info) => {
+            cc.log("post buy good, ", info);
+            if ("0" != info.return) {
+                return cc.error("post buy good Error!");
+            }
+            this.setOrderId(info.orderId, () => {
+                this.ShowTips("购买商品成功,获得钻石99个!");
+            });
+            ThirdPartyBuyGood(JSON.stringify({ 
+                itemID: shopId
+            }));
+        });
+    },
+
     setOrderId(orderId, callback) {
         this.orderId = orderId;
         this.orderCallback = callback;