|
@@ -2,17 +2,32 @@
|
|
|
import { _decorator, Component, EditBox, game, instantiate, Label, Node, Prefab } from 'cc';
|
|
import { _decorator, Component, EditBox, game, instantiate, Label, Node, Prefab } from 'cc';
|
|
|
import { UtilsPanel } from '../../scene/script/UtilsPanel';
|
|
import { UtilsPanel } from '../../scene/script/UtilsPanel';
|
|
|
import { Generate } from '../../scene/script/components/Generate';
|
|
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 { 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')
|
|
@ccclass('Pay')
|
|
|
export class Pay extends Component {
|
|
export class Pay extends Component {
|
|
|
|
|
|
|
@@ -22,26 +37,44 @@ export class Pay extends Component {
|
|
|
private lb_money: Label = null;
|
|
private lb_money: Label = null;
|
|
|
private edit_id: EditBox = null;
|
|
private edit_id: EditBox = null;
|
|
|
|
|
|
|
|
- private urls = null;
|
|
|
|
|
- private select_index = 0;
|
|
|
|
|
|
|
+ private data: ShopData[] = null;
|
|
|
|
|
+ private select_data:ShopData = null;
|
|
|
|
|
|
|
|
protected onLoad(){
|
|
protected onLoad(){
|
|
|
UtilsPanel.getAllNeedCom(this, this.node, false);
|
|
UtilsPanel.getAllNeedCom(this, this.node, false);
|
|
|
UtilsPanel.addBtnEvent(this.node_buy, this.onBuy, this);
|
|
UtilsPanel.addBtnEvent(this.node_buy, this.onBuy, this);
|
|
|
// @ts-ignore
|
|
// @ts-ignore
|
|
|
game.on("select_item", this.onSelect, this);
|
|
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(){
|
|
private onEditChange(){
|
|
|
this.node_descid.active = this.edit_id.string.length == 0;
|
|
this.node_descid.active = this.edit_id.string.length == 0;
|
|
|
}
|
|
}
|
|
|
private onSelect(index:number){
|
|
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(){
|
|
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);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}
|
|
}
|