|
|
@@ -3,6 +3,7 @@ var AConfig = require('../Config');
|
|
|
|
|
|
import utils from "../Network/netUtils";
|
|
|
import GameNet from "../Network/GameNet"
|
|
|
+import gameToast from "../Network/gameToast"
|
|
|
|
|
|
//全局数据类
|
|
|
cc.Class({
|
|
|
@@ -1035,32 +1036,32 @@ cc.Class({
|
|
|
// "data": {
|
|
|
// "seed": [
|
|
|
// {
|
|
|
- // amount: 0
|
|
|
- // createTime: "2022-01-10 16:45:18"
|
|
|
- // harvestCount: 2500
|
|
|
- // harvestName: "大白菜"
|
|
|
- // harvestQuantity: 2500
|
|
|
- // id: 1
|
|
|
- // mallType: "0"
|
|
|
- // maturity: 100
|
|
|
- // name: "白菜种子"
|
|
|
- // picture: null
|
|
|
- // planting: 100
|
|
|
- // priceCnt: 99.99
|
|
|
- // priceSnb: 495.99
|
|
|
- // updateTime: "2022-01-10 16:45:26"
|
|
|
- // withered: 200
|
|
|
+ // amount: 0
|
|
|
+ // createTime: "2022-01-10 16:45:18"
|
|
|
+ // harvestCount: 2500
|
|
|
+ // harvestName: "大白菜"
|
|
|
+ // harvestQuantity: 2500
|
|
|
+ // id: 1
|
|
|
+ // mallType: "0"
|
|
|
+ // maturity: 100
|
|
|
+ // name: "白菜种子"
|
|
|
+ // picture: null
|
|
|
+ // planting: 100
|
|
|
+ // priceCnt: 99.99
|
|
|
+ // priceSnb: 495.99
|
|
|
+ // updateTime: "2022-01-10 16:45:26"
|
|
|
+ // withered: 200
|
|
|
// }
|
|
|
// ],
|
|
|
// "fruit": [
|
|
|
// {
|
|
|
- // createTime: "2022-01-10 16:45:18"
|
|
|
- // id: 1
|
|
|
- // name: "白菜"
|
|
|
- // picture: null
|
|
|
- // priceCnt: 9.99
|
|
|
- // priceSnb: 99
|
|
|
- // updateTime: "2022-01-10 16:45:26"
|
|
|
+ // createTime: "2022-01-10 16:45:18"
|
|
|
+ // id: 1
|
|
|
+ // name: "白菜"
|
|
|
+ // picture: null
|
|
|
+ // priceCnt: 9.99
|
|
|
+ // priceSnb: 99
|
|
|
+ // updateTime: "2022-01-10 16:45:26"
|
|
|
// }
|
|
|
// ]
|
|
|
// },
|
|
|
@@ -1070,14 +1071,14 @@ cc.Class({
|
|
|
},
|
|
|
//种植种子
|
|
|
// data:{landId:1,seedId:1}
|
|
|
- onPlant(data,callback) {
|
|
|
+ onPlant(data, callback) {
|
|
|
utils.get(utils.api.plant, data, (res, vaule) => {
|
|
|
callback(res, vaule);
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//收取果实
|
|
|
- onAddFruit(data,callback) {
|
|
|
+ onAddFruit(data, callback) {
|
|
|
utils.post(utils.api.addFruit, data, (res, vaule) => {
|
|
|
callback(res, vaule);
|
|
|
})
|
|
|
@@ -1090,12 +1091,20 @@ cc.Class({
|
|
|
* @param {*} payType 支付类型,1购买土地租凭, 2自然灾害防护,3野兽防护
|
|
|
* @param {*} itemType 操作物品的id
|
|
|
*/
|
|
|
- payCNT(cntAmount,payType,itemType,callback) {
|
|
|
- if(!GlobalD.dapp){
|
|
|
+ payCNT(cntAmount, payType, itemType, callback) {
|
|
|
+ if (!GlobalD.dapp) {
|
|
|
console.warn("GlobalD.dapp未初始化,不能payCNT!");
|
|
|
return;
|
|
|
}
|
|
|
- GlobalD.dapp.payCnt(cntAmount, payType,itemType).then((data) => {
|
|
|
+ //
|
|
|
+ if (GlobalD.GameData.GetCNT() < cntAmount) {
|
|
|
+ console.log("cnt 不足,GetCNT:", GlobalD.GameData.GetCNT(), "消费的cntAmount", cntAmount);
|
|
|
+ gameToast.getInstance().show(cc.find("Canvas/UICamera"), "CNT不足!", 2, () => {
|
|
|
+ console.log("finish toast!");
|
|
|
+ }, this);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ GlobalD.dapp.payCnt(cntAmount, payType, itemType).then((data) => {
|
|
|
const [err, tx] = data;
|
|
|
if (err === null) {
|
|
|
// TODO 成功, 支付为链上操作,需要提供回调接口给这边服务端确认交易成功后修改购买订单结果
|
|
|
@@ -1104,7 +1113,7 @@ cc.Class({
|
|
|
console.log(err)
|
|
|
}
|
|
|
|
|
|
- if(callback){
|
|
|
+ if (callback) {
|
|
|
callback(data);
|
|
|
}
|
|
|
});
|