充值代码
This commit is contained in:
parent
e887760ba6
commit
c3b24969e3
|
@ -10507,7 +10507,7 @@
|
||||||
"__id__": 370
|
"__id__": 370
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_active": true,
|
"_active": false,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 397
|
"__id__": 397
|
||||||
|
@ -11012,7 +11012,7 @@
|
||||||
"__id__": 298
|
"__id__": 298
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_active": false,
|
"_active": true,
|
||||||
"_components": [],
|
"_components": [],
|
||||||
"_prefab": null,
|
"_prefab": null,
|
||||||
"_opacity": 255,
|
"_opacity": 255,
|
||||||
|
@ -17709,7 +17709,7 @@
|
||||||
"__id__": 395
|
"__id__": 395
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_active": true,
|
"_active": false,
|
||||||
"_components": [],
|
"_components": [],
|
||||||
"_prefab": null,
|
"_prefab": null,
|
||||||
"_opacity": 255,
|
"_opacity": 255,
|
||||||
|
|
|
@ -2435,7 +2435,7 @@
|
||||||
"__type__": "TypedArray",
|
"__type__": "TypedArray",
|
||||||
"ctor": "Float64Array",
|
"ctor": "Float64Array",
|
||||||
"array": [
|
"array": [
|
||||||
-0.255,
|
19.091,
|
||||||
1.584,
|
1.584,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
|
|
@ -109,7 +109,11 @@ export default class NewClass extends cc.Component {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateCoin(){
|
||||||
|
console.log("主页更新金币",cc.fx.GameConfig.GM_INFO.coin);
|
||||||
|
cc.fx.GameConfig.GM_INFO.coin += 900;
|
||||||
|
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
|
||||||
|
}
|
||||||
|
|
||||||
//开始倒计时
|
//开始倒计时
|
||||||
startTimeCutDown() {
|
startTimeCutDown() {
|
||||||
|
@ -216,13 +220,7 @@ export default class NewClass extends cc.Component {
|
||||||
|
|
||||||
clickShop() {
|
clickShop() {
|
||||||
// 假设已经获取到了 userId 和 productId
|
// 假设已经获取到了 userId 和 productId
|
||||||
Utils.buyProp((res)=>{
|
|
||||||
console.log("获得充值结果",res);
|
|
||||||
Utils.getPayInfo((data) =>{
|
|
||||||
console.log("获得轮训结果:",data);
|
|
||||||
console.log(data.data.pay_state)
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,18 +30,33 @@ export default class NumberToImage extends cc.Component {
|
||||||
else if (number < 10) cha = posX
|
else if (number < 10) cha = posX
|
||||||
if (targetNode.children.length > 0)
|
if (targetNode.children.length > 0)
|
||||||
targetNode.removeAllChildren();
|
targetNode.removeAllChildren();
|
||||||
|
|
||||||
|
const digitNodes: cc.Node[] = [];
|
||||||
for (let i = 0; i < numStr.length; i++) {
|
for (let i = 0; i < numStr.length; i++) {
|
||||||
const digit = parseInt(numStr[i], 10);
|
const digit = parseInt(numStr[i], 10);
|
||||||
const node = new cc.Node();
|
const node = new cc.Node();
|
||||||
const sprite = node.addComponent(cc.Sprite);
|
const sprite = node.addComponent(cc.Sprite);
|
||||||
// debugger;
|
|
||||||
sprite.spriteFrame = this.font._spriteFrames[name + digit + ""];
|
sprite.spriteFrame = this.font._spriteFrames[name + digit + ""];
|
||||||
// 将节点添加到目标节点下
|
digitNodes.push(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算总宽度
|
||||||
|
const totalWidth = (numStr.length - 1) * width + (digitNodes[0]?.width || 0);
|
||||||
|
|
||||||
|
if (middle) {
|
||||||
|
// 计算居中的起始位置
|
||||||
|
const startX = -totalWidth / 2;
|
||||||
|
for (let i = 0; i < digitNodes.length; i++) {
|
||||||
|
const node = digitNodes[i];
|
||||||
|
node.x = startX + i * width;
|
||||||
|
node.parent = targetNode;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (let i = 0; i < digitNodes.length; i++) {
|
||||||
|
const node = digitNodes[i];
|
||||||
node.x = i * width + cha;
|
node.x = i * width + cha;
|
||||||
node.parent = targetNode;
|
node.parent = targetNode;
|
||||||
}
|
}
|
||||||
if (middle) {
|
|
||||||
targetNode.x = targetNode.x - targetNode.children.length * (width - 15) / 2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,10 @@ export default class Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**道具直购接口*/
|
/**道具直购接口*/
|
||||||
static buyProp(callBack){
|
static buyProp(id,count,price,callBack){
|
||||||
Utils.POST("wx/orderPaySig",{uid:Utils.uid,itemid:"10011",itemCount:1,itemPrice:100},res=>{
|
console.log("请求uid:"+Utils.uid,"请求id:"+id,"请求数量:"+count,"请求价格:"+price);
|
||||||
|
|
||||||
|
Utils.POST("wx/orderPaySig",{uid:Utils.uid,itemid:id,itemCount:count,itemPrice:price},res=>{
|
||||||
if(res.code==1){
|
if(res.code==1){
|
||||||
Utils.outTradeNo=res.data.outTradeNo;
|
Utils.outTradeNo=res.data.outTradeNo;
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
|
@ -45,7 +47,7 @@ export default class Utils {
|
||||||
fail({errMsg,errCode}) {
|
fail({errMsg,errCode}) {
|
||||||
console.error('失败');
|
console.error('失败');
|
||||||
console.error(errMsg, errCode)
|
console.error(errMsg, errCode)
|
||||||
callBack(res);
|
callBack(null);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -54,24 +56,30 @@ export default class Utils {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
static getPayInfo(callBack){
|
static getPayInfo(callBack) {
|
||||||
console.log("请求uid:"+Utils.uid);
|
const delays = [1000, 10000, 30000, 60000, 60000]; // 延迟时间数组
|
||||||
console.log("outTradeNo:"+this.outTradeNo);
|
let attempt = 0; // 轮询次数
|
||||||
Utils.POST("wx/getPayInfo",{uid:Utils.uid,outTradeNo:Utils.outTradeNo},res=>{
|
|
||||||
console.log("查询字符结果");
|
|
||||||
console.log(res);
|
|
||||||
if(res.code==1){
|
|
||||||
if(res.data.pay_state==1){
|
|
||||||
console.log("充值取消")
|
|
||||||
callBack(res);
|
|
||||||
}else{
|
|
||||||
console.log("充值成功")
|
|
||||||
callBack(res);
|
|
||||||
|
|
||||||
|
const poll = () => {
|
||||||
|
if (attempt >= delays.length) {
|
||||||
|
callBack({ code: 0, data: { pay_state: -1 }, message: '轮询超时' });
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("请求uid:", Utils.uid);
|
||||||
|
console.log("outTradeNo:", this.outTradeNo);
|
||||||
|
Utils.POST("wx/getPayInfo", { uid: Utils.uid, outTradeNo: Utils.outTradeNo }, res => {
|
||||||
|
console.log("查询字符结果:", res);
|
||||||
|
if (res.code === 1 && (res.data.pay_state === 1 || res.data.pay_state === 2)) {
|
||||||
|
callBack(res);
|
||||||
|
} else {
|
||||||
|
attempt++;
|
||||||
|
setTimeout(poll, delays[attempt - 1]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**跳转客服*/
|
/**跳转客服*/
|
||||||
|
|
|
@ -806,6 +806,36 @@ var GameTool = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
//商城购买
|
||||||
|
shopBuy(productId){
|
||||||
|
switch(productId){
|
||||||
|
case "gold_pack_1":
|
||||||
|
cc.fx.GameTool.changeCoin(1800);
|
||||||
|
MiniGameSdk.API.showToast("充值成功,获得1800金币");
|
||||||
|
break;
|
||||||
|
case "gold_pack_2":
|
||||||
|
cc.fx.GameTool.changeCoin(8000);
|
||||||
|
MiniGameSdk.API.showToast("充值成功,获得8000金币");
|
||||||
|
break;
|
||||||
|
case "gold_pack_3":
|
||||||
|
cc.fx.GameTool.changeCoin(16000);
|
||||||
|
MiniGameSdk.API.showToast("充值成功,获得16000金币");
|
||||||
|
break;
|
||||||
|
case "gold_pack_4":
|
||||||
|
cc.fx.GameTool.changeCoin(32000);
|
||||||
|
MiniGameSdk.API.showToast("充值成功,获得32000金币");
|
||||||
|
break;
|
||||||
|
case "gold_pack_5":
|
||||||
|
cc.fx.GameTool.changeCoin(100000);
|
||||||
|
MiniGameSdk.API.showToast("充值成功,获得100000金币");
|
||||||
|
break;
|
||||||
|
case "gold_pack_6":
|
||||||
|
cc.fx.GameTool.changeCoin(240000);
|
||||||
|
MiniGameSdk.API.showToast("充值成功,获得240000金币");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
formatDate(date: Date): string {
|
formatDate(date: Date): string {
|
||||||
const year = date.getFullYear();
|
const year = date.getFullYear();
|
||||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||||
|
|
|
@ -1046,7 +1046,7 @@
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
1
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"_eulerAngles": {
|
"_eulerAngles": {
|
||||||
|
@ -1277,7 +1277,7 @@
|
||||||
"__type__": "TypedArray",
|
"__type__": "TypedArray",
|
||||||
"ctor": "Float64Array",
|
"ctor": "Float64Array",
|
||||||
"array": [
|
"array": [
|
||||||
-72.37,
|
15,
|
||||||
150,
|
150,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -1321,7 +1321,7 @@
|
||||||
"__id__": 25
|
"__id__": 25
|
||||||
},
|
},
|
||||||
"_children": [],
|
"_children": [],
|
||||||
"_active": true,
|
"_active": false,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 34
|
"__id__": 34
|
||||||
|
@ -1576,7 +1576,7 @@
|
||||||
"_normalMaterial": null,
|
"_normalMaterial": null,
|
||||||
"_grayMaterial": null,
|
"_grayMaterial": null,
|
||||||
"duration": 0.1,
|
"duration": 0.1,
|
||||||
"zoomScale": 1.2,
|
"zoomScale": 1.1,
|
||||||
"clickEvents": [
|
"clickEvents": [
|
||||||
{
|
{
|
||||||
"__id__": 41
|
"__id__": 41
|
||||||
|
@ -1584,8 +1584,8 @@
|
||||||
],
|
],
|
||||||
"_N$interactable": true,
|
"_N$interactable": true,
|
||||||
"_N$enableAutoGrayEffect": false,
|
"_N$enableAutoGrayEffect": false,
|
||||||
"_N$transition": 0,
|
"_N$transition": 3,
|
||||||
"transition": 0,
|
"transition": 3,
|
||||||
"_N$normalColor": {
|
"_N$normalColor": {
|
||||||
"__type__": "cc.Color",
|
"__type__": "cc.Color",
|
||||||
"r": 255,
|
"r": 255,
|
||||||
|
@ -1742,7 +1742,7 @@
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
1
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"_eulerAngles": {
|
"_eulerAngles": {
|
||||||
|
@ -1973,7 +1973,7 @@
|
||||||
"__type__": "TypedArray",
|
"__type__": "TypedArray",
|
||||||
"ctor": "Float64Array",
|
"ctor": "Float64Array",
|
||||||
"array": [
|
"array": [
|
||||||
-72.37,
|
20,
|
||||||
150,
|
150,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -2017,7 +2017,7 @@
|
||||||
"__id__": 44
|
"__id__": 44
|
||||||
},
|
},
|
||||||
"_children": [],
|
"_children": [],
|
||||||
"_active": true,
|
"_active": false,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 53
|
"__id__": 53
|
||||||
|
@ -2272,7 +2272,7 @@
|
||||||
"_normalMaterial": null,
|
"_normalMaterial": null,
|
||||||
"_grayMaterial": null,
|
"_grayMaterial": null,
|
||||||
"duration": 0.1,
|
"duration": 0.1,
|
||||||
"zoomScale": 1.2,
|
"zoomScale": 1.1,
|
||||||
"clickEvents": [
|
"clickEvents": [
|
||||||
{
|
{
|
||||||
"__id__": 60
|
"__id__": 60
|
||||||
|
@ -2280,8 +2280,8 @@
|
||||||
],
|
],
|
||||||
"_N$interactable": true,
|
"_N$interactable": true,
|
||||||
"_N$enableAutoGrayEffect": false,
|
"_N$enableAutoGrayEffect": false,
|
||||||
"_N$transition": 0,
|
"_N$transition": 3,
|
||||||
"transition": 0,
|
"transition": 3,
|
||||||
"_N$normalColor": {
|
"_N$normalColor": {
|
||||||
"__type__": "cc.Color",
|
"__type__": "cc.Color",
|
||||||
"r": 255,
|
"r": 255,
|
||||||
|
@ -2438,7 +2438,7 @@
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
1
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"_eulerAngles": {
|
"_eulerAngles": {
|
||||||
|
@ -2669,7 +2669,7 @@
|
||||||
"__type__": "TypedArray",
|
"__type__": "TypedArray",
|
||||||
"ctor": "Float64Array",
|
"ctor": "Float64Array",
|
||||||
"array": [
|
"array": [
|
||||||
-72.37,
|
15,
|
||||||
150,
|
150,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -2713,7 +2713,7 @@
|
||||||
"__id__": 63
|
"__id__": 63
|
||||||
},
|
},
|
||||||
"_children": [],
|
"_children": [],
|
||||||
"_active": true,
|
"_active": false,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 72
|
"__id__": 72
|
||||||
|
@ -2968,7 +2968,7 @@
|
||||||
"_normalMaterial": null,
|
"_normalMaterial": null,
|
||||||
"_grayMaterial": null,
|
"_grayMaterial": null,
|
||||||
"duration": 0.1,
|
"duration": 0.1,
|
||||||
"zoomScale": 1.2,
|
"zoomScale": 1.1,
|
||||||
"clickEvents": [
|
"clickEvents": [
|
||||||
{
|
{
|
||||||
"__id__": 79
|
"__id__": 79
|
||||||
|
@ -2976,8 +2976,8 @@
|
||||||
],
|
],
|
||||||
"_N$interactable": true,
|
"_N$interactable": true,
|
||||||
"_N$enableAutoGrayEffect": false,
|
"_N$enableAutoGrayEffect": false,
|
||||||
"_N$transition": 0,
|
"_N$transition": 3,
|
||||||
"transition": 0,
|
"transition": 3,
|
||||||
"_N$normalColor": {
|
"_N$normalColor": {
|
||||||
"__type__": "cc.Color",
|
"__type__": "cc.Color",
|
||||||
"r": 255,
|
"r": 255,
|
||||||
|
@ -3134,7 +3134,7 @@
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
1
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"_eulerAngles": {
|
"_eulerAngles": {
|
||||||
|
@ -3365,7 +3365,7 @@
|
||||||
"__type__": "TypedArray",
|
"__type__": "TypedArray",
|
||||||
"ctor": "Float64Array",
|
"ctor": "Float64Array",
|
||||||
"array": [
|
"array": [
|
||||||
-72.37,
|
10,
|
||||||
150,
|
150,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -3409,7 +3409,7 @@
|
||||||
"__id__": 82
|
"__id__": 82
|
||||||
},
|
},
|
||||||
"_children": [],
|
"_children": [],
|
||||||
"_active": true,
|
"_active": false,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 91
|
"__id__": 91
|
||||||
|
@ -3664,7 +3664,7 @@
|
||||||
"_normalMaterial": null,
|
"_normalMaterial": null,
|
||||||
"_grayMaterial": null,
|
"_grayMaterial": null,
|
||||||
"duration": 0.1,
|
"duration": 0.1,
|
||||||
"zoomScale": 1.2,
|
"zoomScale": 1.1,
|
||||||
"clickEvents": [
|
"clickEvents": [
|
||||||
{
|
{
|
||||||
"__id__": 98
|
"__id__": 98
|
||||||
|
@ -3672,8 +3672,8 @@
|
||||||
],
|
],
|
||||||
"_N$interactable": true,
|
"_N$interactable": true,
|
||||||
"_N$enableAutoGrayEffect": false,
|
"_N$enableAutoGrayEffect": false,
|
||||||
"_N$transition": 0,
|
"_N$transition": 3,
|
||||||
"transition": 0,
|
"transition": 3,
|
||||||
"_N$normalColor": {
|
"_N$normalColor": {
|
||||||
"__type__": "cc.Color",
|
"__type__": "cc.Color",
|
||||||
"r": 255,
|
"r": 255,
|
||||||
|
@ -3830,7 +3830,7 @@
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
1
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"_eulerAngles": {
|
"_eulerAngles": {
|
||||||
|
@ -4061,7 +4061,7 @@
|
||||||
"__type__": "TypedArray",
|
"__type__": "TypedArray",
|
||||||
"ctor": "Float64Array",
|
"ctor": "Float64Array",
|
||||||
"array": [
|
"array": [
|
||||||
-72.37,
|
0,
|
||||||
150,
|
150,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -4105,7 +4105,7 @@
|
||||||
"__id__": 101
|
"__id__": 101
|
||||||
},
|
},
|
||||||
"_children": [],
|
"_children": [],
|
||||||
"_active": true,
|
"_active": false,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 110
|
"__id__": 110
|
||||||
|
@ -4360,7 +4360,7 @@
|
||||||
"_normalMaterial": null,
|
"_normalMaterial": null,
|
||||||
"_grayMaterial": null,
|
"_grayMaterial": null,
|
||||||
"duration": 0.1,
|
"duration": 0.1,
|
||||||
"zoomScale": 1.2,
|
"zoomScale": 1.1,
|
||||||
"clickEvents": [
|
"clickEvents": [
|
||||||
{
|
{
|
||||||
"__id__": 117
|
"__id__": 117
|
||||||
|
@ -4368,8 +4368,8 @@
|
||||||
],
|
],
|
||||||
"_N$interactable": true,
|
"_N$interactable": true,
|
||||||
"_N$enableAutoGrayEffect": false,
|
"_N$enableAutoGrayEffect": false,
|
||||||
"_N$transition": 0,
|
"_N$transition": 3,
|
||||||
"transition": 0,
|
"transition": 3,
|
||||||
"_N$normalColor": {
|
"_N$normalColor": {
|
||||||
"__type__": "cc.Color",
|
"__type__": "cc.Color",
|
||||||
"r": 255,
|
"r": 255,
|
||||||
|
@ -4526,7 +4526,7 @@
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
1
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"_eulerAngles": {
|
"_eulerAngles": {
|
||||||
|
@ -4757,7 +4757,7 @@
|
||||||
"__type__": "TypedArray",
|
"__type__": "TypedArray",
|
||||||
"ctor": "Float64Array",
|
"ctor": "Float64Array",
|
||||||
"array": [
|
"array": [
|
||||||
-72.37,
|
0,
|
||||||
150,
|
150,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -4801,7 +4801,7 @@
|
||||||
"__id__": 120
|
"__id__": 120
|
||||||
},
|
},
|
||||||
"_children": [],
|
"_children": [],
|
||||||
"_active": true,
|
"_active": false,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 129
|
"__id__": 129
|
||||||
|
@ -5056,7 +5056,7 @@
|
||||||
"_normalMaterial": null,
|
"_normalMaterial": null,
|
||||||
"_grayMaterial": null,
|
"_grayMaterial": null,
|
||||||
"duration": 0.1,
|
"duration": 0.1,
|
||||||
"zoomScale": 1.2,
|
"zoomScale": 1.1,
|
||||||
"clickEvents": [
|
"clickEvents": [
|
||||||
{
|
{
|
||||||
"__id__": 136
|
"__id__": 136
|
||||||
|
@ -5064,8 +5064,8 @@
|
||||||
],
|
],
|
||||||
"_N$interactable": true,
|
"_N$interactable": true,
|
||||||
"_N$enableAutoGrayEffect": false,
|
"_N$enableAutoGrayEffect": false,
|
||||||
"_N$transition": 0,
|
"_N$transition": 3,
|
||||||
"transition": 0,
|
"transition": 3,
|
||||||
"_N$normalColor": {
|
"_N$normalColor": {
|
||||||
"__type__": "cc.Color",
|
"__type__": "cc.Color",
|
||||||
"r": 255,
|
"r": 255,
|
||||||
|
@ -6942,7 +6942,7 @@
|
||||||
"__type__": "TypedArray",
|
"__type__": "TypedArray",
|
||||||
"ctor": "Float64Array",
|
"ctor": "Float64Array",
|
||||||
"array": [
|
"array": [
|
||||||
-0.255,
|
35.399,
|
||||||
1.584,
|
1.584,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
import Utils from "../../Script/module/Pay/Utils";
|
||||||
import List from "../../Script/module/RankList/List";
|
import List from "../../Script/module/RankList/List";
|
||||||
import NumberToImage from "../../Script/NumberToImage";
|
import NumberToImage from "../../Script/NumberToImage";
|
||||||
|
import { MiniGameSdk } from "../../Script/Sdk/MiniGameSdk";
|
||||||
|
|
||||||
const { ccclass, property } = cc._decorator;
|
const { ccclass, property } = cc._decorator;
|
||||||
|
|
||||||
|
@ -16,19 +18,25 @@ export default class NewClass extends cc.Component {
|
||||||
//金币数量
|
//金币数量
|
||||||
@property(cc.Node)
|
@property(cc.Node)
|
||||||
coin: cc.Node = null;
|
coin: cc.Node = null;
|
||||||
|
|
||||||
|
btn_Touch: boolean = true;
|
||||||
|
onLoad() {
|
||||||
|
this.btn_Touch = true;
|
||||||
|
}
|
||||||
start() {
|
start() {
|
||||||
|
this.btn_Touch = true;
|
||||||
this.openShop();
|
this.openShop();
|
||||||
}
|
}
|
||||||
//打开商店界面
|
//打开商店界面
|
||||||
openShop() {
|
openShop() {
|
||||||
// 商品数据数组
|
// 商品数据数组
|
||||||
const products = [
|
const products = [
|
||||||
{ product_id: "gold_pack_1", name: "金币包1", price: 600, title: "3x2六档金币" },
|
{ product_id: "gold_pack_1", name: "金币包1", price: 600, coin:1200, title: "3x2六档金币" },
|
||||||
{ product_id: "gold_pack_2", name: "金币包2", price: 3600, title: "" },
|
{ product_id: "gold_pack_2", name: "金币包2", price: 3600, coin:8000, title: "" },
|
||||||
{ product_id: "gold_pack_3", name: "金币包3", price: 6800, title: "" },
|
{ product_id: "gold_pack_3", name: "金币包3", price: 6800, coin:16000, title: "" },
|
||||||
{ product_id: "gold_pack_4", name: "金币包4", price: 12800, title: "" },
|
{ product_id: "gold_pack_4", name: "金币包4", price: 12800, coin:32000, title: "" },
|
||||||
{ product_id: "gold_pack_5", name: "金币包5", price: 32800, title: "" },
|
{ product_id: "gold_pack_5", name: "金币包5", price: 32800, coin:100000, title: "" },
|
||||||
{ product_id: "gold_pack_6", name: "金币包6", price: 64800, title: "" },
|
{ product_id: "gold_pack_6", name: "金币包6", price: 64800, coin:240000, title: "" },
|
||||||
];
|
];
|
||||||
for (let i = 1; i <= 6 && i < this.itemList.children.length; i++) {
|
for (let i = 1; i <= 6 && i < this.itemList.children.length; i++) {
|
||||||
const spriteComp = this.itemList.children[i].children[0].getComponent(cc.Sprite);
|
const spriteComp = this.itemList.children[i].children[0].getComponent(cc.Sprite);
|
||||||
|
@ -45,7 +53,7 @@ export default class NewClass extends cc.Component {
|
||||||
NumberToImage.numberToImageNodes(product.price / 100, 25, 20, "cost_", price, false)
|
NumberToImage.numberToImageNodes(product.price / 100, 25, 20, "cost_", price, false)
|
||||||
}
|
}
|
||||||
if (title && product) {
|
if (title && product) {
|
||||||
NumberToImage.numberToImageNodes(product.price / 100, 40, 25, "scoin_", title, false)
|
NumberToImage.numberToImageNodes(product.coin, 40, 25, "scoin_", title, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
|
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
|
||||||
|
@ -61,7 +69,66 @@ export default class NewClass extends cc.Component {
|
||||||
//点击充值购买
|
//点击充值购买
|
||||||
|
|
||||||
buyProduct(event, customData) {
|
buyProduct(event, customData) {
|
||||||
|
if(!this.btn_Touch){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.btn_Touch = false;
|
||||||
const productId = customData;
|
const productId = customData;
|
||||||
|
let id = "10011";
|
||||||
|
let price = 100;
|
||||||
|
let count = 1;
|
||||||
|
id = productId;
|
||||||
|
switch(productId){
|
||||||
|
case "gold_pack_1":
|
||||||
|
price = 100;
|
||||||
|
break;
|
||||||
|
case "gold_pack_2":
|
||||||
|
price = 100;
|
||||||
|
break;
|
||||||
|
case "gold_pack_3":
|
||||||
|
price = 100;
|
||||||
|
break;
|
||||||
|
case "gold_pack_4":
|
||||||
|
price = 100;
|
||||||
|
break;
|
||||||
|
case "gold_pack_5":
|
||||||
|
price = 100;
|
||||||
|
break;
|
||||||
|
case "gold_pack_6":
|
||||||
|
price = 200;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
console.log("获得商品id:",id,count,price);
|
||||||
|
Utils.buyProp(id,count,price,(res)=>{
|
||||||
|
console.log("获得充值结果",res);
|
||||||
|
if(res == null){
|
||||||
|
MiniGameSdk.API.showToast("网络异常,充值失败请稍后再试");
|
||||||
|
this.btn_Touch = true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Utils.getPayInfo((data) =>{
|
||||||
|
console.log("获得轮训结果:",data);
|
||||||
|
if(data.data.pay_state == 1){
|
||||||
|
this.btn_Touch = true;
|
||||||
|
MiniGameSdk.API.showToast("取消充值");
|
||||||
|
cc.fx.GameTool.shopBuy(productId);
|
||||||
|
console.log("充值取消未获得金币");
|
||||||
|
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
|
||||||
|
this.node.parent.getComponent("JiaZai").updateCoin();
|
||||||
|
}
|
||||||
|
else if(data.data.pay_state == 2){
|
||||||
|
this.btn_Touch = true;
|
||||||
|
MiniGameSdk.API.showToast("充值成功");
|
||||||
|
cc.fx.GameTool.shopBuy(productId);
|
||||||
|
console.log("充值成功获得金币");
|
||||||
|
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
|
||||||
|
this.node.parent.getComponent("JiaZai").updateCoin();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
// update (dt) {}
|
// update (dt) {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user