152 lines
4.0 KiB
Vue
152 lines
4.0 KiB
Vue
<template>
|
|
<view :class="themeType?'whiteHeaderBox':''">
|
|
<!-- 手机状态层 -->
|
|
<!-- <view :style="{ height: mobileTopHeight + 'px' }" class="statusBar"></view> -->
|
|
<view class="headerBox">
|
|
<u-icon v-if="iconType" class="backImg" @click="$emit('select')" v-show="showBack" name="list" size="40"></u-icon>
|
|
<uni-icons v-else @click="goBackFn" v-show="showBack" class="backImg" type="left" size="24"></uni-icons>
|
|
<slot></slot>
|
|
<view class="rightIcon">
|
|
<slot name="right"></slot>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
<script>
|
|
export default {
|
|
props:['showBack','themeType','iconType'],
|
|
data() {
|
|
return {
|
|
mobileTopHeight: 0
|
|
};
|
|
},
|
|
mounted() {
|
|
// if(uni.getMenuButtonBoundingClientRect()){
|
|
// this.mobileTopHeight = uni.getMenuButtonBoundingClientRect().top
|
|
// }else{
|
|
// this.mobileTopHeight = 0
|
|
// }
|
|
var that = this
|
|
uni.getSystemInfo({
|
|
success(res) {
|
|
console.log('res', )
|
|
that.mobileTopHeight = res.statusBarHeight ? res.statusBarHeight : window.plus ? uni.upx2px(44) : 0;
|
|
uni.setStorageSync('systemInfo',res)
|
|
console.log(1111, res)
|
|
}
|
|
})
|
|
console.log('this.mobileTopHeight',this.mobileTopHeight)
|
|
},
|
|
methods:{
|
|
goBackFn(){
|
|
let pages = getCurrentPages();
|
|
// let prevPage = pages[pages.length - 2]
|
|
|
|
if(pages.length > 1) {
|
|
uni.navigateBack({
|
|
success: function() {
|
|
// console.log('getCurrentPages()',getCurrentPages())
|
|
// let page = getCurrentPages()[0]; //跳转页面成功之后
|
|
// if(page.route=='pages/projectManage/projectManage'){
|
|
|
|
// }
|
|
// if (!page) return;
|
|
// page.onLoad(); //如果页面存在,则重新刷新页面
|
|
}
|
|
});
|
|
return
|
|
}
|
|
|
|
|
|
// uni.redirectTo({
|
|
// url: `/pages/workspace/workspace?current=${11}`
|
|
// });
|
|
// console.log('goBackFn', window.parent.postMessage)
|
|
console.log('当前环境:' + JSON.stringify(webUni) + JSON.stringify(uni));
|
|
// window.parent.postMessage({
|
|
// data: 1
|
|
// }, "*");
|
|
// uni.postMessage({
|
|
// data: {
|
|
// action: 'message'
|
|
// }
|
|
// });
|
|
// document.addEventListener('UniAppJSBridgeReady', function() {
|
|
// console.log('UniAppJSBridgeReady', document.getElementById('postMessage'))
|
|
// // document.getElementById('postMessage').addEventListener('click', function() {
|
|
// // console.log('postMessage触发了')
|
|
// // uni.postMessage({
|
|
// // data: {
|
|
// // action: 'message'
|
|
// // }
|
|
// // });
|
|
// // });
|
|
|
|
// });
|
|
const arrListCode = [{
|
|
code: 'wf66f6451c48b718d0aaf27522',
|
|
name: '安全检查',
|
|
path: '/pages/projectEnd/safeSame/index'
|
|
}, {
|
|
code: "wf67072b923afc947a1a819313",
|
|
name: '质量检查',
|
|
path: '/pages/projectEnd/qualityManage/index'
|
|
},{
|
|
code: "wf670a4a6c2384bf3e58f62681",
|
|
name: '质量监督',
|
|
path: '/pages/projectEnd/qualitySurveillance/index'
|
|
},{
|
|
code: "wf670735f73afc947a1a819314",
|
|
name: '文明施工',
|
|
path: '/pages/projectEnd/civilConstruction/constructionProblemRecord/index'
|
|
}]
|
|
let pathUrl = "/pages/projectEnd/projectIndex/projectIndex";
|
|
console.log('pages', pages)
|
|
|
|
const find = arrListCode.find(item => pages[0].options.code && pages[0].options.code.includes(item.code));
|
|
// console.log('prevPage',pages, pages[0].options.code)
|
|
if(find) {
|
|
pathUrl = find.path;
|
|
}
|
|
console.log('pathUrl', pathUrl)
|
|
if(window.plus) {
|
|
webUni.webView.postMessage({
|
|
data: {
|
|
type: "路由",
|
|
url: pathUrl
|
|
}
|
|
});
|
|
} else {
|
|
window.parent.postMessage({
|
|
data: {
|
|
type: "路由",
|
|
url: pathUrl
|
|
}
|
|
}, "*");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.statusBar{
|
|
background-color: #2a2b5b;
|
|
}
|
|
.whiteHeaderBox{
|
|
.backImg {
|
|
color: white !important;
|
|
}
|
|
.statusBar{
|
|
background-color: #2b8df3;
|
|
}
|
|
.rightIcon{
|
|
position: absolute;
|
|
right: 20rpx;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
z-index: 10;
|
|
}
|
|
}
|
|
</style>
|