Commit e0d02a23 authored by dlkong's avatar dlkong

横屏修改

parent b6065533
<template> <template>
<div class="wrap" ref="mapmidbox"> <div class="wrap" ref="mapmidbox">
<van-sticky> <van-sticky v-if="showHeader">
<header class="header"> <header class="header">
<span @click="close" class="iconLeft"> 关闭</span> <span @click="close" class="iconLeft"> 关闭</span>
<span>{{text}}</span> <span>{{text}}</span>
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
</grid-layout> </grid-layout>
<div class="setBtns"> <div class="setBtns">
<van-button @click="addItem" type="info" size="mini" v-if="!isView">添加房间</van-button> <van-button @click="addItem" type="info" size="mini" v-if="!isView">添加房间</van-button>
<van-grid direction="horizontal" :column-num="2" class="footer"> <van-grid direction="horizontal" :column-num="2" class="footer" v-if="isView">
风险等级图例: 风险等级图例:
<span class="riskTab type1"></span>重大风险 <span class="riskTab type1"></span>重大风险
<span class="riskTab type2"></span>较大风险 <span class="riskTab type2"></span>较大风险
...@@ -101,44 +101,99 @@ export default { ...@@ -101,44 +101,99 @@ export default {
roomName:'', roomName:'',
columns: ['办公', '餐饮', '住宅', '超市'], columns: ['办公', '餐饮', '住宅', '超市'],
colorList:['#FF4433','#FF9800','#FFFF00','#0091EA'], colorList:['#FF4433','#FF9800','#FFFF00','#0091EA'],
isView:true,// true:查看页面; false: 添加页面 isView:false,// true:查看页面; false: 添加页面
showHeader:true
} }
}, },
props:{
isViews: {
type: Boolean,
default: false,
},
},
mounted() { mounted() {
// screenfull.toggle(this.$refs.mapbox); // screenfull.toggle(this.$refs.mapbox);
// this.$nextTick(() => { this.$nextTick(() => {
// this.rotateBox(); // this.rotateBox();
// }); this.initRotate();
this.isView = this.$route.params.isView? true : false });
if (this._props.isViews) {
console.log('作为组件传值==>>',)
this.isView = true
this.showHeader = false
}
if (this.$route.params.isView) {
this.isView = true
}
this.getRoomInfo() this.getRoomInfo()
window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", this.orientationChange, false);
}, },
methods: { methods: {
orientationChange(){
if (window.orientation === 180 || window.orientation === 0) {
console.log('竖屏状态!');
}
if (window.orientation === 90 || window.orientation === -90 ){
console.log('横屏状态!');
}
// let width = document.documentElement.clientWidth//页面宽度
// let height = document.documentElement.clientHeight//页面高度
// console.log('width==>>',width)
// console.log('height==>>',height)
this.rotateBox()
},
initRotate(){
let width = document.documentElement.clientWidth,//页面宽度
height = document.documentElement.clientHeight,//页面高度
wrapper = this.$refs.mapmidbox,//需要横屏的块,与全屏的块要区分开,不区分全屏的块无法显示横屏效果
style = "";//样式
console.log('width==>>',width)
console.log('height==>>',height)
style += "width:" + height + "px;";
style += "height:" + width + "px;";
style += "-webkit-transform: rotate(90deg); transform: rotate(90deg);";
// 注意旋转中点的处理
style +=
"-webkit-transform-origin: " + width / 2 + "px " + width / 2 + "px;";
style += "transform-origin: " + width / 2 + "px " + width / 2 + "px;";
wrapper.style.cssText = style;
},
rotateBox() { rotateBox() {
this.isScreenFull = !this.isScreenFull;//是否全屏状态 this.isScreenFull = !this.isScreenFull;//是否全屏状态
let width = document.documentElement.clientWidth,//页面宽度 let width = document.documentElement.clientWidth,//页面宽度
height = document.documentElement.clientHeight,//页面高度 height = document.documentElement.clientHeight,//页面高度
wrapper = this.$refs.mapmidbox,//需要横屏的块,与全屏的块要区分开,不区分全屏的块无法显示横屏效果 wrapper = this.$refs.mapmidbox,//需要横屏的块,与全屏的块要区分开,不区分全屏的块无法显示横屏效果
style = "";//样式 style = "";//样式
if (height < width) {//注意原来就是宽屏时不用横屏 console.log('width==>>',width)
return; console.log('height==>>',height)
} // if (height < width) {//注意原来就是宽屏时不用横屏
if (this.isScreenFull) { // return;
// }
if (height < width) {
// 横屏 // 横屏
style += "width:" + height + "px;"; style += "width:" + height + "px;";
style += "height:" + width + "px;"; style += "height:" + width + "px;";
style += "-webkit-transform: rotate(90deg); transform: rotate(90deg);"; style += "-webkit-transform: rotate(0deg); transform: rotate(0deg);";
// 注意旋转中点的处理 // 注意旋转中点的处理
style += style +=
"-webkit-transform-origin: " + width / 2 + "px " + width / 2 + "px;"; "-webkit-transform-origin: " + width / 2 + "px " + width / 2 + "px;";
style += "transform-origin: " + width / 2 + "px " + width / 2 + "px;"; style += "transform-origin: " + width / 2 + "px " + width / 2 + "px;";
} else { } else {
// 竖屏 // 竖屏
// style += "width:" + height + "px;";
// style += "height:" + width + "px;";
// style += "-webkit-transform: rotate(90deg); transform: rotate(90deg);";
// // 注意旋转中点的处理
// style +=
// "-webkit-transform-origin: " + width / 2 + "px " + width / 2 + "px;";
// style += "transform-origin: " + width / 2 + "px " + width / 2 + "px;";
style += "width:100%"; style += "width:100%";
style += "height:100%;"; style += "height:100%;";
style += "-webkit-transform: rotate(0); transform: rotate(0);"; style += "-webkit-transform: rotate(0); transform: rotate(0);";
style += "-webkit-transform-origin: 0 0;"; style += "-webkit-transform-origin: 0 0;";
style += "transform-origin: 0 0;"; style += "transform-origin: 0 0;";
} }
console.log('style==>>',style)
wrapper.style.cssText = style; wrapper.style.cssText = style;
}, },
getRoomInfo(){ getRoomInfo(){
...@@ -160,7 +215,7 @@ export default { ...@@ -160,7 +215,7 @@ export default {
} }
this.layout.push(item.position) this.layout.push(item.position)
}) })
console.log('layout==>>',this.layout) // console.log('layout==>>',this.layout)
} }
}).catch((err) => { }).catch((err) => {
console.log('err==>>',err) console.log('err==>>',err)
...@@ -182,8 +237,11 @@ export default { ...@@ -182,8 +237,11 @@ export default {
}, },
// 删除 // 删除
removeItem: function (val) { removeItem: function (val) {
// const index = this.layout.map(item => item.i).indexOf(val); if (val == '') {
// this.layout.splice(index, 1); const index = this.layout.map(item => item.i).indexOf(val);
this.layout.splice(index, 1);
return
}
postFun('/ledger/room/delete/'+val).then((res) => { postFun('/ledger/room/delete/'+val).then((res) => {
if (res.code == 200) { if (res.code == 200) {
Toast.success('删除成功'); Toast.success('删除成功');
...@@ -235,13 +293,13 @@ export default { ...@@ -235,13 +293,13 @@ export default {
h: 3, h: 3,
i: '', i: '',
name: this.roomName, name: this.roomName,
c: '#eee', c: '#0091EA',
type:this.roomType, type:this.roomType,
isDraggable:true, isDraggable:true,
isResizable:true isResizable:true
} }
this.layout.push(this.layOutItem) this.layout.push(this.layOutItem)
console.log('layOutItem==>>',this.layOutItem) // console.log('layOutItem==>>',this.layOutItem)
}, },
onConfirm(value) { onConfirm(value) {
this.roomType = value; this.roomType = value;
...@@ -252,11 +310,15 @@ export default { ...@@ -252,11 +310,15 @@ export default {
</script> </script>
<style scoped > <style scoped >
.router-view{
padding-bottom: 0px !important;
}
.wrap{ .wrap{
height: 100vh; height: 100vh;
width: 100vw; width: 100vw;
/* transform: rotate(90deg); /* transform: rotate(90deg);
transform-origin: bottom left; */ transform-origin: bottom left; */
position: relative;
} }
.footer{ .footer{
/* position: fixed; */ /* position: fixed; */
...@@ -298,9 +360,12 @@ export default { ...@@ -298,9 +360,12 @@ export default {
/*************************************/ /*************************************/
.setBtns{ .setBtns{
position: fixed; /* position: fixed;
top:auto;
right: auto;
left: 0; left: 0;
bottom: 0; bottom: 0; */
margin-top: 10px;
font-size: 0.3rem; font-size: 0.3rem;
padding: 10px; padding: 10px;
vertical-align: middle; vertical-align: middle;
...@@ -342,6 +407,7 @@ export default { ...@@ -342,6 +407,7 @@ export default {
.vue-grid-item .text { .vue-grid-item .text {
writing-mode:vertical-rl; writing-mode:vertical-rl;
-webkit-writing-mode: vertical-rl;
font-size: 10cqw; font-size: 10cqw;
display: flex; display: flex;
align-items: center; align-items: center;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment