<template>
|
<view class="pages-index">
|
<view class="login-content tems-cente">
|
<view>
|
<image :src="imgHttp" class="login-image" mode="widthFix"></image>
|
</view>
|
<view class="gungho-title"><text>{{ titleName}}</text>
|
</view>
|
<view class="gungho-tip"> <text>{{tip}}</text>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import Session from "@/common/utils.js"
|
import {
|
showModal,
|
showToast,
|
showLoading,
|
hideLoading
|
} from "@/common/Page.js"
|
import {
|
login,
|
loginSession,
|
loginDingTalk,
|
loginWeChat
|
} from "@/api/org.js"
|
import {
|
getDingAutoLoginInfo,
|
autoLoginDing,
|
autoLoginFeiShu,
|
autoLoginWxQy,
|
} from "@/api/index.js"
|
export default {
|
data() {
|
return {
|
titleName: getApp().globalData.loginTitleName || "工作任务管理平台",
|
imgHttp: "",
|
tip: '正在跳转...',
|
options: {}
|
}
|
},
|
onLoad(option) {
|
|
this.options =option
|
// #ifdef MP-DINGTALK
|
|
my.setNavigationBar({
|
backgroundColor: "#007AFF",
|
frontColor: "#ffffff"
|
})
|
// #endif
|
// {
|
// page_type: "prjevent_detail",
|
// id: "{86CE4507-FC29-4AD8-9A9F-779ADBE00F72}"
|
// }//option
|
this.loadData()
|
},
|
methods: {
|
loadData() {
|
const _this = this
|
const app = getApp()
|
uni.setNavigationBarTitle({
|
title: app.globalData.titleName
|
})
|
const apiPort = Session.getValue('apiport');
|
app.globalData.files_flag = Session.getValue('files_flag');
|
const portObj = app.globalData.apiport
|
app.globalData.apiurl = {
|
org: `${app.globalData.httproot}:${apiPort?.org|| portObj?.org || 5101}`,
|
mobox: `${app.globalData.httproot}:${apiPort?.mobox || portObj?.mobox|| 5102}`,
|
data: `${app.globalData.httproot}:${apiPort?.data || portObj?.data|| 5103}`,
|
workflow: `${app.globalData.httproot}:${apiPort?.workflow || portObj?.workflow|| 5104}`,
|
gungho: `${app.globalData.httproot}:${apiPort?.gungho|| portObj?.gungho || 5109}`,
|
}
|
let loginInfo = Session.getValue('logininfo')
|
if (loginInfo) {
|
if (loginInfo.sessionid) {
|
let userData = Session.getValue('userdata')
|
_this.checkSession(userData.user_login, loginInfo.sessionid, (res) => {
|
if (loginInfo.mobile) {
|
app.globalData.isPwdLogin = false
|
} else
|
app.globalData.isPwdLogin = true
|
_this.loginSuccess(loginInfo, res)
|
}, () => {
|
_this.login(loginInfo)
|
})
|
} else {
|
_this.login(loginInfo)
|
}
|
}
|
},
|
login(loginInfo) {
|
const _this = this
|
const app = getApp()
|
|
//#ifdef MP-WEIXIN || MP-LARK || MP-DINGTALK
|
if (loginInfo.mobile) {
|
_this.checkMobile(loginInfo.userlogin, loginInfo.mobile, (res) => {
|
app.globalData.isPwdLogin = false
|
_this.loginSuccess(loginInfo, res)
|
}, () => {
|
_this.autoLogin()
|
})
|
}
|
else
|
{
|
_this.autoLogin()
|
}
|
// #endif
|
//#ifndef MP-WEIXIN || MP-LARK || MP-DINGTALK
|
uni.reLaunch({
|
url: '/pages/loading/loading'
|
})
|
// #endif
|
|
},
|
async autoLogin() {
|
try {
|
const _this = this
|
showLoading("登录中,请稍后...")
|
var res = undefined
|
//#ifdef MP-WEIXIN
|
res = await autoLoginWxQy()
|
// #endif
|
//#ifdef MP-LARK
|
res = await autoLoginFeiShu()
|
// #endif
|
//#ifdef MP-DINGTALK
|
res = await autoLoginDing()
|
// #endif
|
if (!res) {
|
uni.reLaunch({
|
url: '/pages/loading/loading'
|
})
|
}
|
const app = getApp()
|
let loginInfo = {
|
userlogin: res.user_id,
|
username: res.user_name,
|
mobile: res.mobile,
|
password: "",
|
sessionid: res.session_id
|
}
|
app.globalData.isPwdLogin = false
|
_this.loginSuccess(loginInfo, res)
|
hideLoading()
|
|
} catch (ex) {
|
hideLoading()
|
console.log(ex)
|
this.showError(ex)
|
uni.reLaunch({
|
url: '/pages/loading/loading'
|
})
|
}
|
|
},
|
|
async checkMobile(account, mobile, callbackSucc, callbackFail) {
|
try {
|
if (account && mobile) {
|
showLoading("登录中,请稍后...")
|
// #ifdef MP-DINGTALK
|
let res = await loginDingTalk(account, mobile)
|
res.user_id = account
|
res.mobile = mobile
|
hideLoading()
|
if (typeof callbackSucc == 'function')
|
callbackSucc(res)
|
// #endif
|
//#ifdef MP-LARK || MP-WEIXIN
|
let res = await loginWeChat(account, mobile)
|
res.user_id = account
|
res.mobile = mobile
|
hideLoading()
|
if (typeof callbackSucc == 'function')
|
callbackSucc(res)
|
// #endif
|
//#ifndef MP-WEIXIN || MP-LARK || MP-DINGTALK
|
hideLoading()
|
if (typeof callbackFail == 'function')
|
callbackFail()
|
|
// #endif
|
|
} else {
|
if (typeof callbackFail == 'function')
|
callbackFail()
|
}
|
} catch (ex) {
|
hideLoading()
|
console.log("checkMobile", ex)
|
if (typeof callbackFail == 'function')
|
callbackFail()
|
}
|
|
},
|
|
async checkSession(account, sessionID, callbackSucc, callbackFail) {
|
try {
|
if (sessionID && account) {
|
showLoading("登录中,请稍后...")
|
const res = await loginSession(account, sessionID)
|
res.session_id = sessionID
|
hideLoading()
|
if (typeof callbackSucc == 'function')
|
callbackSucc(res)
|
} else {
|
if (typeof callbackFail == 'function')
|
callbackFail()
|
}
|
} catch (ex) {
|
hideLoading()
|
console.log("checkSession", ex)
|
if (typeof callbackFail == 'function')
|
callbackFail()
|
}
|
|
},
|
loginSuccess(loginInfo, userData) {
|
console.log("loginSuccess", loginInfo)
|
const app = getApp()
|
Session.setValue('logininfo', loginInfo)
|
userData.logintime = new Date().toDateString();
|
app.globalData.userdata = userData;
|
Session.setValue('userdata', userData);
|
if (userData.files_info && !app.globalData.files_flag) {
|
if (userData.files_info.flag) {
|
app.globalData.files_flag = userData.files_info.flag
|
|
}
|
}
|
if (this.options.page_type == "prjevent_detail") {
|
uni.reLaunch({
|
url: '/pages/project/event/detail?eventId=' + this.options.id
|
})
|
} else if (this.options.page_type == "prjevent_list") {
|
uni.reLaunch({
|
url: '/pages/project/event/index'
|
})
|
} else if (this.options.page_type == "prjevent_create") {
|
uni.reLaunch({
|
url: '/pages/project/event/create'
|
})
|
} else if (this.options.page_type == "task_detail") {
|
uni.reLaunch({
|
url: '/pages/task/detail?taskId=' + this.options.id
|
})
|
} else if (this.options.page_type == "task_list") {
|
uni.reLaunch({
|
url: '/pages/task/index'
|
})
|
} else if (this.options.page_type == "task_create") {
|
uni.reLaunch({
|
url: '/pages/task/create'
|
})
|
} else {
|
uni.reLaunch({
|
url: '/pages/task/index'
|
})
|
}
|
},
|
showError(ex) {
|
let tip = typeof ex == 'string' ? ex : typeof ex.err_msg == 'string' ? ex.err_msg : typeof ex.errMsg ==
|
'string' ? ex.errMsg : ""
|
showModal(tip, "提示", false)
|
},
|
}
|
}
|
</script>
|
|
<style lang="less">
|
.pages-index {
|
|
display: flex;
|
width: 750rpx;
|
height: 100vh;
|
|
.items-center {
|
align-items: center
|
}
|
|
.login-content {
|
width: 750rpx;
|
height: 400px;
|
}
|
|
.login-image {
|
display: block;
|
margin: auto;
|
height: 80px !important;
|
width: 80px;
|
}
|
|
.gungho-title {
|
font-size: 20px;
|
font-weight: 300;
|
margin: 24px 12px 12px;
|
text-align: center;
|
}
|
|
.gungho-tip {
|
font-size: 20px;
|
font-weight: 300;
|
margin: 24px 12px 12px;
|
text-align: center;
|
}
|
}
|
</style>
|