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.

216 lines
5.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<script>
export default {
async onLaunch() {
//#ifdef H5
console.log("APPonLaunch");
// 每次进入托盘模块都需要重新登录不保留上次token
// var token= uni.getStorageSync("token");
// if(token){
// uni.redirectTo({
// url: '/pages/index/index'
// });
// return false;
// }
const queryString = window.location.search;
const searchParams = new URLSearchParams(queryString);
var ticket = searchParams.get('ticket');
console.log("ticket",ticket);
if(!ticket){
const query = window.location.hash.split('?')[1]; // 获取hash后面的查询字符串
const params = new URLSearchParams(query); // 创建一个URLSearchParams对象
ticket=params.get('ticket');
}
if (!ticket){
this.closeWindow()
}
// alert(ticket)
if(ticket){
uni.showLoading({
title: '登录跳转中...'
});
uni.request({
header: {
"Content-Type": "application/json",
"Accept": "application/json"
},
url: 'https://pallet.dsic.cn/api/api/loginBySSO?ticket='+ticket,
data:{
"ticket":ticket
},
method: "POST",
success: res => {
uni.hideLoading()
if(res.data){
var data=res.data;
if(data.data){
var datas=data.data;
uni.setStorageSync('expires', datas.expires);
uni.setStorageSync('token', datas.token);
uni.setStorageSync('user', JSON.stringify(datas.user));
uni.setStorageSync('menu', JSON.stringify(datas.user.btns));
this.getdept();
console.log('1');
// 跳转 首页
uni.redirectTo({
url: '/pages/index/index'
});
}else{
uni.showModal({
title: '提示',
content: '登录失败,请重新登录后进入!',
cancelText: '取消',
confirmText: '确定',
success: ress => {
this.closeWindow()
}
});
}
}else{
uni.showModal({
title: '提示',
content: '登录失败,请重新登录后进入!',
cancelText: '取消',
confirmText: '确定',
success: ress => {
this.closeWindow()
}
});
}
},
fail: err => {
console.log("err",err);
uni.showModal({
title: '提示',
content: '登录请求失败,请重新登录后进入!',
cancelText: '取消',
confirmText: '确定',
success: ress => {
this.closeWindow()
}
});
}
});
}
//#endif
},
methods: {
async getdept(){
var user= JSON.parse(uni.getStorageSync("user"));
var bmbm=user.bmbm?user.bmbm:"";
const {data: res} = await uni.$http.get('/getCommonData');
if(res.success){
if(res.data){
// 缓存部门
uni.setStorageSync('commondata', JSON.stringify(res.data));
if(res.data.depts){
res.data.depts.forEach((item, ii) => {
if(item.departCode==bmbm){
uni.setStorageSync('bmmc', item.departName);
}
});
}
}
}
},
closeWindow(){
if (window.plus) { // 确保在App环境中运行
const main = plus.android.runtimeMainActivity(); // Android方式调用退出
main.finish(); // Android方式调用退出
// 或者使用iOS方式的调用方式...
} else {
console.log('Not in App environment.'); // 非App环境提示信息
setTimeout(function() {
uni.redirectTo({
url: '/pages/login/index'
});
}, 2000);
}
}
}
}
</script>
<style lang="scss">
/*每个页面公共css */
@import "uview-ui/index.scss";
@import "common/demo.scss";
@import 'colorui/main.css';
@import 'colorui/icon.css';
body{
font-family: 'FZLTZHUNHJW--GB1-0';
}
.selright {
height: 100%;
background: url("@/static/images/xiayiji.png") no-repeat center right;
background-size: auto 80%;
padding-right: 50rpx !important;
text-align: right !important;
display: flex;
flex: 1;
align-items: flex-end;
justify-content: flex-end;
}
.rightc {
height: 100%;
padding-right: 10rpx !important;
text-align: right !important;
display: flex;
flex: 1;
align-items: flex-end;
justify-content: flex-end;
}
.wrapnob{
margin: 0;
padding: 0;
width: 100%;
position: relative;
height: calc(100vh);
/* #ifdef H5 */
height: calc(100vh - var(--window-top));
/* #endif */
}
.wrap{
margin: 0;
padding: 0;
width: 100%;
position: relative;
height: calc(100vh);
/* #ifdef H5 */
height: calc(100vh - var(--window-top) - var(--window-bottom));
/* #endif */
overflow-y: auto;
}
.page {
position: relative;
width: 100%;
padding: 0;
margin-top: 0;
overflow: hidden;
.back{
width: 100%;
height: calc(100vh - var(--window-top)) !important;
position: absolute;
top:0;
left:0;
background: url('@/static/images/pagebackimg.jpg') no-repeat top center;
background-size: 100% 100%;
}
}
.page-box{
padding-bottom:20rpx;
}
.imgload{
background-image: url('/static/images/tx.png');
background-size: 66% auto;
background-position: center center;
background-repeat: no-repeat;
}
::v-deep .uni-system-preview-image{
z-index: 9999999;
}
</style>