Files
ctms-client/pages/common/webview/index.vue
fm453 c62d15b288 首次完整推送,
V:1.20240808.006
2024-08-13 18:32:37 +08:00

104 lines
3.3 KiB
Vue

<template>
<view class="container">
<!-- #ifndef APP-PLUS -->
<uni-nav-bar class="status_bar" dark :fixed="true" shadow status-bar left-icon="left" left-text="" title=""
right-icon="refresh" @clickLeft="goBack" @clickRight="goRefresh" />
<!-- #endif -->
<view v-if="params.url">
<web-view :webview-styles="webviewStyles" :src="`${params.url}`"></web-view>
</view>
</view>
</template>
<script>
import store from '@/store/index.js';
import utils from "@/utils/common.js";
export default {
data() {
return {
params: {},
oldUrl: '', //储存传参的url
webviewStyles: {
progress: {
color: "#FF3333"
}
}
}
},
props: {
//接收父组件的数据
src: {
type: [String],
default: null
}
},
methods: {
goRefresh() {
//TBD
}
},
onLoad(event) {
// store.commit('user/login'); //调用登陆user的函数
this.params = event
if (!event.url) {
uni.showToast({
title: "未提供网址链接",
complete: () => {
uni.navigateBack()
}
})
} else {
let url = event.url;
this.oldUrl = url;
var user = store.state.userCloud;
if (url.substring(0, 4) === 'http') {
//打开网址
if (event.title) {
uni.setNavigationBarTitle({
title: event.title
})
}
if (user.hasLogin) {
var openid = user.openid;
utils.debug(openid)
this.params.url = url + '?&open_id=' + openid;
}
} else if (url.substring(0, 7) === '/pages/') {
//打开指定页面
uni.navigateTo({
url: url
})
} else {
uni.showModal({
title: "错误",
content: '不是一个有效的网站链接,' + '"' + url + '"',
showCancel: false,
confirmText: "知道了",
complete: () => {
uni.navigateBack()
}
});
uni.setNavigationBarTitle({
title: "页面路径错误"
});
}
}
},
onNavigationBarButtonTap(e) {
// #ifdef APP-PLUS
let currentWebview = this.$mp.page.$getAppWebview().children()[0]; //获取当前页面的webview对象
utils.debug(currentWebview);
// #endif
return;
}
}
</script>
<style>
@import url('../../ctms/statusBar.css');
/*针对 webview进行的设置*/
uni-app {
margin-top: 88rpx;
}
</style>