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

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