235 lines
4.2 KiB
JavaScript
235 lines
4.2 KiB
JavaScript
var PLAT_FB = {
|
|
isThisPT() {
|
|
return typeof (FBInstant) != 'undefined';
|
|
},
|
|
|
|
getLaunchInfo() {
|
|
if (this.isThisPT()) {
|
|
|
|
}
|
|
return null;
|
|
},
|
|
|
|
getSystemInfo() {
|
|
if (this.isThisPT()) {
|
|
|
|
}
|
|
return null;
|
|
},
|
|
|
|
/** example:
|
|
*
|
|
* @param {object} btninfo :
|
|
* {
|
|
* width: 100,
|
|
* height: 100,
|
|
* name: logo.png
|
|
* }
|
|
* @param {function} cb
|
|
*/
|
|
getUserInfo(btninfo, cb) {
|
|
cb && cb(null, -1000);
|
|
},
|
|
|
|
setUserInfo(dstinfo, ptinfo) {
|
|
dstinfo.nickname = ptinfo.nick;
|
|
dstinfo.avatar_url = ptinfo.avatar;
|
|
},
|
|
|
|
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()) {
|
|
var self = this;
|
|
FBInstant.player.getSignedPlayerInfoAsync('my_metadata')
|
|
.then(function (result) {
|
|
self._owner.login.login({token: result.getSignature(), successcb, failcb, openid: result.getPlayerID()});
|
|
});
|
|
var userinfo = {
|
|
nick: FBInstant.player.getName(),
|
|
avatar: FBInstant.player.getPhoto()
|
|
}
|
|
this._owner.login.updateuserinfo(userinfo);
|
|
} else {
|
|
failcb && failcb(0, -1000, 'not fb platform!');
|
|
}
|
|
},
|
|
|
|
//广告相关
|
|
PTInitADService() {
|
|
|
|
},
|
|
|
|
PTCreateBannerAD(adid, st) {
|
|
return null;
|
|
},
|
|
|
|
PTCreateVideoAD(adid) {
|
|
return null;
|
|
},
|
|
|
|
PTCreateInsertAD(adid) {
|
|
return null;
|
|
},
|
|
|
|
PTSetVideoADCallback(adobj, adowner, cb) {
|
|
|
|
},
|
|
|
|
PTADWatch(adid, successcb, failcb) {
|
|
if (this.isThisPT()) {
|
|
let ad = null;
|
|
FBInstant.getRewardedVideoAsync(
|
|
adid
|
|
).then(function (rewardedVideo) {
|
|
ad = rewardedVideo;
|
|
return ad.loadAsync();
|
|
}).then(function () {
|
|
// Ad loaded
|
|
return ad.showAsync();
|
|
}).then(function () {
|
|
successcb && successcb();
|
|
}).catch((err) => {
|
|
failcb && failcb(adid, err, true);
|
|
});
|
|
} else {
|
|
failcb && failcb(adid, -1000, true);
|
|
}
|
|
},
|
|
|
|
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_FB;
|