244 lines
5.3 KiB
JavaScript
244 lines
5.3 KiB
JavaScript
|
|
var PLAT_QQ = {
|
|
isThisPT(){
|
|
return cc.sys.platform == cc.sys.QQ_PLAY;
|
|
},
|
|
|
|
getLaunchInfo(){
|
|
if(this.isThisPT()){
|
|
|
|
}
|
|
return null;
|
|
},
|
|
|
|
getSystemInfo(){
|
|
if(this.isThisPT()){
|
|
return BK.getSystemInfoSync();
|
|
}
|
|
return null;
|
|
},
|
|
|
|
/** example:
|
|
*
|
|
* @param {object} btninfo :
|
|
* {
|
|
* width: 100,
|
|
* height: 100,
|
|
* name: logo.png
|
|
* }
|
|
* @param {function} cb
|
|
*/
|
|
getUserInfo(btninfo, cb){
|
|
console.log('cc.sys.platform:' + cc.sys.platform);
|
|
cb && cb(null, -1000);
|
|
},
|
|
|
|
setUserInfo(dstinfo, ptinfo){
|
|
|
|
},
|
|
|
|
setTokenInfo(dstinfo, tokeninfo){
|
|
|
|
},
|
|
|
|
init(owner, channelid){
|
|
this._owner = owner;
|
|
this._ptid = channelid;
|
|
},
|
|
|
|
bindController(ctrl){
|
|
this._man = ctrl;
|
|
},
|
|
|
|
commonShare(img, title, stype, param, successcb, failcb, exinfo){
|
|
let sp = this._owner.makeShareParam(stype, param, exinfo);
|
|
let uuid = this._owner.currUUID();
|
|
this.PTShare(title, img, sp, successcb, failcb, uuid);
|
|
},
|
|
|
|
captureShare(rc, title, stype, param, successcb, failcb, exinfo){
|
|
let sp = this._owner.makeShareParam(stype, param, exinfo);
|
|
let uuid = this._owner.currUUID();
|
|
this.PTShareCapture(title, rc, sp, successcb, failcb, uuid);
|
|
},
|
|
|
|
PTInitShare(normalinfo){
|
|
if(!normalinfo){
|
|
return;
|
|
}
|
|
if(this.isThisPT()){
|
|
|
|
}
|
|
},
|
|
|
|
PTShare(content, imgurl, param, successcb, failcb, tokenid){
|
|
if(this.isThisPT()){
|
|
|
|
}else{
|
|
failcb && failcb(-1000, param, tokenid);
|
|
}
|
|
},
|
|
|
|
PTShareCapture(content, rc, param, successcb, failcb, tokenid){
|
|
if(this.isThisPT()){
|
|
|
|
}else{
|
|
failcb && failcb(-1000, param, tokenid);
|
|
}
|
|
},
|
|
|
|
PTOpenKF(cb){
|
|
if (this.isThisPT()) {
|
|
cb && cb(false);
|
|
}else{
|
|
cb && cb(false);
|
|
}
|
|
},
|
|
|
|
PTShowToast(str){
|
|
if (this.isThisPT()) {
|
|
|
|
}
|
|
},
|
|
|
|
PTGotoApp(appid, apppath, exobj, cb, qdid){
|
|
if(this.isThisPT()){
|
|
let self = this;
|
|
let obj = {
|
|
appId: appid,
|
|
path: apppath,
|
|
extraData: exobj,
|
|
success: function(res){
|
|
self._owner.gamelog.logJumpApp(appid, apppath, 1, qdid);
|
|
cb && cb(1, res);
|
|
},
|
|
fail: function(res){
|
|
self._owner.gamelog.logJumpApp(appid, apppath, -1, qdid);
|
|
cb && cb(0, res);
|
|
}
|
|
};
|
|
|
|
|
|
}else{
|
|
this._owner.gamelog.logJumpApp(appid, apppath, -1000, qdid);
|
|
cb && cb(-1000, null);
|
|
}
|
|
},
|
|
|
|
PTLogin(info, successcb, failcb){
|
|
if(this.isThisPT()){
|
|
let self = this;
|
|
let openId = BK.getSystemInfoSync().openId;
|
|
console.log("loginQQ openid:"+openId);
|
|
// BK.Script.loadlib("GameRes://qqPlayCore.js") //预加载bricks js层接口
|
|
BK.QQ.fetchOpenKey(function (errCode, cmd, data) {
|
|
if (errCode == 0) {
|
|
let openKey = data.openKey;
|
|
console.log("loginQQ openKey:"+openKey);
|
|
self._owner.login.login(openKey, successcb, failcb, openId);
|
|
}
|
|
});
|
|
}else{
|
|
failcb && failcb(0, -1000, "not qq platform!");
|
|
}
|
|
},
|
|
|
|
//广告相关
|
|
PTInitADService(){
|
|
|
|
},
|
|
|
|
PTCreateBannerAD(adid, st){
|
|
if(this.isThisPT()){
|
|
if(BK.Advertisement && BK.Advertisement.createBannerAd){
|
|
let data = {
|
|
viewId: adid,
|
|
style: st
|
|
};
|
|
return BK.Advertisement.createBannerAd(data);
|
|
}
|
|
}
|
|
return null;
|
|
},
|
|
|
|
PTCreateVideoAD(adid){
|
|
if(this.isThisPT()){
|
|
if(BK.Advertisement && BK.Advertisement.createVideoAd){
|
|
return BK.Advertisement.createVideoAd();
|
|
}
|
|
}
|
|
return null;
|
|
},
|
|
|
|
PTCreateInsertAD(adid){
|
|
return null;
|
|
},
|
|
|
|
PTSetVideoADCallback(adobj, adowner, cb){
|
|
if(this.isThisPT()){
|
|
let closeCb = function(res){
|
|
console.log("[ad]onClose:"+JSON.stringify(res));
|
|
cb && cb(false, adowner, res);
|
|
// ad.offClose && ad.offClose(closeCb);
|
|
};
|
|
// ad.onPlayStart && ad.onPlayStart(function () {
|
|
// //开始播放
|
|
// });
|
|
adobj.onPlayFinish && adobj.onPlayFinish(function () {
|
|
//播放结束
|
|
cb && cb(true, adowner, null);
|
|
});
|
|
adobj.onClose && adobj.onClose(closeCb);
|
|
}
|
|
},
|
|
|
|
PTVibrateShort(successcb, failcb){
|
|
|
|
},
|
|
|
|
PTVibrateLong(successcb, failcb){
|
|
|
|
},
|
|
|
|
PTOpenDataContext(){
|
|
return null;
|
|
},
|
|
|
|
PTPostOpenMsg(msg){
|
|
|
|
},
|
|
|
|
// 排行榜相关
|
|
saveRankData(nscore, nmoney, stitle){
|
|
if(this.isThisPT()){
|
|
|
|
}
|
|
},
|
|
|
|
showRankData(){
|
|
if(this.isThisPT()){
|
|
|
|
}
|
|
},
|
|
|
|
hideRankData(){
|
|
if(this.isThisPT()){
|
|
|
|
}
|
|
},
|
|
|
|
prevRankPage(){
|
|
if(this.isThisPT()){
|
|
|
|
}
|
|
},
|
|
|
|
nextRankPage(){
|
|
if(this.isThisPT()){
|
|
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = PLAT_QQ;
|