1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
| <template>
|
| <view class="content">
| <u-search shape="true" bg-color="rgba(255, 255, 255, 0.5)" placeholder="请输入作业内容" :show-action="false" v-model="keyword" @search="searchxinxi"
| style="width: 90%; top: 10%;left: 5%; position: absolute; z-index: 999999999;"></u-search>
|
| </view>
| </template>
|
| <script>
| export default {
| data() {
| return {
| link: 'http://hxuwb.com:8888/hxzkuwb/Home/AppMap.jsp',
| robot: 'http://hxuwb.com:8888/hxzkuwb/Home/AppMap.jsp',
| monitor: '',
| webViewObj: ''
| }
| },
| onLoad() {},
| created() {
| this.createView(this.robot)
| this.createBtn()
| },
| methods: {
| //动态创建web-view,传入url地址
| createView(url) {
| this.webViewObj = plus.webview.create("", "webview", {
| plusrequire: "none", //禁止远程网页使用plus的API,有些使用mui制作的网页可能会监听plus.key,造成关闭页面混乱,可以通过这种方式禁止
| //'uni-app': 'none', //不加载uni-app渲染层框架,避免样式冲突
| // top:uni.getSystemInfoSync().statusBarHeight+93 //放置在titleNView下方。如果还想在webview上方加个地址栏的什么的,可以继续降低TOP值
| top: uni.getSystemInfoSync() //放置在titleNView下方。如果还想在webview上方加个地址栏的什么的,可以继续降低TOP值
| })
| this.webViewObj.loadURL(url)
| this.webViewObj.addEventListener('loading', () => {
| uni.showLoading({
| title: '加载中',
| mask: true
| });
| }, false);
| this.webViewObj.addEventListener('loaded', () => {
| uni.hideLoading();
| }, false);
| var currentWebview = this.$scope.$getAppWebview(); //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效,非v3编译模式使用this.$mp.page.$getAppWebview()
| currentWebview.append(this.webViewObj); //一定要append到当前的页面里!!!才能跟随当前页面一起做动画,一起关闭
| },
| createBtn() {
| //创建按钮1
| let robotView = new plus.nativeObj.View('robot-btn', {
| bottom: '0px',
| left: '39%',
| height: '44px',
| width: '100px'
| },
| [{
| tag: 'img',
| id: 'robot',
| src: '/static/robot.png',
| position: {
| top: '0px',
| left: '0px',
| width: '68px',
| height: '28px'
| }
| },
|
| ]);
| //显示按钮1
| robotView.show();
| //按钮1添加点击事件
| robotView.addEventListener("click", (e) => {
| this.link = this.robot
| this.webViewObj.close()
| this.createView(this.robot)
| }, false);
|
| //创建按钮2
| let monitorView = new plus.nativeObj.View('monitor-btn', {
| bottom: '0px',
| left: '54%',
| height: '44px',
| width: '100px'
| },
| [{
| tag: 'img',
| id: 'monitor',
| src: '/static/monitor.png',
| position: {
| top: '0px',
| left: '0px',
| width: '68px',
| height: '28px'
| }
| }, ]);
| //按钮2显示
| monitorView.show();
| //按钮2添加点击事件
| monitorView.addEventListener("click", (e) => {
| this.link = this.monitor
| this.webViewObj.close()
| this.createView(this.monitor)
| }, false);
| }
| }
| }
| </script>
|
| <style>
| .content {
| position: relative;
| }
| </style>
|
|