改善console.log

This commit is contained in:
zhl 2019-03-21 10:29:45 +08:00
parent 80a11defdb
commit 24fbe18a4a
9 changed files with 1218 additions and 1174 deletions

View File

@ -1,7 +1,7 @@
{
"description": "A WePY project",
"setting": {
"urlCheck": true,
"urlCheck": false,
"es6": false,
"postcss": false,
"minified": false,

View File

@ -22,6 +22,8 @@ import wepy from 'wepy'
import 'wepy-async-function'
import jcEvent from './common/jc-event';
import http from './utils/http';
import log, { hookConsoleLog } from './utils/logger';
import g from './common/global';
let sdkManage = require('./jcfw/SDKManage');
export default class extends wepy.app {
@ -54,6 +56,7 @@ export default class extends wepy.app {
super();
this.use('requestfix');
this.use('promisify');
(g.env === 'test') && hookConsoleLog();
sdkManage.init();
sdkManage.Login(() => {
let account = wepy.getStorageSync('account');
@ -201,5 +204,11 @@ export default class extends wepy.app {
getShareCount(cb) {
sdkManage.getAchievInviteeNum(cb);
}
getShareDetail(cb) {
sdkManage.queryAchievementShareDetail(cb);
}
updateUserInfo(allInfo, cb) {
sdkManage.updateUser(allInfo, cb);
}
}
</script>

View File

@ -1,4 +1,4 @@
const env = 'product'; //product, test
const env = 'test'; //product, test
export default {
env: env,
apiBase: env === 'test'? 'https://ghost-test.kingsome.cn' : 'https://ghost.kingsome.cn',

View File

@ -189,8 +189,19 @@ var SDKManage = function() {
];
this.doLogin();
};
this.queryAchievementShareDetail = function(cb) {
var callback = function(res) {
console.log('playerData.invitee_detail');
console.log(res);
if (cb) {
cb(res);
}
};
jcshare.queryAchievementShareDetail([1001], callback, function() {});
};
this.updateUser = function(allInfo, cb) {
jcfw.updateUser(allInfo, cb)
}
};

View File

@ -126,7 +126,9 @@ var JCFW = {
this.gamelog.logShareInvite(this.shareInfo.inviter, this.shareInfo.type, this.shareInfo.id, this.shareInfo.param);
this.gamelog.logSystemInfo(this.systemInfo);
if (this.shareInfo && this.shareInfo.id && this.shareInfo.id != '') {
this.share.acceptDailyInvite(this.shareInfo.param,this.shareInfo.id,()=>{}, ()=>{});
this.share.acceptDailyInvite(this.shareInfo.param, this.shareInfo.id, () => {
}, () => {
});
}
this.rsp && this.rsp.onLogin && this.rsp.onLogin(res);
successcb && successcb(res);
@ -635,5 +637,4 @@ var JCFW = {
};
module.exports = JCFW;

View File

@ -55,7 +55,7 @@ module.exports = {
if (!actionid) {
return;
}
let sid = inviterid? inviterid: "";
let sid = inviterid ? inviterid : '';
this.urlbd.clear();
this.urlbd.addKV('c', 'Fission')
.addKV('a', 'accept')
@ -149,7 +149,7 @@ module.exports = {
* @param {object} failcb
*/
acceptDailyInvite(actionid, inviterid, successcb, failcb) {
let sid = inviterid? inviterid: "";
let sid = inviterid ? inviterid : '';
this.urlbd.clear();
this.urlbd.addKV('c', 'DailyMission')
.addKV('a', 'acceptInvite')
@ -272,7 +272,7 @@ module.exports = {
* @param {object} failcb
*/
acceptRelayInvite(actionid, inviterid, successcb, failcb) {
let sid = inviterid? inviterid: "";
let sid = inviterid ? inviterid : '';
this.urlbd.clear();
this.urlbd.addKV('c', 'Relay')
.addKV('a', 'acceptInvite')
@ -337,7 +337,7 @@ module.exports = {
* @param {object} failcb
*/
acceptAchivementInvite(relationidlst, inviterid, successcb, failcb) {
let sid = inviterid? inviterid: "";
let sid = inviterid ? inviterid : '';
this.urlbd.clear();
this.urlbd.addKV('c', 'AchievementShare')
.addKV('a', 'acceptInvite')
@ -422,7 +422,6 @@ module.exports = {
failcb && failcb(errcode, 0, errmsg);
});
},
};
/**
* 普通分享
@ -436,7 +435,7 @@ module.exports = {
*/
shareNormal(content, imgurl, sharetype, shareparam, extrainfo, successcb, failcb) {
let uuid = this.owner ? this.owner.makeUUID() : '';
let qstr = "inviter_id="+ this.accountid + "&activity_param="
let qstr = 'inviter_id=' + this.accountid + '&activity_param='
+ shareparam + '&localuuid=' + uuid + '&sharetype=' + sharetype;
if (extrainfo) {
qstr += '&';
@ -452,17 +451,20 @@ module.exports = {
});
this.owner && this.owner.gamelog.logShare(sharetype, uuid, shareparam);
successcb && successcb();
}break;
}
break;
case 6002: {
}break;
}
},
break;
}
}
,
shareCapture(content, rc, sharetype, shareparam, extrainfo, successcb, failcb) {
let uuid = this.owner ? this.owner.makeUUID() : '';
let qstr = "inviter_id="+ this.accountid + "&activity_param="
let qstr = 'inviter_id=' + this.accountid + '&activity_param='
+ shareparam + '&localuuid=' + uuid + '&sharetype=' + sharetype;
if (extrainfo) {
qstr += '&';
@ -476,7 +478,7 @@ module.exports = {
width: rc.width,
height: rc.height,
destWidth: 500,
destHeight: 400,
destHeight: 400
});
wx.shareAppMessage({
@ -486,10 +488,12 @@ module.exports = {
});
this.owner && this.owner.gamelog.logShare(sharetype, uuid, shareparam);
successcb && successcb();
}break;
}
break;
case 6002: {
}break;
}
break;
}
},
@ -502,8 +506,7 @@ module.exports = {
.addKV('inviter_id', inviter_id);
if (relate_achivements) {
this.urlbd.addKV('relate_achivements', relate_achivements);
}
else{
} else {
this.urlbd.addKV('achievement_id', Number(achievement_id));
}
//console.log(this.urlbd.baseurl);
@ -523,7 +526,7 @@ module.exports = {
this.urlbd.addKV('c', 'AchievementShare')
.addKV('a', 'getInviteeNum')
.addKV('account_id', this.accountid)
.addKV('session_id', this.sessionid)
.addKV('session_id', this.sessionid);
// .addKV('achievement_ids', achievement_ids)
httpclient.httpGet(this.urlbd.baseurl, function(restext) {
var obj = JSON.parse(restext);
@ -539,5 +542,6 @@ module.exports = {
failcb && failcb(errcode, 0, errmsg);
});
},
};
}
}

View File

@ -1,5 +1,4 @@
import wepy from 'wepy'
export default class baseMixin extends wepy.mixin {
/**
* [公共方法]
@ -170,4 +169,15 @@ export default class baseMixin extends wepy.mixin {
console.log(info);
return (info.platform && (/^ios/.test(info.platform.toLowerCase()) || /^devtools/.test(info.platform.toLowerCase())));
}
jcLog(t, e, n) {
try {
n = n || 'debug';
e = e || n.toUpperCase();
const i = 'error' === n ? 'background: #c4161e; color: #fff' : 'warning' === n ? 'background: #ff8c1c; color: #fff' : 'info' === n ? 'background: #ff0080; color: #fff' : 'background: #44a5ab; color: #fff',
r = console.log('%c %c %c ==JCLOGGER== %c %c %c ' + e + ' ', 'background: #9854d8', 'background: #6c2ca7', 'color: #fff; background: #450f78;', 'background: #6c2ca7', 'background: #9854d8', i, void 0 !== t ? t : '');
return console.log.bind(console, r);
} catch (e) {
return console.log(e);
}
}
}

View File

@ -43,15 +43,15 @@
import wepy from 'wepy';
import Toast from 'wepy-com-toast';
import http from '../utils/http';
import base from '../mixins/base';
import tips from '../mixins/tips';
import cfg from '../mixins/cfg';
import recordCell from '../components/game-cell';
import recentGame from '../components/recent-game';
import zanLoadmore from '../components/zan-loadmore';
import jcEvent from '../common/jc-event';
import image from '../common/images';
import global from '../common/global';
import base from '../mixins/base';
import tips from '../mixins/tips';
import cfg from '../mixins/cfg';
export default class Index extends wepy.page {
mixins = [base, tips, cfg];
@ -104,7 +104,6 @@
})
}
};
onPullDownRefresh() {
this.initPageParam();
this.getAllData();
@ -123,6 +122,9 @@
async onLoad(options) {
let self = this;
wepy.showShareMenu({
withShareTicket: true
});
this.payVer = global.env === 'product' ? 'release' : 'develop';
if (!this.$parent.checkClientLogin()) {
this.getAllData();
@ -203,7 +205,9 @@
if (!cfg._getrewardtype) {
wepy.hideShareMenu();
} else {
wepy.showShareMenu();
wepy.showShareMenu({
withShareTicket: true
});
}
this.showAll = this.$showAll();
let userInfo = this.$parent.getUserInfo();
@ -248,7 +252,7 @@
async getUserInfo() {
try {
let res = await http.post('/api/emulated/user_info', {type: 'all'});
console.log(res);
this.debugLog(res);
if (res.userInfo) {
let user = res.userInfo;
this.score = user.score;
@ -301,7 +305,7 @@
self.noData = (self.records.length === 0);
self.$apply();
} else {
console.log('get game data error');
this.debugLog('get game data error');
self.loading = false
}
} catch (error) {
@ -325,7 +329,7 @@
shareTicket: res.shareTickets[0]
})
.then(res => {
console.log(res);
this.debugLog(res);
})
.catch(err => {
console.log(err)

View File

@ -18,11 +18,15 @@
<script>
import wepy from 'wepy'
import zanToast from '../components/zan-toast'
import base from '../mixins/base';
import tips from '../mixins/tips';
import cfg from '../mixins/cfg';
export default class Login extends wepy.page {
config = {
navigationBarTitleText: '授权'
}
mixins = [base, tips, cfg];
components = {
zanToast: zanToast
}
@ -41,9 +45,10 @@
bindGetUserInfo: function(e) {
let self = this
if (e.detail.userInfo) {
console.log(e.detail.userInfo)
this.jcLog(e.detail);
wepy.setStorageSync('userInfo', JSON.stringify(e.detail.userInfo));
self.$parent.updateGlobalData('userInfo', e.detail.userInfo);
self.$parent.updateUserInfo(e.detail);
wepy.navigateBack({
delta: 1
})