改善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)
}
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

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
})