Huanyuyuehui/pages/webview/webview.vue

62 lines
1.1 KiB
Vue

<template>
<web-view class="web-view" :webview-styles="webviewStyles" :src="url"></web-view>
</template>
<script>
import {
ERP_REGISTER_URI
} from '@/config/app';
export default {
data() {
return {
webviewStyles: {
progress: {
color: 'transparent'
}
},
url: ''
}
},
onLoad(options) {
if (options.url) {
let url = decodeURIComponent(options.url)
this.setData({
url: url
})
} else if (!options.do || !options.m) {
uni.navigateBack({
delta: 1
})
} else {
this.setData({
url: `${ERP_REGISTER_URI}?i=4&c=entry&do=${options.do}&m=${options.m}&adtag=${options?.adtag}&pid=${options?.pid}`
})
}
},
methods: {
setData(obj) {
let that = this;
let keys = [];
let val, data;
Object.keys(obj).forEach(function(key) {
keys = key.split('.');
val = obj[key];
data = that.$data;
keys.forEach(function(key2, index) {
if (index + 1 == keys.length) {
that.$set(data, key2, val);
} else {
if (!data[key2]) {
that.$set(data, key2, {});
}
}
data = data[key2];
})
});
}
}
}
</script>