改善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", "description": "A WePY project",
"setting": { "setting": {
"urlCheck": true, "urlCheck": false,
"es6": false, "es6": false,
"postcss": false, "postcss": false,
"minified": false, "minified": false,

View File

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

View File

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

View File

@ -189,8 +189,19 @@ var SDKManage = function() {
]; ];
this.doLogin(); 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.logShareInvite(this.shareInfo.inviter, this.shareInfo.type, this.shareInfo.id, this.shareInfo.param);
this.gamelog.logSystemInfo(this.systemInfo); this.gamelog.logSystemInfo(this.systemInfo);
if (this.shareInfo && this.shareInfo.id && this.shareInfo.id != '') { 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); this.rsp && this.rsp.onLogin && this.rsp.onLogin(res);
successcb && successcb(res); successcb && successcb(res);
@ -635,5 +637,4 @@ var JCFW = {
}; };
module.exports = JCFW; module.exports = JCFW;

View File

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

View File

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

View File

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