<template>
|
<web-view class="web-view" :topBar="false" :update-title="false" :fullscreen="true" :src="url"
|
:style="{ width: windowW + 'px', height: windowH + 'px' }" @message="onHandleMessage"></web-view>
|
</template>
|
|
<script>
|
import {
|
mapGetters
|
} from "vuex";
|
import { toLogin } from "../../../libs/login";
|
export default {
|
//computed: mapGetters(['chatUrl']),
|
data() {
|
return {
|
windowH: 0,
|
windowW: 0,
|
url: '',
|
paramUrl: '',
|
shareObj: null,
|
isShare: '0'
|
}
|
},
|
onShow() {
|
let that = this;
|
let pages = getCurrentPages(),
|
currPage = pages[pages.length - 1];
|
console.log('------------------page onShow start-----------------');
|
console.log('route', currPage.route);
|
console.log('options', currPage.options);
|
console.log('------------------page onShow end-----------------');
|
let options = currPage.options;
|
if (options.webUel) {
|
that.paramUrl = decodeURIComponent(options.webUel);
|
}
|
that.url = '';
|
if (options.isShare) {
|
that.isShare = options.isShare;
|
}
|
if (that.isShare == '0') {
|
wx.hideShareMenu({
|
menus: ["shareAppMessage"]
|
});
|
|
} else {
|
wx.showShareMenu({
|
menus: ["shareAppMessage"]
|
})
|
}
|
// uni.setNavigationBarTitle({
|
// title: options.title ? decodeURIComponent(options.title) : ''
|
// })
|
try {
|
const res = uni.getSystemInfoSync();
|
that.windowW = res.windowWidth;
|
that.windowH = res.windowHeight;
|
} catch (e) {
|
// error
|
}
|
|
if (!options.needLogin || options.needLogin !== 'false') {
|
if (that.$store.getters.isBelong) {
|
that.belongInfoReadyFn({
|
isRegister: false
|
})
|
} else {
|
uni.$once('BELONG_READY', that.belongInfoReadyFn);
|
}
|
} else {
|
if (that.paramUrl) {
|
that.url = that.paramUrl;
|
}
|
}
|
|
},
|
onShareAppMessage: function () {
|
if (!this.isShare || this.isShare == '0') {
|
return {};
|
}
|
if (this.shareObj) {
|
let pages = getCurrentPages(),
|
currPage = pages[pages.length - 1];
|
let options = currPage.options;
|
this.addTrack('yy_contentPageShare', {
|
'sharePosition_var': options.from == 'button' ? '页面分享按钮' : '页面顶部',
|
'shareMethod_var': '微信好友',
|
'pageTitle_var': this.shareObj.activityTitle ? this.shareObj.activityTitle : '',
|
'pageType_var': this.shareObj.activityTitle ? this.shareObj.activityTitle : '',
|
'pagePath_var': currPage.route,
|
'productID_var': '-',
|
'productName_var': '-',
|
'contentId_var': '-',
|
'contentName_var': '-',
|
'contentType_var': '-',
|
'contentLabel_var': '-',
|
});
|
console.log(this.shareObj);
|
let path = this.shareObj.path;
|
let shareUrl = '';
|
if (path) {
|
shareUrl = '/pages/users/web_page/index?isShare=' + options.isShare + '&needLogin=' + (options.needLogin?options.needLogin:'true') + '&webUel=' + encodeURIComponent(path);
|
} else {
|
shareUrl = currPage.$page.fullPath;
|
}
|
return {
|
title: this.shareObj.title,
|
imageUrl: this.shareObj.imageUrl,
|
desc: this.shareObj.desc ? this.shareObj.desc : '',
|
path: shareUrl
|
};
|
} else {
|
return {}
|
}
|
},
|
methods: {
|
belongInfoReadyFn(data) {
|
let that = this;
|
console.log(1111, 'belongInfoReadyFn');
|
let pages = getCurrentPages(),
|
currPage = pages[pages.length - 1];
|
let options = currPage.options;
|
if (that.$store.getters.isLogin) {
|
if (this.paramUrl.indexOf('token') < 0) {
|
this.url = this.paramUrl + (this.paramUrl.indexOf('?') < 0 ? '?' : '&') + 'token=' + that.$store.getters.token + '&unionId=' + that.$store.getters.unionId;
|
} else {
|
this.url = this.paramUrl.replace("{{token}}", that.$store.getters.token).replace("{{unionId}}", that.$store.getters.unionId);
|
}
|
if (this.url.indexOf('title=') < 0 && options.title) {
|
this.url = this.url + (this.url.indexOf('?') < 0 ? '?' : '&') + 'title=' + encodeURIComponent(options.title);
|
}
|
} else {
|
uni.navigateTo({
|
url: '/pages/users/web_page/login?back_url=' + encodeURIComponent(currPage.$page.fullPath)
|
})
|
}
|
},
|
onHandleMessage: function (data) {
|
console.error("接收到消息:" + JSON.stringify(data.detail));
|
this.shareObj = data.detail.data[0];
|
}
|
},
|
}
|
</script>
|
<style>
|
uni-page-head {
|
display: none;
|
}
|
</style>
|