Переглянути джерело

Merge branch 'qqplay-1.0' of http://svn.ouj.com:3000/DWG/budingGame into qqplay-1.0

Roy 6 роки тому
батько
коміт
6069438fad
3 змінених файлів з 338 додано та 354 видалено
  1. 46 64
      assets/Script/Game/GameSence.js
  2. 4 2
      assets/Script/Home/HomeSence.js
  3. 288 288
      assets/Script/UserInfoJS.js

+ 46 - 64
assets/Script/Game/GameSence.js

@@ -196,20 +196,19 @@ cc.Class({
 
             this.gameOver();
 
-            var data = [{
-                key: UserInfo.getCurWeekScoreValue(),
-                value: UserInfo.getScore().toString()
-            }, {
-                key: "driLevel",
-                value: '0'
-            }
-            ];
-
-            if (CC_WECHATGAME && cc.vv.isRank) {
+            // var data = [{
+            //     key: UserInfo.getCurWeekScoreValue(),
+            //     value: UserInfo.getScore().toString()
+            // }, {
+            //     key: "driLevel",
+            //     value: '0'
+            // }];
+
+            if (CC_QQPLAY) {
                 this.node.parent.getChildByName("PHB").getChildByName("bg").active = false;
                 this.rankScene.status = 3;
                 this.showRank();
-                this.updateXYXScore('showMyRank', data);
+                this.updateXYXScore('showMyRank', null);
             }
         }
     },
@@ -227,21 +226,12 @@ cc.Class({
                 gameOverNode.getChildByName("EndNode").active = true;
 
                 this.gameOver();
-
-                var data = [{
-                    key: UserInfo.getCurWeekScoreValue(),
-                    value: UserInfo.getScore().toString()
-                }, {
-                    key: "driLevel",
-                    value: '0'
-                }
-                ];
-
-                if (CC_WECHATGAME && cc.vv.isRank) {
-                    this.rankScene.status = 3;
-                    this.showRank();
-                    this.updateXYXScore('showMyRank', data);
-                }
+				
+				if (CC_QQPLAY) { 
+					this.rankScene.status = 3;
+					this.showRank();
+					this.updateXYXScore('showMyRank', null);
+				}
             } else {
                 countDown--;
                 countDownLabel.getComponent("cc.Label").string = countDown;
@@ -853,23 +843,13 @@ cc.Class({
         gameOverNode.getChildByName("EndNode").active = true;
 
         this.gameOver();
-
-        var data = [{
-            key: UserInfo.getCurWeekScoreValue(),
-            value: UserInfo.getScore().toString()
-        },
-        {
-            key: "driLevel",
-            value: '0'
-        }
-        ];
-
-        if (CC_WECHATGAME && cc.vv.isRank) {
+		
+		if (CC_QQPLAY) { 
             // window.deadBanner.hide();
-            this.rankScene.status = 3;
+			this.rankScene.status = 3;
             this.showRank();
-            this.updateXYXScore('showMyRank', data);
-        }
+            this.updateXYXScore('showMyRank', null);
+		}
     },
 
     onRestartBtn: function () {
@@ -911,29 +891,31 @@ cc.Class({
     },
 
     updateXYXScore(strFun, data) {
-        data.push({
-            key: "starrank",
-            value: JSON.stringify({
-                "wxgame": {
-                    "score": UserInfo.getScore().toString(),
-                    "update_time": Date.now()
-                }
-            })
-
-            // value: UserInfo.getScore().toString()
-        })
-        wx.setUserCloudStorage({
-            KVDataList: data,
-            success: function (res) {
-                wx.postMessage({
-                    method: strFun
-                });
-            },
-            fail: function (res) {
-                console.error(res);
-            },
-            complete: function (res) { }
-        })
+		var data = {
+			userData: [{
+				openId: GameStatusInfo.openId,
+				startMs: GameStatusInfo.startMs,
+				endMs: ((new Date()).getTime()).toString(),
+				scoreInfo: {
+					score: parseInt(UserInfo.getScore()), //分数,类型必须是整型数
+				}
+			}],
+			attr: {
+				score: {   
+					type: 'rank',
+					order: 1,
+				}
+			},
+		};
+		
+		BK.QQ.uploadScoreWithoutRoom(1, data, function(errCode, cmd, data) {
+			// 返回错误码信息
+			if (errCode !== 0) {
+				BK.Script.log(1,1,'上传分数失败!错误码:' + errCode);
+			} else {
+				BK.Script.log(1,1,'上传分数成功' + JSON.stringify(data));
+			}
+		});
     },
 
     showRank() {

+ 4 - 2
assets/Script/Home/HomeSence.js

@@ -43,7 +43,9 @@ cc.Class({
 
     onLoad() {
         cc.audioEngine.playMusic(this.gamebgMusic, true);
-
+		if(CC_QQPLAY && window.GameStatusInfo) {
+			GameStatusInfo.startMs = ((new Date()).getTime()).toString()
+		}
         if (CC_WECHATGAME) {
             // this.initShare();
             // wx.setPreferredFramesPerSecond(30);
@@ -219,7 +221,7 @@ cc.Class({
 
         if (!guideTime || guideTime != guideTimeValue) {
             cc.sys.localStorage.setItem(key, guideTimeValue);
-            return true;
+            return false;
         } else {
             this.GuideNode && this.GuideNode.destroy();
             this.showGuideValue = false;

+ 288 - 288
assets/Script/UserInfoJS.js

@@ -1,288 +1,288 @@
-
-/*
-	Global UserInfo
-*/
-
-window.UserInfo = {
-	/*
-		积分
-	*/
-	shareLimit : 3,		//分享次数限制
-	shareAddGold : 10,	//分享增加金币数
-	platform :  CC_WECHATGAME ? 1 : 0,		//1为微信小游戏模式
-	shareUrl : 'https://pub.dwstatic.com/wxgame/budingGame/share/shareImage.jpg',//分享图片地址
-	shareDesc : '超级可爱的布丁,快来跟我一起玩吧',
-	shareDescChanllenge : '顽强的布丁',
-	wxversion : '6.6.3',
-	localversion : '1.0.1',
-    ewmurl: 'https://pub.dwstatic.com/wxgame/escape/share/2weima.jpg',//公众号二维码
-
-	GameCount : 2,
-
-	getScore: function () {
-		let score = cc.sys.localStorage.getItem(this.getCurWeekScoreValue());
-		return score ? parseInt(score) : 0;
-	},
-
-	setScore: function (value) {
-		cc.sys.localStorage.setItem(this.getCurWeekScoreValue(), "" + value);
-	},
-
-	getCurrLocalversion: function () {
-		if (this.IsEmpty(this.localversion))
-			return "";
-		return this.localversion;
-	},
-
-	setLocalversion: function (version) {
-		cc.sys.localStorage.setItem("localversion", "" + version);
-	},
-
-	getLocalversion: function () {
-		let version = cc.sys.localStorage.getItem('localversion');
-		if (this.IsEmpty(version)) {
-			cc.sys.localStorage.setItem('localversion', '');
-			version = '';
-		}
-		return version;
-	},
-
-	addScore: function (value) {
-		let score = cc.sys.localStorage.getItem(this.getCurWeekScoreValue());
-		let inputScore = (score ? parseInt(score) : 0) + parseInt(value) + "";
-		cc.sys.localStorage.setItem(this.getCurWeekScoreValue(), inputScore);
-	},
-
-	/*
-		金币
-	*/
-	getGold: function () {
-		let gold = cc.sys.localStorage.getItem('gold');
-		return gold ? parseInt(gold) : 0;
-	},
-
-	setGold: function (value) {
-		cc.sys.localStorage.setItem('gold', "" + value);
-	},
-
-	addGold: function (value) {
-		let gold = cc.sys.localStorage.getItem('gold');
-		let inputGold = (gold ? parseInt(gold) : 0) + parseInt(value) + "";
-		cc.sys.localStorage.setItem('gold', inputGold);
-
-		this.addTotalGold(value);
-	},
-
-	addTotalGold: function (value) {
-		let goldTotal = cc.sys.localStorage.getItem('goldTotal');
-		let inputGold = (goldTotal ? parseInt(goldTotal) : 0) + parseInt(value) + "";
-		cc.sys.localStorage.setItem('goldTotal', inputGold);
-	},
-
-	getTotalGold: function () {
-		let goldTotal = cc.sys.localStorage.getItem('goldTotal');
-		return goldTotal ? parseInt(goldTotal) : 0;
-	},
-
-	addStageProp: function(value) {//累计道具数
-		let propcnt = cc.sys.localStorage.getItem('propcnt');
-		let inputCnt = (propcnt ? parseInt(propcnt) : 0) + parseInt(value) + "";
-		cc.sys.localStorage.setItem('propcnt', inputCnt);
-	},
-
-	setStageProp: function(value) {//累计道具数		
-		let inputCnt = parseInt(value) + "";
-		cc.sys.localStorage.setItem('propcnt', inputCnt);
-	},
-
-	getStageProp: function () {
-		let propcnt = cc.sys.localStorage.getItem('propcnt');
-		return propcnt ? parseInt(propcnt) : 0;
-	},
-
-	getCurrentLevel: function () {
-		let level = cc.sys.localStorage.getItem('levelSign');
-		if (this.IsEmpty(level)) {
-			cc.sys.localStorage.setItem('levelSign', '0');
-			level = '0';
-		}
-		return parseInt(level);
-	},
-
-	setCurrentLevel: function (value) {
-		cc.sys.localStorage.setItem('levelSign', value + "");
-	},
-
-	setFlyCnt: function(cnt) {
-		cc.sys.localStorage.setItem('flycnt', cnt + "");
-	},
-
-	getFlyCnt: function() {
-		let level = cc.sys.localStorage.getItem('flycnt');
-		if (this.IsEmpty(level)) {
-			cc.sys.localStorage.setItem('flycnt', '0');
-			level = '0';
-		}
-		return parseInt(level);
-	},
-
-	setSkinIndex: function(skinIndex){
-		cc.sys.localStorage.setItem('skinIndex',skinIndex + "");
-	},
-
-	getSkinIndex: function()
-	{
-		let skinIndex = cc.sys.localStorage.getItem('skinIndex');
-		if (this.IsEmpty(skinIndex)) 
-		{
-			cc.sys.localStorage.setItem('skinIndex','0');
-			skinIndex = '0';
-		}
-		return parseInt(skinIndex);
-	},
-
-	/*
-		当前等级
-	*/
-	getCurrentPlane: function () {
-		let level = cc.sys.localStorage.getItem('level');
-		if (this.IsEmpty(level)) {
-			cc.sys.localStorage.setItem('level', '1');
-			level = '1';
-		}
-
-		var intLevel = parseInt(level);
-		if (intLevel <= 0) {
-			intLevel = 1;
-		}
-		return intLevel;
-	},
-
-	setCurrentPlane: function (value) {
-		cc.sys.localStorage.setItem('level', value + "");
-	},
-
-
-	getLevelStage: function () {
-		let level = cc.sys.localStorage.getItem('levelStage');
-		if (this.IsEmpty(level)) {
-			cc.sys.localStorage.setItem('levelStage', '');
-			level = '';
-		}
-
-		return level;
-	},
-
-	setLevelStage: function (value) {
-		cc.sys.localStorage.setItem('levelStage', value + "");
-	},
-
-	/*
-		设置自定义数据
-	*/
-	setString: function (str, value) {
-		cc.sys.localStorage.setItem(str, value);
-	},
-
-	getString: function (str) {
-		return cc.sys.localStorage.getItem(str);
-	},
-
-	addString: function (str, value) {
-		let data = cc.sys.localStorage.getItem(str);
-		let inputData = (data ? parseInt(data) : 0) + parseInt(value) + "";
-		cc.sys.localStorage.setItem(str, inputData);
-	},
-
-	removeString: function (str) {
-		cc.sys.localStorage.removeItem(str);
-	},
-
-	IsEmpty(obj) {//判断是否为空
-        if (obj == "undefined" || obj == null || obj == "") {
-            return true;
-        } else {
-            return false;
-        }
-	},
-
-	getMaxTime() {//历史最长时间
-		var score = this.getString('maxtime');
-		if (this.IsEmpty(score)) {
-			cc.sys.localStorage.setItem('maxtime', "0");
-			score = "0";
-		}
-		return parseInt(score);
-	},
-
-	setMaxTime: function (value) {
-		cc.sys.localStorage.setItem('maxtime', value+"");
-	},
-
-	getHistoryScore() {//历史最高分
-		var score = this.getString('historyScore');
-		if (this.IsEmpty(score)) {
-			cc.sys.localStorage.setItem('historyScore', "0");
-			score = "0";
-		}
-		return parseInt(score);
-	},
-	
-	getCurWeekScoreValue() {
-		return this.getNowFormatDate();
-	},
-
-	getNowFormatDate() {
-		var date = new Date();
-		var seperator1 = "-";
-		var year = date.getFullYear();
-		// var month = date.getMonth() + 1;
-		// if (month >= 1 && month <= 9) {
-		// 	month = "0" + month;
-		// }
-		var week = this.Getweek();
-		var currentdate = year + seperator1 + week;
-		return currentdate;
-	},
-
-	getMonthWeek() {
-		var date = new Date(),
-			w = date.getDay(),
-			d = date.getDate();
-		return Math.ceil(
-			(d + 7 - w) / 7
-		);
-	},
-
-	Getweek(dateString) {
-		var da = '';
-		if (dateString == undefined) {
-			var now = new Date();
-			var now_m = now.getMonth() + 1;
-			now_m = (now_m < 10) ? '0' + now_m : now_m;
-			var now_d = now.getDate();
-			now_d = (now_d < 10) ? '0' + now_d : now_d;
-			da = now.getFullYear() + '-' + now_m + '-' + now_d;
-		} else {
-			da = dateString; //日期格式2015-12-30
-		}
-		var date1 = new Date(da.substring(0, 4), parseInt(da.substring(5, 7)) - 1, da.substring(8, 10)); //当前日期
-		var date2 = new Date(da.substring(0, 4), 0, 1); //1月1号
-		//获取1月1号星期(以周一为第一天,0周一~6周日)
-		var dateWeekNum = date2.getDay() - 1;
-		if (dateWeekNum < 0) {
-			dateWeekNum = 6;
-		}
-		if (dateWeekNum < 4) {
-			//前移日期
-			date2.setDate(date2.getDate() - dateWeekNum);
-		} else {
-			//后移日期
-			date2.setDate(date2.getDate() + 7 - dateWeekNum);
-		}
-		var d = Math.round((date1.valueOf() - date2.valueOf()) / 86400000);
-		var year = date1.getFullYear();
-		var week = Math.ceil((d + 1) / 7);
-		return week;
-	},
-};
+
+/*
+	Global UserInfo
+*/
+
+window.UserInfo = {
+	/*
+		积分
+	*/
+	shareLimit : 3,		//分享次数限制
+	shareAddGold : 10,	//分享增加金币数
+	platform :  CC_WECHATGAME ? 1 : 0,		//1为微信小游戏模式
+	shareUrl : 'https://pub.dwstatic.com/wxgame/budingGame/share/shareImage.jpg',//分享图片地址
+	shareDesc : '超级可爱的布丁,快来跟我一起玩吧',
+	shareDescChanllenge : '顽强的布丁',
+	wxversion : '6.6.3',
+	localversion : '1.0.1',
+    ewmurl: 'https://pub.dwstatic.com/wxgame/escape/share/2weima.jpg',//公众号二维码
+
+	GameCount : 2,
+
+	getScore: function () {
+		let score = BK.localStorage.getItem('score');
+		return score ? parseInt(score) : 0;
+	},
+
+	setScore: function (value) {
+		BK.localStorage.setItem('score', "" + value);
+	},
+
+	getCurrLocalversion: function () {
+		if (this.IsEmpty(this.localversion))
+			return "";
+		return this.localversion;
+	},
+
+	setLocalversion: function (version) {
+		BK.localStorage.setItem("localversion", "" + version);
+	},
+
+	getLocalversion: function () {
+		let version = BK.localStorage.getItem('localversion');
+		if (this.IsEmpty(version)) {
+			BK.localStorage.setItem('localversion', '');
+			version = '';
+		}
+		return version;
+	},
+
+	addScore: function (value) {
+		let score = BK.localStorage.getItem(this.getCurWeekScoreValue());
+		let inputScore = (score ? parseInt(score) : 0) + parseInt(value) + "";
+		BK.localStorage.setItem(this.getCurWeekScoreValue(), inputScore);
+	},
+
+	/*
+		金币
+	*/
+	getGold: function () {
+		let gold = BK.localStorage.getItem('gold');
+		return gold ? parseInt(gold) : 0;
+	},
+
+	setGold: function (value) {
+		BK.localStorage.setItem('gold', "" + value);
+	},
+
+	addGold: function (value) {
+		let gold = BK.localStorage.getItem('gold');
+		let inputGold = (gold ? parseInt(gold) : 0) + parseInt(value) + "";
+		BK.localStorage.setItem('gold', inputGold);
+
+		this.addTotalGold(value);
+	},
+
+	addTotalGold: function (value) {
+		let goldTotal = BK.localStorage.getItem('goldTotal');
+		let inputGold = (goldTotal ? parseInt(goldTotal) : 0) + parseInt(value) + "";
+		BK.localStorage.setItem('goldTotal', inputGold);
+	},
+
+	getTotalGold: function () {
+		let goldTotal = BK.localStorage.getItem('goldTotal');
+		return goldTotal ? parseInt(goldTotal) : 0;
+	},
+
+	addStageProp: function(value) {//累计道具数
+		let propcnt = BK.localStorage.getItem('propcnt');
+		let inputCnt = (propcnt ? parseInt(propcnt) : 0) + parseInt(value) + "";
+		BK.localStorage.setItem('propcnt', inputCnt);
+	},
+
+	setStageProp: function(value) {//累计道具数		
+		let inputCnt = parseInt(value) + "";
+		BK.localStorage.setItem('propcnt', inputCnt);
+	},
+
+	getStageProp: function () {
+		let propcnt = BK.localStorage.getItem('propcnt');
+		return propcnt ? parseInt(propcnt) : 0;
+	},
+
+	getCurrentLevel: function () {
+		let level = BK.localStorage.getItem('levelSign');
+		if (this.IsEmpty(level)) {
+			BK.localStorage.setItem('levelSign', '0');
+			level = '0';
+		}
+		return parseInt(level);
+	},
+
+	setCurrentLevel: function (value) {
+		BK.localStorage.setItem('levelSign', value + "");
+	},
+
+	setFlyCnt: function(cnt) {
+		BK.localStorage.setItem('flycnt', cnt + "");
+	},
+
+	getFlyCnt: function() {
+		let level = BK.localStorage.getItem('flycnt');
+		if (this.IsEmpty(level)) {
+			BK.localStorage.setItem('flycnt', '0');
+			level = '0';
+		}
+		return parseInt(level);
+	},
+
+	setSkinIndex: function(skinIndex){
+		BK.localStorage.setItem('skinIndex',skinIndex + "");
+	},
+
+	getSkinIndex: function()
+	{
+		let skinIndex = BK.localStorage.getItem('skinIndex');
+		if (this.IsEmpty(skinIndex)) 
+		{
+			BK.localStorage.setItem('skinIndex','0');
+			skinIndex = '0';
+		}
+		return parseInt(skinIndex);
+	},
+
+	/*
+		当前等级
+	*/
+	getCurrentPlane: function () {
+		let level = BK.localStorage.getItem('level');
+		if (this.IsEmpty(level)) {
+			BK.localStorage.setItem('level', '1');
+			level = '1';
+		}
+
+		var intLevel = parseInt(level);
+		if (intLevel <= 0) {
+			intLevel = 1;
+		}
+		return intLevel;
+	},
+
+	setCurrentPlane: function (value) {
+		BK.localStorage.setItem('level', value + "");
+	},
+
+
+	getLevelStage: function () {
+		let level = BK.localStorage.getItem('levelStage');
+		if (this.IsEmpty(level)) {
+			BK.localStorage.setItem('levelStage', '');
+			level = '';
+		}
+
+		return level;
+	},
+
+	setLevelStage: function (value) {
+		BK.localStorage.setItem('levelStage', value + "");
+	},
+
+	/*
+		设置自定义数据
+	*/
+	setString: function (str, value) {
+		BK.localStorage.setItem(str, "" + value);
+	},
+
+	getString: function (str) {
+		return BK.localStorage.getItem(str);
+	},
+
+	addString: function (str, value) {
+		let data = BK.localStorage.getItem(str);
+		let inputData = (data ? parseInt(data) : 0) + parseInt(value) + "";
+		BK.localStorage.setItem(str, inputData);
+	},
+
+	removeString: function (str) {
+		cc.sys.localStorage.removeItem(str);
+	},
+
+	IsEmpty(obj) {//判断是否为空
+        if (obj == "undefined" || obj == null || obj == "") {
+            return true;
+        } else {
+            return false;
+        }
+	},
+
+	getMaxTime() {//历史最长时间
+		var score = this.getString('maxtime');
+		if (this.IsEmpty(score)) {
+			BK.localStorage.setItem('maxtime', "0");
+			score = "0";
+		}
+		return parseInt(score);
+	},
+
+	setMaxTime: function (value) {
+		BK.localStorage.setItem('maxtime', value+"");
+	},
+
+	getHistoryScore() {//历史最高分
+		var score = this.getString('historyScore');
+		if (this.IsEmpty(score)) {
+			BK.localStorage.setItem('historyScore', "0");
+			score = "0";
+		}
+		return parseInt(score);
+	},
+	
+	getCurWeekScoreValue() {
+		return this.getNowFormatDate();
+	},
+
+	getNowFormatDate() {
+		var date = new Date();
+		var seperator1 = "-";
+		var year = date.getFullYear();
+		// var month = date.getMonth() + 1;
+		// if (month >= 1 && month <= 9) {
+		// 	month = "0" + month;
+		// }
+		var week = this.Getweek();
+		var currentdate = year + seperator1 + week;
+		return currentdate;
+	},
+
+	getMonthWeek() {
+		var date = new Date(),
+			w = date.getDay(),
+			d = date.getDate();
+		return Math.ceil(
+			(d + 7 - w) / 7
+		);
+	},
+
+	Getweek(dateString) {
+		var da = '';
+		if (dateString == undefined) {
+			var now = new Date();
+			var now_m = now.getMonth() + 1;
+			now_m = (now_m < 10) ? '0' + now_m : now_m;
+			var now_d = now.getDate();
+			now_d = (now_d < 10) ? '0' + now_d : now_d;
+			da = now.getFullYear() + '-' + now_m + '-' + now_d;
+		} else {
+			da = dateString; //日期格式2015-12-30
+		}
+		var date1 = new Date(da.substring(0, 4), parseInt(da.substring(5, 7)) - 1, da.substring(8, 10)); //当前日期
+		var date2 = new Date(da.substring(0, 4), 0, 1); //1月1号
+		//获取1月1号星期(以周一为第一天,0周一~6周日)
+		var dateWeekNum = date2.getDay() - 1;
+		if (dateWeekNum < 0) {
+			dateWeekNum = 6;
+		}
+		if (dateWeekNum < 4) {
+			//前移日期
+			date2.setDate(date2.getDate() - dateWeekNum);
+		} else {
+			//后移日期
+			date2.setDate(date2.getDate() + 7 - dateWeekNum);
+		}
+		var d = Math.round((date1.valueOf() - date2.valueOf()) / 86400000);
+		var year = date1.getFullYear();
+		var week = Math.ceil((d + 1) / 7);
+		return week;
+	},
+};