262 lines
5.5 KiB
JavaScript
262 lines
5.5 KiB
JavaScript
var PLAT_HUAWEI = {
|
|
SHARE_FAIL: 25,
|
|
SHARE_TIME: 3000,
|
|
appid: '',
|
|
shareCount: {},
|
|
|
|
getSystemInfoAsync(successcb, failcb) {
|
|
hbs.getSystemInfo({
|
|
success : function (res) {
|
|
console.log("getSystemInfo success res = " + res.brand);
|
|
successcb && successcb(res);
|
|
},
|
|
fail:function(){
|
|
console.log("getSystemInfo fail");
|
|
failcb && failcb();
|
|
}
|
|
});
|
|
},
|
|
|
|
|
|
getUserInfo(btninfo, cb) {
|
|
cb && cb(null, -1000);
|
|
},
|
|
|
|
destoryAuth() {
|
|
},
|
|
|
|
setUserInfo(dstinfo, ptinfo) {
|
|
dstinfo.nickname = ptinfo.nickName;
|
|
dstinfo.country = ptinfo.country;
|
|
dstinfo.province = ptinfo.province;
|
|
dstinfo.city = ptinfo.city;
|
|
dstinfo.avatar_url = ptinfo.avatarUrl;
|
|
dstinfo.sex = ptinfo.gender;
|
|
},
|
|
|
|
setTokenInfo(dstinfo, tokeninfo) {
|
|
|
|
},
|
|
|
|
init(owner, channelid, appid) {
|
|
this._owner = owner;
|
|
this._ptid = channelid;
|
|
this.appid = appid;
|
|
},
|
|
|
|
bindController(ctrl) {
|
|
this._man = ctrl;
|
|
},
|
|
|
|
commonShare(aimg, atitle, stype, param, successcb, failcb, exinfo) {
|
|
let sp = this._owner.makeShareParam(stype, param, exinfo);
|
|
let img = aimg;
|
|
if (!img && this._exshareinfo) {
|
|
img = this._exshareinfo.imgurl;
|
|
}
|
|
let title = atitle;
|
|
if (!title && this._exshareinfo) {
|
|
title = this._exshareinfo.title;
|
|
}
|
|
this.PTShare(title, img, sp, successcb, failcb);
|
|
},
|
|
|
|
captureShare(rc, title, stype, param, successcb, failcb, exinfo) {
|
|
var st = (new Date()).getTime();
|
|
let sp = this._owner.makeShareParam(stype, param, exinfo);
|
|
let uuid = this._owner.currUUID();
|
|
|
|
this.PTShareCapture(title, rc, sp);
|
|
},
|
|
|
|
PTInitShare(normalinfo) {
|
|
|
|
},
|
|
|
|
PTShare(content, imgurl, param, successcb, failcb) {
|
|
hbs.systemShare({
|
|
type: 'text/html',
|
|
data: content,
|
|
success:function(){
|
|
successcb && successcb();
|
|
},
|
|
fail:function(erromsg, errorcode){
|
|
console.log('share fail --- ' + errorcode + ':' + erromsg)
|
|
failcb && failcb(-3, param);
|
|
},
|
|
cancel:function(data){
|
|
console.log("share cancel:" + data)
|
|
failcb && failcb(-3, param);
|
|
},
|
|
complete:function(){console.log('share complete')}
|
|
});
|
|
|
|
},
|
|
|
|
PTShareCapture(content, rc, param, successcb, failcb) {
|
|
successcb && successcb();
|
|
},
|
|
|
|
PTOpenKF(cb, info) {
|
|
},
|
|
|
|
PTCreateGameClubButton(nleft, ntop, nwidth) {
|
|
return null;
|
|
},
|
|
/**
|
|
* @param {string} str 显示的文字
|
|
* @param {icon} icon 图标类型 默认'none';
|
|
* success: 显示成功图标
|
|
* loading: 显示加载图标
|
|
* none: 不显示图标,此时 title 文本最多可显示两行
|
|
* */
|
|
PTShowToast(str, icon) {
|
|
hbs.showToast({
|
|
title: str,
|
|
icon: 'none'
|
|
});
|
|
},
|
|
|
|
PTGotoApp(appid, apppath, exobj, cb, qdid, env, acontent) {
|
|
|
|
},
|
|
|
|
PTLogin(info, successcb, failcb) {
|
|
var self = this;
|
|
hbs.gameLogin({
|
|
forceLogin: 1,
|
|
appid: this.appid,
|
|
success: function (res) {
|
|
console.log('[hbs]hbs login success');
|
|
self._owner.login.login({token: res.playerId, successcb, failcb});
|
|
},
|
|
fail: function (res) {
|
|
console.log('[hbs]login fail!', res);
|
|
failcb && failcb(0, res ? res.errcode : -1, res ? res.data : '');
|
|
}
|
|
});
|
|
},
|
|
|
|
//广告相关
|
|
PTInitADService() {
|
|
|
|
},
|
|
|
|
PTCreateBannerAD(adid, st) {
|
|
return null;
|
|
},
|
|
|
|
PTCreateVideoAD(adid) {
|
|
return null;
|
|
},
|
|
|
|
PTCreateInsertAD(adid) {
|
|
return null;
|
|
},
|
|
|
|
PTSetVideoADCallback(adobj, adowner, cb) {
|
|
|
|
},
|
|
|
|
PTVibrateShort(successcb, failcb) {
|
|
hbs.vibrateShort({
|
|
success: () => {
|
|
successcb && successcb();
|
|
},
|
|
fail: () => {
|
|
failcb && failcb();
|
|
}
|
|
})
|
|
},
|
|
|
|
PTVibrateLong(successcb, failcb) {
|
|
hbs.vibrateLong({
|
|
success: () => {
|
|
successcb && successcb();
|
|
},
|
|
fail: () => {
|
|
failcb && failcb();
|
|
}
|
|
})
|
|
},
|
|
|
|
/**
|
|
* @return {null}
|
|
*/
|
|
PTOpenDataContext() {
|
|
return null;
|
|
},
|
|
|
|
PTPostOpenMsg(msg) {
|
|
const openDataContext = this.PTOpenDataContext();
|
|
openDataContext && openDataContext.postMessage(msg);
|
|
},
|
|
|
|
// 排行榜相关
|
|
saveRankData(nscore, nmoney, stitle) {
|
|
const openDataContext = this.PTOpenDataContext();
|
|
openDataContext && openDataContext.postMessage({
|
|
type: 'save_data',
|
|
score: nscore,
|
|
money: nmoney,
|
|
title: stitle
|
|
});
|
|
},
|
|
|
|
showRankData() {
|
|
const openDataContext = this.PTOpenDataContext();
|
|
openDataContext && openDataContext.postMessage({
|
|
type: 'friends_all'
|
|
});
|
|
},
|
|
|
|
hideRankData() {
|
|
const openDataContext = this.PTOpenDataContext();
|
|
openDataContext && openDataContext.postMessage({
|
|
type: 'friends_all_hide'
|
|
});
|
|
},
|
|
|
|
prevRankPage() {
|
|
const openDataContext = this.PTOpenDataContext();
|
|
openDataContext && openDataContext.postMessage({
|
|
type: 'pagechange',
|
|
prev: 1
|
|
});
|
|
},
|
|
|
|
nextRankPage() {
|
|
const openDataContext = this.PTOpenDataContext();
|
|
openDataContext && openDataContext.postMessage({
|
|
type: 'pagechange',
|
|
next: 1
|
|
});
|
|
},
|
|
|
|
PTADWatch(adid, successcb, failcb) {
|
|
failcb && failcb(adid, {}, true, adid);
|
|
},
|
|
|
|
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_HUAWEI;
|