Browse Source

webpage

dev
jiazhipeng 7 months ago
parent
commit
4e1f539989
  1. 108
      subPackages/webPage/webPage.vue

108
subPackages/webPage/webPage.vue

@ -3,26 +3,108 @@
</template> </template>
<script> <script>
import Base from "@/components/Base";
export default { export default {
extends: Base,
data() { data() {
return { return {
url: '' url: '',
saveUrl: '',
} }
}, },
onLoad(option) { onLoad(option) {
if (option.url) { // if (option.url) {
try { // try {
this.url = decodeURIComponent(option.url); // this.url = decodeURIComponent(option.url);
} catch (error) { // } catch (error) {
console.error('URL解码出错:', error); // console.error('URL:', error);
this.url = uni.getStorageSync('webUrl'); // this.url = uni.getStorageSync('webUrl');
} // }
} else { // } else {
this.url = uni.getStorageSync('webUrl'); // this.url = uni.getStorageSync('webUrl');
} // }
console.log(this.url) // 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')
// 使web-view // 使web-view
} },
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; //
}
},
} }
</script> </script>

Loading…
Cancel
Save