WechatOwnerService/pages/hcWebView/hcWebView.vue
2022-06-17 00:37:42 +08:00

70 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"  :src="url"  @message="reciveMessage"></web-view>
</view>
</template>
<script>
import conf from '../../conf/config.js'
import {
decodeUrl
} from '../../lib/java110/utils/UrlUtil.js'
import {
reciveMessage
} from '../../api/webView/webViewApi.js'
import {
isNull
} from '../../lib/java110/utils/StringUtil.js'
import {
getStorageSync
} from '../../lib/java110/utils/StorageUtil.js'
import {getMallCommunityId} from '../../api/community/communityApi.js'
import mapping from '../../constant/MappingConstant.js'
export default {
data() {
return {
url: ''
}
},
onLoad(options) {
let _url = options.url;
if (isNull(_url)) {
_url = getStorageSync(mapping.HC_MALL_CUR_URL);
}
if (_url.indexOf("http") < 0 && _url.indexOf("https") < 0) {
_url = conf.mallUrl + '#' + _url;
}
_url = decodeUrl(_url)
if(_url.indexOf("?")>0){
_url = _url +"&hcCommunityId="+getMallCommunityId();
}else{
_url = _url +"?hcCommunityId="+getMallCommunityId();
}
// #ifdef H5
_url = _url +"&mallFrom=HC_H5"
// #endif
// #ifndef H5
_url = _url +"&mallFrom=HC_APP"
// #endif
this.url = _url;
},
methods: {
onReciveMessage: function(event) {
console.log('商城回传的参数', event);
event.data = JSON.parse(event.data);
reciveMessage(event);
}
}
}
</script>
<style>
.h5-html {
width: 100%;
height: 100%;
}
</style>