bing 2 tahun lalu
induk
melakukan
11d607b92f
3 mengubah file dengan 66 tambahan dan 24 penghapusan
  1. 6 5
      assets/pay/script/ItemPay.ts
  2. 50 17
      assets/pay/script/Pay.ts
  3. 10 2
      assets/scene/script/NavInfo.ts

+ 6 - 5
assets/pay/script/ItemPay.ts

@@ -3,6 +3,7 @@ import { _decorator, Component, game, Label, Node, Sprite } from 'cc';
 import { UtilsPanel } from '../../scene/script/UtilsPanel';
 import { ViewItemPro } from '../../scene/script/components/ViewItemPro';
 import { nav_info } from '../../scene/script/NavInfo';
+import { ShopData } from './Pay';
 const { ccclass } = _decorator;
 
 @ccclass('ItemPay')
@@ -11,20 +12,20 @@ export class ItemPay extends ViewItemPro {
     private sp_icon: Sprite = null;
 	private lb_count: Label = null;
 
-    private data = null;
+    private index = null;
 	protected onLoad(){
 		UtilsPanel.getAllNeedCom(this, this.node, false);
         UtilsPanel.addBtnEvent(this.node, this.onClick, this);
 	}
 
-    public init(data: any, index?: number, p?: any): void {
+    public init(data:ShopData, index?: number, p?: any): void {
         if(index > 5)index = 5;
-        this.data = index;
-        this.lb_count.string = "" + index * 1000;
+        this.index = index;
+        this.lb_count.string = "" + data.Extra[0].Count;
         UtilsPanel.setItemIcon(nav_info.bundle, "texture/2"+index+"/spriteFrame", this.sp_icon);
     }
 
     public onClick(){
-        game.emit("select_item", this.data);
+        game.emit("select_item", this.index);
     }
 }

+ 50 - 17
assets/pay/script/Pay.ts

@@ -2,17 +2,32 @@
 import { _decorator, Component, EditBox, game, instantiate, Label, Node, Prefab } from 'cc';
 import { UtilsPanel } from '../../scene/script/UtilsPanel';
 import { Generate } from '../../scene/script/components/Generate';
-import { nav_info } from '../../scene/script/NavInfo';
+import { Config, nav_info } from '../../scene/script/NavInfo';
+import { WebRequest } from '../../scene/script/WebRequest';
 const { ccclass, property } = _decorator;
 
-const Urls = [
-    "",
-    ""
-]
-const Urls_Test = [
-    "http://139.224.253.42:8089/livepay/getProducts?H5Extra=666888",
-    "http://139.224.253.42:8089/livepay/payOrder"
-];
+type ItemType = {
+    ItemId: number
+    Count: number
+}
+export type ShopData = {
+    AninationType: number
+    Bonus: number
+    Extra: Array<ItemType>
+    IsBotton: number
+    IsHot: number
+    PayType: number
+    Price: number
+    ProductDesc: string
+    ProductId: string
+    ProductName: string
+    ShopType: number
+    ShowPrice: number
+    Sort: number
+    Status: number
+    UserType: number
+}
+
 @ccclass('Pay')
 export class Pay extends Component {
 
@@ -22,26 +37,44 @@ export class Pay extends Component {
 	private lb_money: Label = null;
 	private edit_id: EditBox = null;
     
-    private urls = null;
-    private select_index = 0;
+    private data: ShopData[] = null;
+    private select_data:ShopData = null;
 
 	protected onLoad(){
 		UtilsPanel.getAllNeedCom(this, this.node, false);
         UtilsPanel.addBtnEvent(this.node_buy, this.onBuy, this);
         // @ts-ignore
         game.on("select_item", this.onSelect, this);
-        this.urls = nav_info.is_test ? Urls_Test : Urls;
+        let url = nav_info.is_test ? Config.url_product_test : Config.url_product;
+        new WebRequest().getData(url, "", (succ:boolean,content:string)=>{
+            if(succ){
+                this.data = JSON.parse(JSON.parse(content).Data);
+            }
+            this.gene_items.initData(this.data);
+            // console.log("fwef:",this.data);
+        }, false);
 	}
-    protected start(): void {
-        this.gene_items.initData(new Array(6));
-    }
     private onEditChange(){
         this.node_descid.active = this.edit_id.string.length == 0;
     }
     private onSelect(index:number){
-        this.lb_money.string = index * 1000 + "";
+        this.select_data = this.data[index];
+        this.lb_money.string = this.select_data.Price + "";
     }
     private onBuy(){
-
+        let user_id = this.edit_id.string;
+        if(user_id.length == 0){
+            nav_info.scene.showTip("please input user id");
+            return;
+        }
+        if(!this.select_data){
+            nav_info.scene.showTip("please select product");
+            return;
+        }
+        let data = this.select_data;
+        let url = nav_info.is_test ? Config.url_pay_test : Config.url_pay;
+        let final_url = `${url}?UserID=${user_id}&Price=${data.Price}&ProductID=${data.ProductId}&PartnerID=110&Currency=SAR&Country=SA&T=${new Date().getTime()}`;
+        window.open(final_url);
     }
+    
 }

+ 10 - 2
assets/scene/script/NavInfo.ts

@@ -9,7 +9,7 @@ class NavInfo{
     public scene: MainScene = null;
 
     public bundle = "pay";
-    public pre = "pag";
+    public pre = "pay";
     public is_test = false;
 
     public init(){
@@ -38,11 +38,19 @@ class NavInfo{
 export const nav_info = new NavInfo();
 
 export class Config{
+    public static copy_prefix = "cocobaloot:";
+    
+    //跳转
     public static scheme_id = "cocobaloot";
     public static scheme_prefix = "";
+    //下载
     public static download_ios_url = "https://apps.apple.com/sa/app/%D8%A8%D9%84%D9%88%D8%AA-%D8%A7%D9%84%D9%85%D8%A7%D8%B1%D8%AF/id6451100112";
     public static downlaod_google_url = `https://play.google.com/store/apps/details?id=chior.mideast.thirdd&referrer=website`;
-    public static copy_prefix = "cocobaloot:";
+    //充值
+    public static url_product = "https://baloot.almarid77.com:8089/livepay/getProducts?H5Extra=666888";
+    public static url_pay = "https://baloot.almarid77.com:8089/livepay/payOrder";
+    public static url_product_test = "http://139.224.253.42:8089/livepay/getProducts?H5Extra=666888";
+    public static url_pay_test = "http://139.224.253.42:8089/livepay/payOrder";
 
     public static init(){
         let prefix = sys.platform == sys.Platform.IOS ? "://?" : "://splash?";