常熟
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
2.8 KiB

7 months ago
<template>
<web-view :src="url"></web-view>
</template>
<script>
7 months ago
import Base from "@/components/Base";
7 months ago
export default {
7 months ago
extends: Base,
7 months ago
data() {
return {
7 months ago
url: '',
saveUrl: '',
7 months ago
}
},
onLoad(option) {
7 months ago
// if (option.url) {
// try {
// this.url = decodeURIComponent(option.url);
// } catch (error) {
// console.error('URL解码出错:', error);
// this.url = uni.getStorageSync('webUrl');
// }
// } else {
// this.url = uni.getStorageSync('webUrl');
// }
// return;
let url = ''
let that = this
if (option.url) {
url = decodeURIComponent(option.url)
}else{
url = decodeURIComponent(uni.getStorageSync('webUrl'))
}
if (url.toLowerCase().indexOf('m.cloud.sz-trip.com')>=0) {
this.handleJDSZ(url)
setTimeout(()=>{
that.saveUrl = url
},500)
} else {
this.url = url
this.saveUrl = url
}
console.log(this.url, 'onload')
7 months ago
// 传入需要跳转的链接 使用web-view标签进行跳转
7 months ago
},
onShow() {
console.log(this.url, this.saveUrl, 'onshow')
if (!this.url && this.saveUrl) {
let param = this.getUrlParam(this.saveUrl)
console.log(param)
this.checkIsLoginJdsz().then(res => {
if(res) {
param.token = res
param.isKunshan = 1
let baseUrl = param.tempUrl
let queryString = Object.entries(param).filter(v=>v[0]!='tempUrl')
.map(([key, value]) => `${(key)}=${(value)}`)
.join('&');
const fullUrl = `${baseUrl}?${queryString}`;
console.log(fullUrl);
this.url = fullUrl
}
})
}
},
methods: {
handleJDSZ (url) {
let param = this.getUrlParam(url)
console.log(param)
this.checkIsLoginJdsz().then(res => {
if(res) {
param.token = res
param.isKunshan = 1
let baseUrl = param.tempUrl
let queryString = Object.entries(param).filter(v=>v[0]!='tempUrl')
.map(([key, value]) => `${(key)}=${(value)}`)
.join('&');
const fullUrl = `${baseUrl}?${queryString}`;
console.log(fullUrl);
this.url = fullUrl
}
}).finally(()=>{
this.saveUrl = url
})
},
getUrlParam(url) {
var theParam = {tempUrl: url};
let searchStartIndex = url.indexOf("?")
if (searchStartIndex>=0) {
theParam.tempUrl = url.substring(0,searchStartIndex);
var strs = url.substring(searchStartIndex+1);
strs = strs.split("&"); //将获取到的字符串从&分割,输出参数数组,即输出[参数1=xx,参数2=xx,参数3=xx,...]的数组形式
for(var i = 0; i < strs.length; i ++) { //遍历参数数组
theParam[strs[i].split("=")[0]]=decodeURIComponent(strs[i].split("=")[1]);
}
}
return theParam; //返回参数值
}
},
7 months ago
}
</script>
<style lang="scss" scoped>
</style>