288 lines
5.5 KiB
JavaScript
288 lines
5.5 KiB
JavaScript
var PLAT_OPPO = {
|
|
isThisPT() {
|
|
return typeof (qg) != 'undefined';
|
|
},
|
|
|
|
getLaunchInfo() {
|
|
if (this.isThisPT()) {
|
|
|
|
}
|
|
return null;
|
|
},
|
|
|
|
getSystemInfo() {
|
|
return qg.getSystemInfoSync();
|
|
},
|
|
|
|
/** 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.nickName;
|
|
dstinfo.avatar_url = ptinfo.avatar;
|
|
dstinfo.sex = ptinfo.sex;
|
|
dstinfo.birthday = ptinfo.birthday;
|
|
dstinfo.phone = ptinfo.phoneNum;
|
|
dstinfo.location = ptinfo.location;
|
|
},
|
|
|
|
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) {
|
|
qg.showToast({
|
|
title: str,
|
|
icon: 'none'
|
|
});
|
|
},
|
|
|
|
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()) {
|
|
console.log('[qg.login]BEGIN:' + info);
|
|
qg.login({
|
|
pkgName: info,
|
|
success: (res) => {
|
|
console.log('[qg.login]success');
|
|
console.log(JSON.stringify(res));
|
|
this._owner.login.login({token: res.token, successcb: function(data) {
|
|
data.client_token = res.token;
|
|
successcb && successcb(data);
|
|
}, failcb, openid: res.uid});
|
|
this._owner.login.updateuserinfo(res);
|
|
},
|
|
fail: (res) => {
|
|
console.log('[qg.login]fail');
|
|
console.log(JSON.stringify(res));
|
|
failcb && failcb(0, res ? res.errcode : -1, res ? res.errmsg : '');
|
|
}
|
|
});
|
|
} else {
|
|
failcb && failcb(0, -1000, 'not oppo platform!');
|
|
}
|
|
},
|
|
|
|
//广告相关
|
|
PTInitADService(adparam) {
|
|
if (this.isThisPT()) {
|
|
qg.initAdService({
|
|
appId: adparam,
|
|
isDebug: false
|
|
});
|
|
}
|
|
},
|
|
|
|
PTCreateBannerAD(adid, st) {
|
|
if (this.isThisPT()) {
|
|
return qg.createBannerAd({
|
|
posId: adid
|
|
});
|
|
}
|
|
return null;
|
|
},
|
|
|
|
PTCreateVideoAD(adid) {
|
|
if (this.isThisPT()) {
|
|
return qg.createRewardedVideoAd({
|
|
posId: adid
|
|
});
|
|
}
|
|
return null;
|
|
},
|
|
|
|
PTCreateInsertAD(adid) {
|
|
if (this.isThisPT()) {
|
|
return qg.createInsertAd({
|
|
posId: adid
|
|
});
|
|
}
|
|
return null;
|
|
},
|
|
|
|
PTSetVideoADCallback(adobj, adowner, cb) {
|
|
if (this.isThisPT()) {
|
|
let closeCb = function () {
|
|
console.log('[ad]onRewarded');
|
|
cb && cb(true, adowner, null);
|
|
// ad.offClose && ad.offClose(closeCb);
|
|
};
|
|
adobj.onRewarded && adobj.onRewarded(closeCb);
|
|
}
|
|
},
|
|
|
|
PTVibrateShort(successcb, failcb) {
|
|
if (this.isThisPT()) {
|
|
qg.vibrateShort({
|
|
success: () => {
|
|
successcb && successcb();
|
|
},
|
|
fail: () => {
|
|
failcb && failcb();
|
|
}
|
|
})
|
|
}
|
|
},
|
|
|
|
PTVibrateLong(successcb, failcb) {
|
|
if (this.isThisPT()) {
|
|
qg.vibrateLong({
|
|
success: () => {
|
|
successcb && successcb();
|
|
},
|
|
fail: () => {
|
|
failcb && 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()) {
|
|
|
|
}
|
|
},
|
|
setLocalStorage(key, value) {
|
|
if (window.localStorage) {
|
|
localStorage.setItem(key, value);
|
|
}
|
|
},
|
|
|
|
getLocalStorage(key) {
|
|
if (window.localStorage) {
|
|
return localStorage.getItem(key);
|
|
} else {
|
|
return null;
|
|
}
|
|
},
|
|
|
|
removeStorage(key) {
|
|
if (window.localStorage) {
|
|
localStorage.removeItem(key);
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = PLAT_OPPO;
|