Compare commits
No commits in common. "0dc35480f4796211a3e66e3fc3dfd97ac781999e" and "a661ab464656023b83f84680a67474dece494742" have entirely different histories.
0dc35480f4
...
a661ab4646
|
@ -11012,7 +11012,7 @@
|
|||
"__id__": 299
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_active": false,
|
||||
"_components": [],
|
||||
"_prefab": null,
|
||||
"_opacity": 255,
|
||||
|
|
|
@ -2434,7 +2434,7 @@
|
|||
"__type__": "TypedArray",
|
||||
"ctor": "Float64Array",
|
||||
"array": [
|
||||
19.091,
|
||||
-0.255,
|
||||
1.584,
|
||||
0,
|
||||
0,
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
// Learn life-cycle callbacks:
|
||||
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
|
||||
|
||||
import Utils from "./module/Pay/Utils";
|
||||
import { MiniGameManager } from "./Sdk/MiniGameManager";
|
||||
import { MiniGameSdk } from "./Sdk/MiniGameSdk";
|
||||
|
||||
|
@ -212,9 +211,6 @@ export default class GameManager extends cc.Component {
|
|||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
MiniGameSdk.API.shushu_Init();
|
||||
Utils.getUserInfo((data)=>{
|
||||
console.log("登陆成功",data);
|
||||
});
|
||||
let levelInfo = cc.fx.StorageMessage.getStorage("level");
|
||||
//旧的读取数据设置数据方法,以强联网为主
|
||||
if (levelInfo == undefined || levelInfo == "" || levelInfo == null) {
|
||||
|
|
|
@ -9,7 +9,6 @@ import GameManager from "./GameManager";
|
|||
import NumberToImage from "./NumberToImage";
|
||||
import { MiniGameSdk } from "./Sdk/MiniGameSdk";
|
||||
import { LQCollideSystem } from "./lq_collide_system/lq_collide_system";
|
||||
import Utils from "./module/Pay/Utils";
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
@ccclass
|
||||
|
@ -111,21 +110,21 @@ export default class NewClass extends cc.Component {
|
|||
|
||||
}
|
||||
|
||||
|
||||
//打开heath弹窗,创建预制体
|
||||
openHeath() {
|
||||
let health = cc.instantiate(this.health);
|
||||
this.node.addChild(health);
|
||||
let heathPop =health.getComponent("heathnum").coin ;
|
||||
heathPop.scale = 0.7;
|
||||
let swich = health.getComponent("heathnum").switchNode;
|
||||
let spriteFrames = health.getComponent("heathnum").spriteFrames;
|
||||
if(cc.fx.GameConfig.GM_INFO.hp <= 0) {
|
||||
swich.getComponent(cc.Sprite).spriteFrame =spriteFrames[1];
|
||||
let health = cc.instantiate(this.health);
|
||||
this.node.addChild(health);
|
||||
let heathPop =health.getComponent("heathnum").coin ;
|
||||
heathPop.scale = 0.7;
|
||||
let swich = health.getComponent("heathnum").switchNode;
|
||||
let spriteFrames = health.getComponent("heathnum").spriteFrames;
|
||||
if(cc.fx.GameConfig.GM_INFO.hp <= 0) {
|
||||
swich.getComponent(cc.Sprite).spriteFrame =spriteFrames[1];
|
||||
}else {
|
||||
swich.getComponent(cc.Sprite).spriteFrame = spriteFrames[0];
|
||||
}
|
||||
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.hp, 40, 20, "time_", heathPop, true);
|
||||
|
||||
}
|
||||
|
||||
//开始倒计时
|
||||
|
@ -233,8 +232,50 @@ export default class NewClass extends cc.Component {
|
|||
|
||||
clickShop() {
|
||||
// 假设已经获取到了 userId 和 productId
|
||||
|
||||
|
||||
const userId = cc.fx.GameConfig.GM_INFO.openid;
|
||||
const productId = '1';
|
||||
console.log("即将创建createorder");
|
||||
//@ts-ignore
|
||||
wx.cloud.callFunction({
|
||||
name: "createOrder",
|
||||
data: {
|
||||
"userId": userId,
|
||||
"productId": productId,
|
||||
},
|
||||
success: (res) => {
|
||||
// 取得云函数返回的订单信息
|
||||
console.log("createOrder结果:", res.result);
|
||||
const payment = res.result.paymentResult.payment;
|
||||
console.log("payment:", payment);
|
||||
// 调起微信客户端支付
|
||||
//@ts-ignore
|
||||
// 调起微信客户端支付
|
||||
//@ts-ignore
|
||||
wx.requestPayment({
|
||||
// 时间戳,从 1970 年 1 月 1 日 00:00:00 至今的秒数,即当前的时间
|
||||
timeStamp: payment.timeStamp,
|
||||
// 随机字符串,长度为32个字符以下
|
||||
nonceStr: payment.nonceStr,
|
||||
// 统一下单接口返回的 prepay_id 参数值
|
||||
package: payment.package,
|
||||
// 签名算法,暂支持 MD5、HMAC-SHA256
|
||||
signType: payment.signType || 'MD5',
|
||||
// 支付签名
|
||||
paySign: payment.paySign,
|
||||
success(res) {
|
||||
/* 成功回调 */
|
||||
console.log("支付成功", res);
|
||||
},
|
||||
fail(res) {
|
||||
/* 失败回调 */
|
||||
console.log("支付失败", res);
|
||||
},
|
||||
complete(res) {
|
||||
console.log("支付完成", res);
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -288,11 +329,6 @@ export default class NewClass extends cc.Component {
|
|||
this.node.getChildByName("Stamina").active = false;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// update (dt) {}
|
||||
}
|
||||
|
|
|
@ -30,33 +30,18 @@ export default class NumberToImage extends cc.Component {
|
|||
else if (number < 10) cha = posX
|
||||
if (targetNode.children.length > 0)
|
||||
targetNode.removeAllChildren();
|
||||
|
||||
const digitNodes: cc.Node[] = [];
|
||||
for (let i = 0; i < numStr.length; i++) {
|
||||
const digit = parseInt(numStr[i], 10);
|
||||
const node = new cc.Node();
|
||||
const sprite = node.addComponent(cc.Sprite);
|
||||
// debugger;
|
||||
sprite.spriteFrame = this.font._spriteFrames[name + digit + ""];
|
||||
digitNodes.push(node);
|
||||
// 将节点添加到目标节点下
|
||||
node.x = i * width + cha;
|
||||
node.parent = targetNode;
|
||||
}
|
||||
|
||||
// 计算总宽度
|
||||
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.parent = targetNode;
|
||||
}
|
||||
targetNode.x = targetNode.x - targetNode.children.length * (width - 15) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"ver": "1.1.3",
|
||||
"uuid": "6fcc6549-a36e-45d2-a845-79719c1be068",
|
||||
"importer": "folder",
|
||||
"isBundle": false,
|
||||
"bundleName": "",
|
||||
"priority": 1,
|
||||
"compressionType": {},
|
||||
"optimizeHotUpdate": {},
|
||||
"inlineSpriteFrames": {},
|
||||
"isRemoteBundle": {},
|
||||
"subMetas": {}
|
||||
}
|
|
@ -1,375 +0,0 @@
|
|||
export default class Utils {
|
||||
static uid:string="";
|
||||
static session_key="";
|
||||
static appid:string="";
|
||||
static openid:string="";
|
||||
static outTradeNo:string ="";
|
||||
static httpip:string=`https://laf.nika4games.com/`;
|
||||
//#region 支付
|
||||
/**获取用户信息*/
|
||||
static getUserInfo(callBack){
|
||||
wx.login({
|
||||
success (res) {
|
||||
console.log("登录成功");
|
||||
console.log(res);
|
||||
if (res.code) {
|
||||
Utils.POST("login",{code:res.code},ret=>{
|
||||
console.log("请求结果:");
|
||||
console.log(ret);
|
||||
Utils.openid=ret.data.openid;
|
||||
Utils.session_key=ret.data.session_key;
|
||||
Utils.uid=ret.data._id;
|
||||
callBack(Utils.uid);
|
||||
})
|
||||
} else {
|
||||
console.log('登录失败!' + res.errMsg)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**道具直购接口*/
|
||||
static buyProp(id,count,price,callBack){
|
||||
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){
|
||||
Utils.outTradeNo=res.data.outTradeNo;
|
||||
//@ts-ignore
|
||||
wx.requestMidasPaymentGameItem({
|
||||
signData:res.data.signData,
|
||||
paySig: res.data.paySig,
|
||||
signature: res.data.signature,
|
||||
success(res, errCode) {
|
||||
console.log('成功', res, errCode);
|
||||
callBack(res);
|
||||
},
|
||||
fail({errMsg,errCode}) {
|
||||
console.error('失败');
|
||||
console.error(errMsg, errCode)
|
||||
callBack(null);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
static getPayInfo(callBack) {
|
||||
const delays = [1000, 10000, 30000, 60000, 60000]; // 延迟时间数组
|
||||
let attempt = 0; // 轮询次数
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
/**跳转客服*/
|
||||
static GoKEFu(){
|
||||
// 打开客服会话
|
||||
//wx.navigateTo({ url: '/pages/webview?url=https://xxx.com/customer' });
|
||||
//@ts-ignore
|
||||
wx.openCustomerServiceConversation({
|
||||
sessionFrom: '你好这是充值中心', // 会话来源(可选)
|
||||
showMessageCard: true, // 是否展示消息卡片
|
||||
sendMessageTitle:"扫描二维码进行充值",
|
||||
sendMessageImg:"https://img2.huashi6.com/images/resource/thumbnail/2023/07/23/193722_24254930385.jpg?imageMogr2/quality/100/interlace/1/thumbnail/2000x%3E",
|
||||
success() {
|
||||
console.log('客服会话已打开');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 微信云
|
||||
static initServer(){
|
||||
if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
||||
//@ts-ignore
|
||||
wx.cloud.init({
|
||||
env: 'cloudbase-1gl7iex89268f11e'
|
||||
})
|
||||
}
|
||||
|
||||
static getUserCode(){
|
||||
//@ts-ignore
|
||||
wx.login({
|
||||
success (res) {
|
||||
console.log("登录成功");
|
||||
console.log(res);
|
||||
if (res.code) {
|
||||
//@ts-ignore
|
||||
wx.cloud.callFunction({
|
||||
// 云函数名称
|
||||
name: 'login',
|
||||
// 传给云函数的参数
|
||||
data: {
|
||||
code:res.code,
|
||||
},
|
||||
success: function(ret) {
|
||||
console.log("请求成功");
|
||||
console.log("请求结果:");
|
||||
console.log(ret);
|
||||
Utils.openid=ret.data.openid;
|
||||
Utils.session_key=ret.data.session_key;
|
||||
Utils.uid=ret.data._id;
|
||||
},
|
||||
fail:function(res){
|
||||
console.log("请求失败");
|
||||
console.log(res);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log('登录失败!' + res.errMsg)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
static PayOder(){
|
||||
if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
||||
//@ts-ignore
|
||||
wx.cloud.callFunction({
|
||||
// 云函数名称
|
||||
name: 'userPayOrder',
|
||||
// 传给云函数的参数
|
||||
data: {
|
||||
itemid:"10011",
|
||||
itemCount:1,
|
||||
itemPrice:100
|
||||
},
|
||||
success: function(res) {
|
||||
console.log("请求成功");
|
||||
console.log(res)
|
||||
if(res.result.code==1){
|
||||
Utils.outTradeNo=res.result.data.outTradeNo;
|
||||
console.log("订单号:"+Utils.outTradeNo);
|
||||
//@ts-ignore
|
||||
wx.requestMidasPaymentGameItem({
|
||||
signData:res.result.data.signData,
|
||||
paySig: res.result.data.paySig,
|
||||
signature: res.result.data.signature,
|
||||
success(res, errCode) {
|
||||
console.log('成功', res, errCode);
|
||||
},
|
||||
fail({errMsg,errCode}) {
|
||||
console.error('失败');
|
||||
console.error(errMsg, errCode)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
fail:function(res){
|
||||
console.log("请求失败");
|
||||
console.log(res);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
static getPayInfo1(callBack){
|
||||
if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
||||
//@ts-ignore
|
||||
wx.cloud.callFunction({
|
||||
// 云函数名称
|
||||
name: 'userGetPayState',
|
||||
// 传给云函数的参数
|
||||
data: {
|
||||
outTradeNo:Utils.outTradeNo
|
||||
},
|
||||
success: function(res) {
|
||||
console.log("请求成功");
|
||||
console.log(res)
|
||||
callBack("成功");
|
||||
},
|
||||
fail:function(res){
|
||||
console.log("请求失败");
|
||||
console.log(res);
|
||||
callBack("失败");
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
static toke(){
|
||||
if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
||||
//@ts-ignore
|
||||
wx.cloud.callFunction({
|
||||
// 云函数名称
|
||||
name: 'uerToken',
|
||||
// 传给云函数的参数
|
||||
data: {
|
||||
|
||||
},
|
||||
success: function(res) {
|
||||
console.log("请求成功");
|
||||
console.log(res)
|
||||
},
|
||||
fail:function(res){
|
||||
console.log("请求失败");
|
||||
console.log(res);
|
||||
}
|
||||
})
|
||||
}
|
||||
//#endregion
|
||||
|
||||
|
||||
/**
|
||||
* POST请求
|
||||
*
|
||||
* @static
|
||||
* @param {*} url
|
||||
* @param {object} [param={}]
|
||||
* @param {*} callback
|
||||
* @memberof HttpUtil
|
||||
*/
|
||||
public static POST(url, param:object|any,callback) {
|
||||
var xhr = cc.loader.getXMLHttpRequest();
|
||||
let dataStr = '';
|
||||
Object.keys(param).forEach(key => {
|
||||
dataStr += key + '=' + encodeURIComponent(param[key]) + '&';
|
||||
})
|
||||
if (dataStr !== '') {
|
||||
dataStr = dataStr.substr(0, dataStr.lastIndexOf('&'));
|
||||
}
|
||||
url=this.httpip+url;
|
||||
console.log("请求地址:"+url);
|
||||
xhr.open("POST", url, true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4) {
|
||||
let response:any = xhr.responseText;
|
||||
if (xhr.status >= 200 && xhr.status < 300) {
|
||||
let httpStatus = xhr.statusText;
|
||||
// callback(true, JSON.parse(response));
|
||||
try{
|
||||
response=JSON.parse(response);
|
||||
}catch{
|
||||
response={data:"数据有误",code:0};
|
||||
}
|
||||
callback(response);
|
||||
|
||||
} else {
|
||||
callback({data:"网络请求失败,请检查网络连接",code:0});
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.send(dataStr);
|
||||
}
|
||||
|
||||
static http_sendRequest(path,data,handler,extraUrl=null){
|
||||
let xhr=cc.loader.getXMLHttpRequest();
|
||||
xhr.timeout=5000;//超时时间
|
||||
if(data==null){
|
||||
data={};
|
||||
}
|
||||
// if(exports.token){//数据中加入安全密匙
|
||||
// data.token=exports.token;
|
||||
// }
|
||||
if(extraUrl==null){
|
||||
//@ts-ignore
|
||||
if(Utils.isDebug){
|
||||
extraUrl="http://localhost:9003";
|
||||
}else{
|
||||
extraUrl=this.httpip;
|
||||
}
|
||||
|
||||
}
|
||||
//解析请求路由以及格式化请求参数
|
||||
let sendtext="?";
|
||||
for(let k in data){
|
||||
if(sendtext !="?"){
|
||||
sendtext +="&";
|
||||
}
|
||||
sendtext +=(k +'='+data[k]);
|
||||
}
|
||||
//组装完整的URL
|
||||
let requestURL=extraUrl+"/"+path+encodeURI(sendtext);
|
||||
// console.log("发送请求:");
|
||||
// console.log(requestURL);
|
||||
//发送请求 Get形式发送请求
|
||||
xhr.open("GET",requestURL,true);
|
||||
if (cc.sys.isNative) {//如果是手机就设置请求头
|
||||
xhr.setRequestHeader("Accept-Encoding", "gzip,deflate");
|
||||
}
|
||||
//计时判断是否超时
|
||||
let hasRetried=false;
|
||||
let timer=setTimeout(function(){
|
||||
//xhr.hasRetried=true;
|
||||
hasRetried=true;
|
||||
xhr.abort();
|
||||
console.log("http timeOut......");
|
||||
retryFun();
|
||||
},5000);
|
||||
//重新发送请求
|
||||
let retryFun=function(){
|
||||
Utils.http_sendRequest(path,data,handler,extraUrl);
|
||||
}
|
||||
//监听反馈
|
||||
xhr.onreadystatechange=function(){
|
||||
clearTimeout(timer);
|
||||
if(xhr.readyState===4&&(xhr.status >= 200 && xhr.status < 300)){
|
||||
let ret=null;
|
||||
let respText=xhr.responseText;
|
||||
try{
|
||||
ret=JSON.parse(respText);
|
||||
}catch(e){
|
||||
console.log("http error:" +e);
|
||||
ret={
|
||||
code:1,
|
||||
msg:e
|
||||
}
|
||||
}
|
||||
if(handler){
|
||||
handler(ret);
|
||||
}
|
||||
handler=null;
|
||||
}else if(xhr.readyState===4){
|
||||
// if(xhr.hasRetried){
|
||||
// return;
|
||||
// }
|
||||
if(hasRetried){
|
||||
return;
|
||||
}
|
||||
console.log('other readystate =='+xhr.readyState + ', status:' + xhr.status);
|
||||
if(xhr.readyState==4&&xhr.status==0){
|
||||
handler({
|
||||
err:1,
|
||||
msg:"网络连接失败,请稍后再试"
|
||||
});
|
||||
return;
|
||||
}
|
||||
setTimeout(function(){
|
||||
retryFun();
|
||||
},5000);
|
||||
}else{
|
||||
//console.log('other readystate:' + xhr.readyState + ', status:' + xhr.status);
|
||||
}
|
||||
}
|
||||
try{
|
||||
xhr.send();
|
||||
}catch(e){
|
||||
retryFun();
|
||||
}
|
||||
return xhr;
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"ver": "1.1.0",
|
||||
"uuid": "974132c6-ae8f-4a31-95c8-d525a2310abb",
|
||||
"importer": "typescript",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
|
@ -821,37 +821,7 @@ 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 month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
|
|
|
@ -1046,7 +1046,7 @@
|
|||
1,
|
||||
1,
|
||||
1,
|
||||
0
|
||||
1
|
||||
]
|
||||
},
|
||||
"_eulerAngles": {
|
||||
|
@ -1277,7 +1277,7 @@
|
|||
"__type__": "TypedArray",
|
||||
"ctor": "Float64Array",
|
||||
"array": [
|
||||
15,
|
||||
-72.37,
|
||||
150,
|
||||
0,
|
||||
0,
|
||||
|
@ -1321,7 +1321,7 @@
|
|||
"__id__": 25
|
||||
},
|
||||
"_children": [],
|
||||
"_active": false,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 34
|
||||
|
@ -1576,7 +1576,7 @@
|
|||
"_normalMaterial": null,
|
||||
"_grayMaterial": null,
|
||||
"duration": 0.1,
|
||||
"zoomScale": 1.1,
|
||||
"zoomScale": 1.2,
|
||||
"clickEvents": [
|
||||
{
|
||||
"__id__": 41
|
||||
|
@ -1584,8 +1584,8 @@
|
|||
],
|
||||
"_N$interactable": true,
|
||||
"_N$enableAutoGrayEffect": false,
|
||||
"_N$transition": 3,
|
||||
"transition": 3,
|
||||
"_N$transition": 0,
|
||||
"transition": 0,
|
||||
"_N$normalColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
|
@ -1742,7 +1742,7 @@
|
|||
1,
|
||||
1,
|
||||
1,
|
||||
0
|
||||
1
|
||||
]
|
||||
},
|
||||
"_eulerAngles": {
|
||||
|
@ -1973,7 +1973,7 @@
|
|||
"__type__": "TypedArray",
|
||||
"ctor": "Float64Array",
|
||||
"array": [
|
||||
20,
|
||||
-72.37,
|
||||
150,
|
||||
0,
|
||||
0,
|
||||
|
@ -2017,7 +2017,7 @@
|
|||
"__id__": 44
|
||||
},
|
||||
"_children": [],
|
||||
"_active": false,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 53
|
||||
|
@ -2272,7 +2272,7 @@
|
|||
"_normalMaterial": null,
|
||||
"_grayMaterial": null,
|
||||
"duration": 0.1,
|
||||
"zoomScale": 1.1,
|
||||
"zoomScale": 1.2,
|
||||
"clickEvents": [
|
||||
{
|
||||
"__id__": 60
|
||||
|
@ -2280,8 +2280,8 @@
|
|||
],
|
||||
"_N$interactable": true,
|
||||
"_N$enableAutoGrayEffect": false,
|
||||
"_N$transition": 3,
|
||||
"transition": 3,
|
||||
"_N$transition": 0,
|
||||
"transition": 0,
|
||||
"_N$normalColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
|
@ -2438,7 +2438,7 @@
|
|||
1,
|
||||
1,
|
||||
1,
|
||||
0
|
||||
1
|
||||
]
|
||||
},
|
||||
"_eulerAngles": {
|
||||
|
@ -2669,7 +2669,7 @@
|
|||
"__type__": "TypedArray",
|
||||
"ctor": "Float64Array",
|
||||
"array": [
|
||||
15,
|
||||
-72.37,
|
||||
150,
|
||||
0,
|
||||
0,
|
||||
|
@ -2713,7 +2713,7 @@
|
|||
"__id__": 63
|
||||
},
|
||||
"_children": [],
|
||||
"_active": false,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 72
|
||||
|
@ -2968,7 +2968,7 @@
|
|||
"_normalMaterial": null,
|
||||
"_grayMaterial": null,
|
||||
"duration": 0.1,
|
||||
"zoomScale": 1.1,
|
||||
"zoomScale": 1.2,
|
||||
"clickEvents": [
|
||||
{
|
||||
"__id__": 79
|
||||
|
@ -2976,8 +2976,8 @@
|
|||
],
|
||||
"_N$interactable": true,
|
||||
"_N$enableAutoGrayEffect": false,
|
||||
"_N$transition": 3,
|
||||
"transition": 3,
|
||||
"_N$transition": 0,
|
||||
"transition": 0,
|
||||
"_N$normalColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
|
@ -3134,7 +3134,7 @@
|
|||
1,
|
||||
1,
|
||||
1,
|
||||
0
|
||||
1
|
||||
]
|
||||
},
|
||||
"_eulerAngles": {
|
||||
|
@ -3365,7 +3365,7 @@
|
|||
"__type__": "TypedArray",
|
||||
"ctor": "Float64Array",
|
||||
"array": [
|
||||
10,
|
||||
-72.37,
|
||||
150,
|
||||
0,
|
||||
0,
|
||||
|
@ -3409,7 +3409,7 @@
|
|||
"__id__": 82
|
||||
},
|
||||
"_children": [],
|
||||
"_active": false,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 91
|
||||
|
@ -3664,7 +3664,7 @@
|
|||
"_normalMaterial": null,
|
||||
"_grayMaterial": null,
|
||||
"duration": 0.1,
|
||||
"zoomScale": 1.1,
|
||||
"zoomScale": 1.2,
|
||||
"clickEvents": [
|
||||
{
|
||||
"__id__": 98
|
||||
|
@ -3672,8 +3672,8 @@
|
|||
],
|
||||
"_N$interactable": true,
|
||||
"_N$enableAutoGrayEffect": false,
|
||||
"_N$transition": 3,
|
||||
"transition": 3,
|
||||
"_N$transition": 0,
|
||||
"transition": 0,
|
||||
"_N$normalColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
|
@ -3830,7 +3830,7 @@
|
|||
1,
|
||||
1,
|
||||
1,
|
||||
0
|
||||
1
|
||||
]
|
||||
},
|
||||
"_eulerAngles": {
|
||||
|
@ -4061,7 +4061,7 @@
|
|||
"__type__": "TypedArray",
|
||||
"ctor": "Float64Array",
|
||||
"array": [
|
||||
0,
|
||||
-72.37,
|
||||
150,
|
||||
0,
|
||||
0,
|
||||
|
@ -4105,7 +4105,7 @@
|
|||
"__id__": 101
|
||||
},
|
||||
"_children": [],
|
||||
"_active": false,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 110
|
||||
|
@ -4360,7 +4360,7 @@
|
|||
"_normalMaterial": null,
|
||||
"_grayMaterial": null,
|
||||
"duration": 0.1,
|
||||
"zoomScale": 1.1,
|
||||
"zoomScale": 1.2,
|
||||
"clickEvents": [
|
||||
{
|
||||
"__id__": 117
|
||||
|
@ -4368,8 +4368,8 @@
|
|||
],
|
||||
"_N$interactable": true,
|
||||
"_N$enableAutoGrayEffect": false,
|
||||
"_N$transition": 3,
|
||||
"transition": 3,
|
||||
"_N$transition": 0,
|
||||
"transition": 0,
|
||||
"_N$normalColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
|
@ -4526,7 +4526,7 @@
|
|||
1,
|
||||
1,
|
||||
1,
|
||||
0
|
||||
1
|
||||
]
|
||||
},
|
||||
"_eulerAngles": {
|
||||
|
@ -4757,7 +4757,7 @@
|
|||
"__type__": "TypedArray",
|
||||
"ctor": "Float64Array",
|
||||
"array": [
|
||||
0,
|
||||
-72.37,
|
||||
150,
|
||||
0,
|
||||
0,
|
||||
|
@ -4801,7 +4801,7 @@
|
|||
"__id__": 120
|
||||
},
|
||||
"_children": [],
|
||||
"_active": false,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 129
|
||||
|
@ -5056,7 +5056,7 @@
|
|||
"_normalMaterial": null,
|
||||
"_grayMaterial": null,
|
||||
"duration": 0.1,
|
||||
"zoomScale": 1.1,
|
||||
"zoomScale": 1.2,
|
||||
"clickEvents": [
|
||||
{
|
||||
"__id__": 136
|
||||
|
@ -5064,8 +5064,8 @@
|
|||
],
|
||||
"_N$interactable": true,
|
||||
"_N$enableAutoGrayEffect": false,
|
||||
"_N$transition": 3,
|
||||
"transition": 3,
|
||||
"_N$transition": 0,
|
||||
"transition": 0,
|
||||
"_N$normalColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
|
@ -6942,7 +6942,7 @@
|
|||
"__type__": "TypedArray",
|
||||
"ctor": "Float64Array",
|
||||
"array": [
|
||||
35.399,
|
||||
-0.255,
|
||||
1.584,
|
||||
0,
|
||||
0,
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import Utils from "../../Script/module/Pay/Utils";
|
||||
import List from "../../Script/module/RankList/List";
|
||||
import NumberToImage from "../../Script/NumberToImage";
|
||||
import { MiniGameSdk } from "../../Script/Sdk/MiniGameSdk";
|
||||
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
|
@ -18,25 +16,19 @@ export default class NewClass extends cc.Component {
|
|||
//金币数量
|
||||
@property(cc.Node)
|
||||
coin: cc.Node = null;
|
||||
|
||||
btn_Touch: boolean = true;
|
||||
onLoad() {
|
||||
this.btn_Touch = true;
|
||||
}
|
||||
start() {
|
||||
this.btn_Touch = true;
|
||||
this.openShop();
|
||||
}
|
||||
//打开商店界面
|
||||
openShop() {
|
||||
// 商品数据数组
|
||||
const products = [
|
||||
{ product_id: "gold_pack_1", name: "金币包1", price: 600, coin:1200, title: "3x2六档金币" },
|
||||
{ product_id: "gold_pack_2", name: "金币包2", price: 3600, coin:8000, title: "" },
|
||||
{ product_id: "gold_pack_3", name: "金币包3", price: 6800, coin:16000, title: "" },
|
||||
{ product_id: "gold_pack_4", name: "金币包4", price: 12800, coin:32000, title: "" },
|
||||
{ product_id: "gold_pack_5", name: "金币包5", price: 32800, coin:100000, title: "" },
|
||||
{ product_id: "gold_pack_6", name: "金币包6", price: 64800, coin:240000, title: "" },
|
||||
{ product_id: "gold_pack_1", name: "金币包1", price: 600, title: "3x2六档金币" },
|
||||
{ product_id: "gold_pack_2", name: "金币包2", price: 3600, title: "" },
|
||||
{ product_id: "gold_pack_3", name: "金币包3", price: 6800, title: "" },
|
||||
{ product_id: "gold_pack_4", name: "金币包4", price: 12800, title: "" },
|
||||
{ product_id: "gold_pack_5", name: "金币包5", price: 32800, title: "" },
|
||||
{ product_id: "gold_pack_6", name: "金币包6", price: 64800, title: "" },
|
||||
];
|
||||
for (let i = 1; i <= 6 && i < this.itemList.children.length; i++) {
|
||||
const spriteComp = this.itemList.children[i].children[0].getComponent(cc.Sprite);
|
||||
|
@ -53,7 +45,7 @@ export default class NewClass extends cc.Component {
|
|||
NumberToImage.numberToImageNodes(product.price / 100, 25, 20, "cost_", price, false)
|
||||
}
|
||||
if (title && product) {
|
||||
NumberToImage.numberToImageNodes(product.coin, 40, 25, "scoin_", title, true)
|
||||
NumberToImage.numberToImageNodes(product.price / 100, 40, 25, "scoin_", title, false)
|
||||
}
|
||||
}
|
||||
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
|
||||
|
@ -69,66 +61,7 @@ export default class NewClass extends cc.Component {
|
|||
//点击充值购买
|
||||
|
||||
buyProduct(event, customData) {
|
||||
if(!this.btn_Touch){
|
||||
return;
|
||||
}
|
||||
this.btn_Touch = false;
|
||||
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) {}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user