常熟
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.
 
 
 
 

109 lines
2.7 KiB

<template>
<web-view :src="url"></web-view>
</template>
<script>
export default {
data() {
return {
url: '',
saveUrl: '',
}
},
onLoad(option) {
if(option && option.scene) {
const scene = decodeURIComponent(option.scene);
console.log('scene', scene)
uni.setStorageSync("merchant_id", scene)
}
let that = this
this.Post({
type: 'webView',
},
'/api/public_service/getKumgangHeadImgList'
).then(res => {
let url = res.data[0].title
console.log(url)
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(111,this.url)
}
});
},
onShow() {
// 埋点
this.Post({
merchant_id: uni.getStorageSync("merchant_id") || ''
}, '/api/mini_program/recordQrCodeScan').then(res => {})
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.platform = 'changshu'
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.platform = 'changshu'
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>
<style lang="scss" scoped>
</style>