|
|
|
@ -1,88 +1,85 @@
|
|
|
|
<script setup>
|
|
|
|
<script setup>
|
|
|
|
import DraggableButton from "@/pages/components/goHome.vue";
|
|
|
|
import DraggableButton from "@/pages/components/goHome.vue";
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* name:
|
|
|
|
* name:
|
|
|
|
* user:sa0ChunLuyu
|
|
|
|
* user:sa0ChunLuyu
|
|
|
|
* date:2024年8月12日 19:47:35
|
|
|
|
* date:2024年8月12日 19:47:35
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
import {
|
|
|
|
import { ref } from 'vue'
|
|
|
|
ref
|
|
|
|
import { $response } from '@/api'
|
|
|
|
} from 'vue'
|
|
|
|
import { onShow } from '@dcloudio/uni-app'
|
|
|
|
import {
|
|
|
|
|
|
|
|
$response
|
|
|
|
// 1. 解构 props,命名更清晰,符合 Vue 最佳实践
|
|
|
|
} from '@/api'
|
|
|
|
const props = defineProps({
|
|
|
|
import {
|
|
|
|
|
|
|
|
onShow
|
|
|
|
|
|
|
|
} from '@dcloudio/uni-app'
|
|
|
|
|
|
|
|
const $props = defineProps({
|
|
|
|
|
|
|
|
openid: {
|
|
|
|
openid: {
|
|
|
|
type: String,
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
},
|
|
|
|
path:{
|
|
|
|
path: {
|
|
|
|
type:String,
|
|
|
|
type: String,
|
|
|
|
default:''
|
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
},
|
|
|
|
orderid:{
|
|
|
|
orderid: {
|
|
|
|
type:String,
|
|
|
|
type: String,
|
|
|
|
default:''
|
|
|
|
default: ''
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
const tip_str = ref('授权登录中,请稍候...')
|
|
|
|
|
|
|
|
const checkOpenid = () => {
|
|
|
|
|
|
|
|
let openid = ''
|
|
|
|
|
|
|
|
let path=''
|
|
|
|
|
|
|
|
let param=''
|
|
|
|
|
|
|
|
if (!!$props.openid) {
|
|
|
|
|
|
|
|
openid = decodeURIComponent($props.openid)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!!$props.path) {
|
|
|
|
});
|
|
|
|
path = decodeURIComponent($props.path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const index = path.indexOf('#');
|
|
|
|
const tip_str = ref('授权登录中,请稍候...')
|
|
|
|
if (index !== -1) {
|
|
|
|
|
|
|
|
path= path.substring(0, index); // 包含 # 时,返回 # 前面的部分
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
param=param+"?path="+path
|
|
|
|
// 2. 封装通用函数:截取 # 之前的字符串,避免重复代码
|
|
|
|
}
|
|
|
|
const getPureValue = (value) => {
|
|
|
|
if (!!$props.orderid) {
|
|
|
|
if (!value) return '';
|
|
|
|
path = decodeURIComponent($props.orderid)
|
|
|
|
const decodedValue = decodeURIComponent(value);
|
|
|
|
const index = path.indexOf('#');
|
|
|
|
const hashIndex = decodedValue.indexOf('#');
|
|
|
|
if (index !== -1) {
|
|
|
|
return hashIndex !== -1 ? decodedValue.substring(0, hashIndex) : decodedValue;
|
|
|
|
path= path.substring(0, index); // 包含 # 时,返回 # 前面的部分
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
param=param+"&orderid="+path
|
|
|
|
const checkOpenid = () => {
|
|
|
|
|
|
|
|
// 3. 处理各参数,使用通用函数统一处理 # 截取
|
|
|
|
|
|
|
|
const openid = getPureValue(props.openid);
|
|
|
|
|
|
|
|
const path = getPureValue(props.path);
|
|
|
|
|
|
|
|
const orderid = getPureValue(props.orderid);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 4. 初始化参数拼接字符串,避免 undefined 开头
|
|
|
|
|
|
|
|
let redirectParams = '';
|
|
|
|
|
|
|
|
// 拼接 path 参数
|
|
|
|
|
|
|
|
if (path) {
|
|
|
|
|
|
|
|
redirectParams += `?path=${path}`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!!openid) {
|
|
|
|
// 拼接 orderid 参数(修复:不再覆盖 path 变量)
|
|
|
|
const index = openid.indexOf('#');
|
|
|
|
if (orderid) {
|
|
|
|
if (index !== -1) {
|
|
|
|
redirectParams += `${redirectParams ? '&' : '?'}orderid=${orderid}`;
|
|
|
|
openid= openid.substring(0, index); // 包含 # 时,返回 # 前面的部分
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
uni.setStorageSync('OPENID', openid)
|
|
|
|
|
|
|
|
|
|
|
|
if (openid) {
|
|
|
|
|
|
|
|
uni.setStorageSync('OPENID', openid);
|
|
|
|
|
|
|
|
// 跳转页面,拼接参数
|
|
|
|
uni.redirectTo({
|
|
|
|
uni.redirectTo({
|
|
|
|
url: "/pages/main/index/index"+param
|
|
|
|
url: `/pages/main/index/index${redirectParams}`
|
|
|
|
})
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
tip_str.value = '未获取到授权信息,请从小程序进入'
|
|
|
|
tip_str.value = '未获取到授权信息,请从小程序进入';
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
onShow(() => {
|
|
|
|
onShow(() => {
|
|
|
|
checkOpenid()
|
|
|
|
checkOpenid();
|
|
|
|
})
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<view class="tip_wrapper">
|
|
|
|
<view class="tip_wrapper">
|
|
|
|
{{ tip_str }}
|
|
|
|
{{ tip_str }}
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
<style scoped>
|
|
|
|
.tip_wrapper {
|
|
|
|
.tip_wrapper {
|
|
|
|
height: 100vh;
|
|
|
|
height: 100vh;
|
|
|
|
width: 100%;
|
|
|
|
width: 100%;
|
|
|
|
display: flex;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</style>
|