123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <template>
- <view class="content">
- <view class="status_bar">
-
- </view>
- <web-view :src="url" :fullscreen='false' @message="messageData"></web-view>
- </view>
- </template>
- <script>
- const jpushModule = uni.requireNativePlugin('JG-JPush')
- var wv
- export default {
- data() {
- return {
- title: 'wdly',
-
- url: 'http://139.9.102.170:10012/#/',
-
-
- src: "",
- canBack: false,
- }
- },
- onBackPress() {
- if (wv && this.canBack) {
- wv.back();
- return true;
- }
- return false;
- },
- onReady() {
-
- var self = this;
- var currentWebview = this.$scope.$getAppWebview();
-
- setTimeout(function() {
- wv = currentWebview.children()[0];
- wv.addEventListener(
- "progressChanged",
- function(e) {
- wv.canBack(function(e) {
- self.canBack = e.canBack;
- });
- },
- false
- );
- }, 500);
-
- },
- onLoad() {
- var height = 0;
- uni.getSystemInfo({
-
- success: (sysinfo) => {
- console.log(sysinfo)
- height = sysinfo.windowHeight;
- },
- complete: () => {}
- });
- let info = uni.getSystemInfoSync();
- let top = info.statusBarHeight;
- console.log(info, 12312312312);
- var currentWebview = this.$scope.$getAppWebview();
- setTimeout(function() {
- var wv = currentWebview.children()[0];
- wv.setStyle({
- top: top,
-
- height: height - top,
- scalable: false,
- })
-
-
-
-
-
-
- }, 1000);
-
- uni.$on('connectStatusChange', (connectStatus) => {
- if (connectStatus) {
- var currentWebview = this.$scope.$getAppWebview();
- var wv = currentWebview.children()[0];
-
- jpushModule.getRegistrationID(result => {
- console.log(result, "注册ID.....")
- wv.evalJS(`getVueMessage(${JSON.stringify(result.registerID)})`);
- })
- }
- })
- },
- onUnload() {
-
- uni.$off('connectStatusChange')
- },
- methods: {
- messageData(e) {
- const data = e.detail.data
- let url = data[0].url
- uni.downloadFile({
- url: url,
- success: function(res) {
-
- if (res.statusCode === 200) {
-
- uni.openDocument({
- filePath: res.tempFilePath,
- success: function(res) {},
- fail: function(error) {}
- });
- }
- },
- fail: function(error) {}
- });
- }
- }
- }
- </script>
- <style>
- .content {}
- .status_bar {
- height: var(--status-bar-height);
- width: 100%;
- }
- </style>sss
|