106 lines
2.1 KiB
JavaScript
106 lines
2.1 KiB
JavaScript
// components/header/header.js
|
|
Component({
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
title: {
|
|
type: String,
|
|
value: '智慧云馆'
|
|
},
|
|
icon: {
|
|
type: String,
|
|
value: '../../images/back.png'
|
|
},
|
|
showIcon: {
|
|
type: Boolean,
|
|
value: true
|
|
},
|
|
isGoHome: {
|
|
type: Boolean,
|
|
value: false
|
|
},
|
|
isHistory: {
|
|
type: Boolean,
|
|
value: false
|
|
},
|
|
isLogin: {
|
|
type: Boolean,
|
|
value: false
|
|
},
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
unIcon: false
|
|
},
|
|
|
|
ready() {
|
|
let pages = getCurrentPages();
|
|
this.setData({
|
|
showIcon: pages.length > 1,
|
|
|
|
})
|
|
// console.log(pages);
|
|
// if (this.isLogin()) {
|
|
// this.setData({
|
|
// unIcon: pages[pages.length - 2].data.gohome
|
|
// })
|
|
// }
|
|
// pages/register/index
|
|
// pages/facialCapturing/index options isPass 1
|
|
},
|
|
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
isLogin() {
|
|
let pages = getCurrentPages();
|
|
let currentPage = pages[pages.length - 1];
|
|
let perPage = pages[pages.length - 2]
|
|
if (currentPage.route == 'pages/login/index') {
|
|
return true;
|
|
}
|
|
if (currentPage.route == 'pages/register/index') {
|
|
return true;
|
|
}
|
|
if (currentPage.route == 'pages/facialCapturing/index' && currentPage.options.isPass == 1) {
|
|
return true;
|
|
}
|
|
return false;
|
|
},
|
|
iconClick() {
|
|
let pages = getCurrentPages();
|
|
let route = wx.getStorageSync('history');
|
|
if (this.data.isGoHome) {
|
|
wx.redirectTo({
|
|
url: '/pages/home/index',
|
|
})
|
|
} else if (this.data.isLogin) {
|
|
wx.redirectTo({
|
|
url: '/pages/login/index',
|
|
})
|
|
} else if (this.data.isHistory && route) {
|
|
|
|
if (pages[pages.length - 2].data.gohome) {
|
|
wx.reLaunch({
|
|
url: '/pages/home/index',
|
|
})
|
|
return;
|
|
}
|
|
wx.removeStorageSync('history');
|
|
wx.redirectTo({
|
|
url: route,
|
|
})
|
|
} else {
|
|
|
|
wx.navigateBack({
|
|
delta: 1,
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}) |