WechatOwnerService/pages/homemaking/homemaking.vue
2021-09-05 01:16:30 +08:00

75 lines
1.5 KiB
Vue
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="h5-html">
 <web-view ref="webview" id="homemarkingWebView" class="wuixw"  :src="url"  @onPostMessage="onReciveMessage">
</web-view>
</view>
</template>
<script>
import conf from '../../conf/config.js'
import {
reciveMessage,
getHcCode
} from '../../api/webView/webViewApi.js'
import {
decodeUrl
} from '../../utils/UrlUtil.js';
import {
getStorageSync,
setStorageSync
} from '../../utils/StorageUtil.js'
export default {
data() {
return {
url: '',
communityId: ''
}
},
onLoad(options) {
let _that = this;
let _url = options.url;
_url = decodeUrl(_url);
setStorageSync('_go_back_refresh', 0);
//刷新hcCode
this.vc.getCurCommunity()
.then(function(_communityInfo) {
_that.communityId = _communityInfo.communityId;
})
.then(function() {
_that.url = conf.mallUrl + "#/pages/homemaking/index?mallFrom=HC&hcCommunityId=" + _that
.communityId;
})
},
onShow() {
let that = this;
let _goBackRefresh = getStorageSync('_go_back_refresh');
if (_goBackRefresh == 1) {
// #ifdef H5
document.getElementsByTagName('iframe').forEach(item => {
console.log(item.id);
if('homemarkingWebView' == item.id){
item.contentWindow.location.href = that.url;
}
})
// #endif
}
setStorageSync('_go_back_refresh', 0);
},
methods: {
onReciveMessage: function(event) {
reciveMessage(event);
}
}
}
</script>
<style>
.h5-html {
width: 100%;
height: 100%;
}
</style>