blob: fab08d239be20cd3b09184543c46c87df0d62ef9 [file] [log] [blame]
guangchao.xu070005a2020-12-07 09:56:40 +08001<template>
2 <view>
3 <view class="status_bar"></view>
4 <web-view :webview-styles="webviewStyles" :src="src"></web-view>
5 </view>
6</template>
7
8<script>
9 export default {
10 data() {
11 return {
12 src: "",
13 webviewStyles: {
14 progress: {
15 color: '#2B9939'
16 }
17 },
18 userid: ""
19 }
20 },
21 onLoad(option) {
22 let that = this
23 let userid = uni.getStorageSync("userid")
guangchao.xu50e42382021-01-04 17:53:47 +080024 //that.userid = userid
guangchao.xu070005a2020-12-07 09:56:40 +080025 let url = option.url
guangchao.xuc43cf972021-01-18 13:37:55 +080026 // if (url.indexOf("?") > 0) {
27 // url = url + "&userid=" + userid
28 // } else {
29 // url = url + "?userid=" + userid
30 // }
guangchao.xu50e42382021-01-04 17:53:47 +080031 console.log(url)
guangchao.xu070005a2020-12-07 09:56:40 +080032 that.src = url
guangchao.xu070005a2020-12-07 09:56:40 +080033 },
guangchao.xuc43cf972021-01-18 13:37:55 +080034 onBackPress(options) {
35 uni.reLaunch({
36 url: '/pages/sub_tabbar/index'
37 })
38 return true
39 },
guangchao.xu070005a2020-12-07 09:56:40 +080040 onReady() {
guangchao.xuc43cf972021-01-18 13:37:55 +080041 let that = this
42 let userid = uni.getStorageSync("userid")
43 var pages = getCurrentPages()
44 var page = pages[pages.length - 1]
45 var currentWebview = page.$getAppWebview()
46 var url = currentWebview.children()[0].getURL()
47 var wx = currentWebview.children()[0]
48 wx.addEventListener('loaded', function(e) {
49 let newUrl = wx.getURL()
50 if (newUrl.indexOf("userid") > -1) {
51 //console.log(1)
52 return false
53 }
54 if (newUrl.indexOf("?") > 0) {
55 newUrl = newUrl + "&userid=" + userid
56 } else {
57 newUrl = newUrl + "?userid=" + userid
58 }
59 that.src = newUrl
60 }, false);
guangchao.xu070005a2020-12-07 09:56:40 +080061 },
62 }
63</script>
64
65<style scoped lang="scss">
66
67
68</style>