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

2 months ago
<script>
export default {
async onLaunch() {
//#ifdef H5
1 month ago
console.log("APPonLaunch");
1 month ago
// 每次进入托盘模块都需要重新登录不保留上次token
1 month ago
// var token= uni.getStorageSync("token");
// if(token){
// uni.redirectTo({
// url: '/pages/index/index'
// });
// return false;
// }
2 months ago
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');
}
1 month ago
if (!ticket){
this.closeWindow()
}
2 months ago
// 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()
2 months ago
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');
2 months ago
// 跳转 首页
uni.redirectTo({
2 months ago
url: '/pages/index/index'
});
}else{
2 months ago
uni.showModal({
title: '提示',
content: '登录失败,请重新登录后进入!',
2 months ago
cancelText: '取消',
confirmText: '确定',
success: ress => {
this.closeWindow()
2 months ago
}
});
}
}else{
2 months ago
uni.showModal({
title: '提示',
content: '登录失败,请重新登录后进入!',
2 months ago
cancelText: '取消',
confirmText: '确定',
success: ress => {
this.closeWindow()
2 months ago
}
});
}
},
fail: err => {
console.log("err",err);
uni.showModal({
title: '提示',
content: '登录请求失败,请重新登录后进入!',
2 months ago
cancelText: '取消',
confirmText: '确定',
success: ress => {
this.closeWindow()
2 months ago
}
});
}
});
}
1 month ago
//#endif
2 months ago
},
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);
}
}
2 months ago
}
}
</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>