123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- <!--认证页面-->
- <template>
- <view id="ssoCertification">
- 登录中请稍后
- </view>
- </template>
- <script>
- import {
- config
- } from '@/api/request/config.js'
- import {
- authGetAppletUser,
- configInfo,
- getConfigByType,
- systemAppletRolePermission,
- securityDataStatisticsGetUserIdentity
- } from '@/pages/api/index.js'
- import {
- Encrypt,
- Decrypt
- } from '@/utils/secret.js'
- export default {
- name: "ssoCertification",
- data() {
- return {
-
- }
- },
- onLoad(option) {
- console.log('option=>',option);
- if(option.token){
- uni.setStorageSync('token', option.token);
- //获取登录人信息接口
- this.authGetAppletUser();
- }else{
- uni.redirectTo({
- url: '/pages/views/login/ssoLogin',
- });
- }
- },
- mounted() {
- },
- methods: {
- async authGetAppletUser(){
- const {
- data
- } = await authGetAppletUser();
- if (data.code == 200) {
- uni.setStorageSync('dataBoardType', false);
- uni.setStorageSync('userId', data.data.userId);
- uni.setStorageSync('isInitPwd', true);
- // userType 0-系统 1-教职工 2-学生 3-大屏
- uni.setStorageSync('userType', data.data.userType == 0 || data.data.userType == 1 ? '1' :
- (data.data.userType == 2 ? '2' : (data.data.userType == 3 ? '3' : 'none')));
- //等待配置与字段获取到后跳转
- Promise.all([
- //查询公共配置
- this.getConfigInfo(),
- //获取开发配置
- this.getConfigByType(),
- //获取权限字段
- this.systemAppletRolePermission(),
- //查询身份
- this.securityDataStatisticsGetUserIdentity()
- ]).then((result) => {
- if (uni.getStorageSync('codeData')) {
- uni.redirectTo({
- url: '/pages/views/saoCode/saoCode',
- });
- } else if (uni.getStorageSync('warningId')) {
- uni.redirectTo({
- url: '/pages_basics/views/earlyWarningManage/earlyWarningDetail',
- });
- } else {
- uni.redirectTo({
- url: '/pages/views/home/home',
- });
- }
- }).catch((error) => {
- wx.showToast({
- title: '数据异常,请稍候再试!',
- icon: "none",
- duration: 3000
- });
- })
- }else{
- uni.redirectTo({
- url: '/pages/views/home/home',
- });
- }
- },
-
- //查询公共配置
- async getConfigInfo() {
- const {
- data
- } = await configInfo({
- type: '1,2,4'
- });
- if (data.code == 200) {
- let list = JSON.parse(data.data)
- let newData = {};
- list.forEach((item) => {
- let obj = JSON.parse(item.configValue)
- newData = {
- ...newData,
- ...obj
- }
- })
- uni.setStorageSync('circularLogo', config.base_url + newData.circularLogo)
- uni.setStorageSync('rectangleLogo', config.base_url + newData.rectangleLogo)
- uni.setStorageSync('videoCover', config.base_url + newData.videoCover)
- this.$set(this, 'loginBanner', config.base_url + newData.loginBanner);
- uni.setStorageSync('loginBanner', config.base_url + newData.loginBanner)
- this.$set(this, 'supplierType', newData.supplier);
- uni.setStorageSync('supplierType', newData.supplier)
- uni.setStorageSync('homepageBanner', config.base_url + newData.homepageBanner)
- }
- },
- //获取开发配置
- async getConfigByType() {
- const {
- data
- } = await getConfigByType({
- category: 2,
- configType: 5
- });
- if (data.code == 200) {
- let obj = JSON.parse(data.data.configValue)
- //文件预览地址
- uni.setStorageSync('filePreviewUrl', 'https://' + obj.fileExtranetUrl)
- //小程序视频地址
- uni.setStorageSync('cameraExtranetAgent', 'https://' + obj.cameraExtranetAgent)
- //MQTT地址
- uni.setStorageSync('mqttUrl', Decrypt(obj.mqttExtranetUrl))
- //MQTT地址-内网
- uni.setStorageSync('mqttIntranetUrl', Decrypt(obj.mqttIntranetUrl))
- //MQTT账号
- uni.setStorageSync('mqttUser', Decrypt(obj.mqttExtranetUser))
- //MQTT密码
- uni.setStorageSync('mqttPassword', Decrypt(obj.mqttExtranetPassword))
- //文件浏览环境
- uni.setStorageSync('fileBrowseEnvironment','http://'+Decrypt(obj.fileBrowseEnvironment))
- uni.setStorageSync('fileBrowseEnvironmentExtranet','https://'+Decrypt(obj.fileBrowseEnvironmentExtranet))
- }
- },
- //获取权限字段
- async systemAppletRolePermission() {
- let self = this;
- const {
- data
- } = await systemAppletRolePermission();
- if (data.code == 200) {
- uni.setStorageSync('permissions', data.data.data)
- uni.setStorageSync('controlsRestrict', data.data.roleKeys ? data.data.roleKeys : [])
- uni.setStorageSync('user', data.data.userInfo)
- }
- },
- //查询身份
- async securityDataStatisticsGetUserIdentity(routeUrl) {
- let self = this;
- const {
- data
- } = await securityDataStatisticsGetUserIdentity();
- if(data.schoolAdmin){
- //校级管理员
- uni.setStorageSync('identityData',{
- type:'schoolAdmin'
- });
- }else if(data.collegeAdmin){
- //院级管理员
- uni.setStorageSync('identityData',{
- type:'collegeAdmin'
- });
- }else if(data.schoolGroup){
- //校级督导组
- uni.setStorageSync('identityData',{
- type:'schoolGroup',
- groupIds:data.groupIds
- });
- }else if(data.collegeGroup){
- //院级督导组
- uni.setStorageSync('identityData',{
- type:'collegeGroup',
- groupIds:data.groupIds
- });
- }else{
- uni.removeStorageSync('identityData');
- }
- },
- },
- }
- </script>
- <style lang="stylus" scoped>
- #ssoCertification {
- width:100%;
- height:100%;
- overflow:scroll;
- text-align: center;
- line-height:200rpx;
- }
- </style>
|