|
|
@ -2,7 +2,8 @@ |
|
|
import Dialog from '../../../components/dialog/dialog' |
|
|
import Dialog from '../../../components/dialog/dialog' |
|
|
import { finalizeToken } from "../../api/user" |
|
|
import { finalizeToken } from "../../api/user" |
|
|
const util = require('../../../utils/util') |
|
|
const util = require('../../../utils/util') |
|
|
const event = require('../../../utils/event.js') |
|
|
|
|
|
|
|
|
const event = require('../../../utils/event') |
|
|
|
|
|
const storage = require('../../../utils/storage') |
|
|
const app = getApp() |
|
|
const app = getApp() |
|
|
|
|
|
|
|
|
Component({ |
|
|
Component({ |
|
|
@ -33,7 +34,6 @@ Component({ |
|
|
// resume的处理;
|
|
|
// resume的处理;
|
|
|
onRestart: function () { |
|
|
onRestart: function () { |
|
|
this.setUserInfo() |
|
|
this.setUserInfo() |
|
|
this.fetchCreditInfo() |
|
|
|
|
|
this.data.firstShow = true |
|
|
this.data.firstShow = true |
|
|
}, |
|
|
}, |
|
|
onEvent: function (message) { |
|
|
onEvent: function (message) { |
|
|
@ -44,53 +44,43 @@ Component({ |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
setUserInfo: function(){ |
|
|
setUserInfo: function(){ |
|
|
if(!app.accountInfo){ |
|
|
|
|
|
|
|
|
if(!app.userInfo){ |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
var nickname = '' |
|
|
var nickname = '' |
|
|
if(app.accountInfo.isAuth) { |
|
|
|
|
|
nickname = app.accountInfo.realName.substring(0, 14) |
|
|
|
|
|
} else if(!util.isEmpty(app.accountInfo.nickname)){ |
|
|
|
|
|
nickname = app.accountInfo.nickname.substring(0, 14) |
|
|
|
|
|
} else if(!util.isEmpty(app.accountInfo.realName)){ |
|
|
|
|
|
nickname = app.accountInfo.realName.substring(0, 14) |
|
|
|
|
|
|
|
|
if(app.userInfo.isAuth) { |
|
|
|
|
|
nickname = app.userInfo.realName.substring(0, 14) |
|
|
|
|
|
} else if(!util.isEmpty(app.userInfo.nickname)){ |
|
|
|
|
|
nickname = app.userInfo.nickname.substring(0, 14) |
|
|
|
|
|
} else if(!util.isEmpty(app.userInfo.realName)){ |
|
|
|
|
|
nickname = app.userInfo.realName.substring(0, 14) |
|
|
} |
|
|
} |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
avatarUrl: util.isEmpty(app.accountInfo.avatarUrl) ? '/assets/image/ygImg.png' : app.accountInfo.avatarUrl, |
|
|
|
|
|
userInfo: app.accountInfo, |
|
|
|
|
|
|
|
|
avatarUrl: util.isEmpty(app.userInfo.avatarUrl) ? '/assets/image/ygImg.png' : app.userInfo.avatarUrl, |
|
|
|
|
|
userInfo: app.userInfo, |
|
|
userName: nickname, |
|
|
userName: nickname, |
|
|
height: app.globalData.safeFragmentHeight |
|
|
height: app.globalData.safeFragmentHeight |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
toUserInfo: function(){ |
|
|
toUserInfo: function(){ |
|
|
if(!app.accountInfo){ |
|
|
|
|
|
|
|
|
if(!app.userInfo){ |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
if(!app.accountInfo.isAuth){ |
|
|
|
|
|
|
|
|
if(!app.userInfo.isAuth){ |
|
|
wx.navigateTo({ url: '/pages/home/authory/index' }) |
|
|
wx.navigateTo({ url: '/pages/home/authory/index' }) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
fetchCreditInfo: function(){ |
|
|
|
|
|
if(!app.accountInfo || util.isEmpty(app.accountInfo.enterpriseId)){ |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
getCreditInfo({enterpriseId: app.accountInfo.enterpriseId}).then(result => { |
|
|
|
|
|
this.setData({ creditInfo: result.data }) |
|
|
|
|
|
}).catch(error => { }) |
|
|
|
|
|
}, |
|
|
|
|
|
orderList: function(){ |
|
|
orderList: function(){ |
|
|
wx.navigateTo({ url: '/pages/mall/order-list/index' }) |
|
|
wx.navigateTo({ url: '/pages/mall/order-list/index' }) |
|
|
}, |
|
|
}, |
|
|
tipApply: function(){ |
|
|
|
|
|
wx.navigateTo({ url: '/pages/htmls/credit/index' }) |
|
|
|
|
|
}, |
|
|
|
|
|
loginOut: function () { |
|
|
loginOut: function () { |
|
|
Dialog.confirm({ title: '温馨提示', message: '确定退出云印通账号?' }).then(() => { |
|
|
Dialog.confirm({ title: '温馨提示', message: '确定退出云印通账号?' }).then(() => { |
|
|
wx.removeStorageSync('Authorization') |
|
|
|
|
|
|
|
|
storage.remove('Authorization') |
|
|
app.globalData.token = null |
|
|
app.globalData.token = null |
|
|
app.accountInfo = null |
|
|
|
|
|
this.setData({ userInfo: null, avatarUrl: '/assets/image/ygImg.png', creditInfo: { availableCreditLine: 0, creditLine: 0, usedCreditLine: 0.00 }}) |
|
|
|
|
|
|
|
|
app.userInfo = null |
|
|
|
|
|
this.setData({ userInfo: null, avatarUrl: '/assets/image/ygImg.png' }) |
|
|
finalizeToken() |
|
|
finalizeToken() |
|
|
|
|
|
wx.redirectTo({ url: '/pages/login/index' }) |
|
|
event.emit('EventMessage', { what: 888, desc: 'Logout' }) |
|
|
event.emit('EventMessage', { what: 888, desc: 'Logout' }) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|