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
| <template>
| <view>
| <web-view :webview-styles="webviewStyles" :src="webviewUrl" @message='received'></web-view>
|
| </view>
|
| </template>
|
| <script>
| var wv;
| export default {
| data() {
| return {
| empowerModel: false,
| webviewUrl: '',
| user:'',
| webviewStyles: {
| progress: {
| color: '#EE1B14'
| }
| },
| }
| },
| onLoad(options) {
| if(!this.hasLogin){
| uni.reLaunch({
| url:"/pages/login/wxlogin"
| })
| }
| else{
| const value = uni.getStorageSync('userInfo');
| this.user = value;
| if(options.t_url)
| {
| console.log(encodeURI(decodeURIComponent(options.t_url)+"?token="+value.token+"&userid="+value.id));
| this.webviewUrl = encodeURI(decodeURIComponent(options.t_url)+"?token="+value.token+"&userid="+value.id);
| }
| }
|
| },
| onReady() {
| this.clearMuiBack();
| },
|
| methods: {
|
| received(e) {
| var res=e.detail.data[0];
| if(res.action=='back')
| {
| this.backLast();
| }
| },
| backLast()
| {
| uni.navigateBack({
| delta: 1
| });
| },
| // 关闭mui返回
| clearMuiBack() {
| // #ifdef APP-PLUS
| var currentWebview = this.$scope.$getAppWebview().children()[0];
| //监听注入的js
| currentWebview.addEventListener("loaded", function() {
| currentWebview.evalJS("mui.init({keyEventBind: {backbutton: false }});");
| });
| // #endif
| },
|
| },
| onNavigationBarButtonTap(e) {
| // #ifdef APP-PLUS
| const currentWebview = this.$scope.$getAppWebview(); //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效,非v3编译模式使用this.$mp.page.$getAppWebview()
| var wv = currentWebview.children()[0]
| wv.reload();
| // #endif
| console.log(JSON.stringify(e))
| },
| }
| </script>
|
| <style>
|
| </style>
|
|