You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
2.1 KiB
100 lines
2.1 KiB
const event = require('../../utils/event')
|
|
const app = getApp()
|
|
|
|
Component({
|
|
/**
|
|
* 组件的一些选项
|
|
*/
|
|
options: {
|
|
addGlobalClass: true,
|
|
multipleSlots: true
|
|
},
|
|
/**
|
|
* 组件的对外属性
|
|
*/
|
|
properties: {
|
|
bgColor: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
isCustom: {
|
|
type: [Boolean, String],
|
|
default: false
|
|
},
|
|
isBack: {
|
|
type: [Boolean, String],
|
|
default: false
|
|
},
|
|
shadow: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
intercept: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
bgImage: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
fragment: {
|
|
type: Boolean,
|
|
default: false
|
|
}
|
|
},
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
StatusBar: app.globalData.StatusBar,
|
|
CustomBar: app.globalData.CustomBar,
|
|
Custom: app.globalData.Custom
|
|
},
|
|
lifetimes: {
|
|
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
|
|
attached: function () {
|
|
if(app.globalData.Custom){
|
|
this.setData({
|
|
StatusBar: app.globalData.StatusBar || 40,
|
|
CustomBar: app.globalData.CustomBar || (app.globalData.isIos ? 64 : 80),
|
|
Custom: app.globalData.Custom
|
|
})
|
|
} else {
|
|
event.on('InitMessage', this, this.onEvent)
|
|
}
|
|
},
|
|
detached: function(){
|
|
if(!app.globalData.Custom){
|
|
event.remove('InitMessage', this)
|
|
}
|
|
}
|
|
},
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
backspace() {
|
|
if (this.data.intercept) {
|
|
this.triggerEvent('customevent', null)
|
|
return
|
|
}
|
|
wx.navigateBack()
|
|
},
|
|
onEvent: function(message){
|
|
if (message.what == 8) {
|
|
this.setData({
|
|
StatusBar: app.globalData.StatusBar || 40,
|
|
CustomBar: app.globalData.CustomBar || (app.globalData.isIos ? 64 : 80),
|
|
Custom: app.globalData.Custom
|
|
})
|
|
}
|
|
},
|
|
toHome() {
|
|
if (app.globalData.userInfo.userId) {
|
|
wx.redirectTo({ url: '/pages/index/index' })
|
|
} else {
|
|
wx.reLaunch({ url: '/pages/login/index' })
|
|
}
|
|
}
|
|
}
|
|
})
|