configurationDetail.vue 1.63 KB
<template>
	<view class="content">
		<!-- 公共组件-每个页面必须引入 -->
		<public-module></public-module>
		<web-view :src="showConfiguration" bindload="bindload" binderror="binderror"></web-view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			showConfiguration: '',
			defauleConfigImage: 'https://dev.thingskit.com',
			params: ''
		};
	},
	onLoad(e) {
		uni.setStorageSync('getConfiguration', {
			isConfiguration: true
		});
		if (e.configId !== null) {
			this.params = e.configId;
			this.requestUrl(this.params);
		}
		// 隐藏原生的tabbar
		uni.hideTabBar();
	},
	onShow() {
		uni.setStorageSync('getConfiguration', {
			isConfiguration: true
		});
	},
	onUnload() {
		uni.setStorageSync('getConfiguration', {
			isConfiguration: false
		});
		uni.removeStorageSync('config');
	},
	methods: {
		// 网页加载成功时候触发此事件
		bindload(res) {
			console.log(res, res.detail);
		},
		// 网页加载失败的时候触发此事件
		binderror(err) {
			console.log(err, err.detail);
		},
		async requestUrl(e) {
			const httpData = {
				configurationId: e,
				lightbox: 1
			};
			const getUrl = await uni.$u.http.get('/', { params: httpData, custom: { load: false } });
			const pathUrl = uni.getStorageSync('config');
			const userInfo = uni.getStorageSync('userInfo') 
			this.showConfiguration = `${pathUrl.baseURL}/?configurationId=${e}&userId=${userInfo.userId}&lightbox=1`
			// this.showConfiguration = pathUrl.baseURL + '/' + '?' + 'configurationId=' + e + '&' + 'lightbox=' + 1;
		}
	}
};
</script>

<style lang="scss" scoped>
.content {
	background: #f8f9fa;
	min-height: 100vh;
}
</style>