ssoCertification.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <!--认证页面-->
  2. <template>
  3. <view id="ssoCertification">
  4. 登录中请稍后
  5. </view>
  6. </template>
  7. <script>
  8. import {
  9. config
  10. } from '@/api/request/config.js'
  11. import {
  12. authGetAppletUser,
  13. configInfo,
  14. getConfigByType,
  15. systemAppletRolePermission,
  16. systemSubjectCheckIsAdminOrSafeUser,
  17. securityDataStatisticsGetUserIdentity
  18. } from '@/pages/api/index.js'
  19. import {
  20. Encrypt,
  21. Decrypt
  22. } from '@/utils/secret.js'
  23. export default {
  24. name: "ssoCertification",
  25. data() {
  26. return {
  27. }
  28. },
  29. onLoad(option) {
  30. if(option.token){
  31. uni.setStorageSync('token', option.token);
  32. //获取登录人信息接口
  33. this.authGetAppletUser();
  34. }else{
  35. uni.showToast({
  36. mask: true,
  37. icon: "none",
  38. position: "center",
  39. title: '数据异常,请稍候再试!',
  40. duration: 2000
  41. });
  42. setTimeout(function() {
  43. uni.redirectTo({
  44. url: '/pages/views/login/login',
  45. });
  46. }, 2000);
  47. }
  48. },
  49. mounted() {
  50. },
  51. methods: {
  52. async authGetAppletUser(){
  53. const {
  54. data
  55. } = await authGetAppletUser();
  56. if (data.code == 200) {
  57. uni.setStorageSync('dataBoardType', false);
  58. uni.setStorageSync('userId', data.data.userId);
  59. uni.setStorageSync('isInitPwd', true);
  60. // userType 0-系统 1-教职工 2-学生 3-大屏
  61. uni.setStorageSync('userType', data.data.userType == 0 || data.data.userType == 1 ? '1' :
  62. (data.data.userType == 2 ? '2' : (data.data.userType == 3 ? '3' : 'none')));
  63. //等待配置与字段获取到后跳转
  64. Promise.all([
  65. //查询公共配置
  66. this.getConfigInfo(),
  67. //获取开发配置
  68. this.getConfigByType(),
  69. //获取权限字段
  70. this.systemAppletRolePermission(),
  71. //查询身份
  72. this.securityDataStatisticsGetUserIdentity(),
  73. //查询是否是管理员/安全员
  74. this.systemSubjectCheckIsAdminOrSafeUser(),
  75. ]).then((result) => {
  76. if (uni.getStorageSync('codeData')) {
  77. uni.redirectTo({
  78. url: '/pages/views/saoCode/saoCode',
  79. });
  80. } else if (uni.getStorageSync('warningId')) {
  81. uni.reLaunch({
  82. url: '/pages_basics/views/earlyWarningManage/earlyWarningDetail',
  83. });
  84. } else if (uni.getStorageSync('manageCation')) {
  85. uni.reLaunch({
  86. url: '/pages_manage/views/accessQualification/accessQualificationInfo?item=' + uni.getStorageSync('manageCation')
  87. })
  88. } else if (uni.getStorageSync('studentCation')) {
  89. uni.reLaunch({
  90. url: '/pages_student/views/accessApplication/applicationDetails?item=' + uni.getStorageSync('studentCation')
  91. })
  92. } else {
  93. uni.reLaunch({
  94. url: '/pages/views/home/home',
  95. });
  96. }
  97. }).catch((error) => {
  98. uni.showToast({
  99. mask: true,
  100. icon: "none",
  101. position: "center",
  102. title: '数据异常,请稍候再试!',
  103. duration: 2000
  104. });
  105. setTimeout(function() {
  106. uni.redirectTo({
  107. url: '/pages/views/login/login',
  108. });
  109. }, 2000);
  110. })
  111. }else{
  112. uni.redirectTo({
  113. url: '/pages/views/home/home',
  114. });
  115. }
  116. },
  117. //查询是否是管理员/安全员
  118. async systemSubjectCheckIsAdminOrSafeUser(){
  119. let self = this;
  120. const {
  121. data
  122. } = await systemSubjectCheckIsAdminOrSafeUser();
  123. if (data.code == 200) {
  124. if(data.data.isSafe || data.data.isAdmin){
  125. uni.setStorageSync('subAdmin','1');
  126. }else{
  127. uni.setStorageSync('subAdmin','0');
  128. }
  129. }
  130. },
  131. //查询公共配置
  132. async getConfigInfo() {
  133. const {
  134. data
  135. } = await configInfo({
  136. type: '1,2,4'
  137. });
  138. if (data.code == 200) {
  139. let list = JSON.parse(data.data)
  140. let newData = {};
  141. list.forEach((item) => {
  142. let obj = JSON.parse(item.configValue)
  143. newData = {
  144. ...newData,
  145. ...obj
  146. }
  147. })
  148. uni.setStorageSync('circularLogo', config.base_url + newData.circularLogo)
  149. uni.setStorageSync('rectangleLogo', config.base_url + newData.rectangleLogo)
  150. uni.setStorageSync('videoCover', config.base_url + newData.videoCover)
  151. this.$set(this, 'loginBanner', config.base_url + newData.loginBanner);
  152. uni.setStorageSync('loginBanner', config.base_url + newData.loginBanner)
  153. this.$set(this, 'supplierType', newData.supplier);
  154. uni.setStorageSync('supplierType', newData.supplier)
  155. uni.setStorageSync('homepageBanner', config.base_url + newData.homepageBanner)
  156. }
  157. },
  158. //获取开发配置
  159. async getConfigByType() {
  160. const {
  161. data
  162. } = await getConfigByType({
  163. category: 2,
  164. configType: 5
  165. });
  166. if (data.code == 200) {
  167. let obj = JSON.parse(data.data.configValue)
  168. //文件预览地址
  169. uni.setStorageSync('filePreviewUrl', 'https://' + obj.fileExtranetUrl)
  170. //小程序视频地址
  171. uni.setStorageSync('cameraExtranetAgent', 'https://' + obj.cameraExtranetAgent)
  172. //MQTT地址
  173. uni.setStorageSync('mqttUrl', Decrypt(obj.mqttExtranetUrl))
  174. //MQTT地址-内网
  175. uni.setStorageSync('mqttIntranetUrl', Decrypt(obj.mqttIntranetUrl))
  176. //MQTT账号
  177. uni.setStorageSync('mqttUser', Decrypt(obj.mqttExtranetUser))
  178. //MQTT密码
  179. uni.setStorageSync('mqttPassword', Decrypt(obj.mqttExtranetPassword))
  180. //文件浏览环境
  181. uni.setStorageSync('fileBrowseEnvironment','http://'+Decrypt(obj.fileBrowseEnvironment))
  182. uni.setStorageSync('fileBrowseEnvironmentExtranet','https://'+Decrypt(obj.fileBrowseEnvironmentExtranet))
  183. }
  184. },
  185. //获取权限字段
  186. async systemAppletRolePermission() {
  187. let self = this;
  188. const {
  189. data
  190. } = await systemAppletRolePermission();
  191. if (data.code == 200) {
  192. uni.setStorageSync('permissions', data.data.data)
  193. uni.setStorageSync('controlsRestrict', data.data.roleKeys ? data.data.roleKeys : [])
  194. uni.setStorageSync('user', data.data.userInfo)
  195. }
  196. },
  197. //查询身份
  198. async securityDataStatisticsGetUserIdentity(routeUrl) {
  199. let self = this;
  200. const {
  201. data
  202. } = await securityDataStatisticsGetUserIdentity();
  203. if(data.schoolAdmin){
  204. //校级管理员
  205. uni.setStorageSync('identityData',{
  206. type:'schoolAdmin'
  207. });
  208. }else if(data.collegeAdmin){
  209. //院级管理员
  210. uni.setStorageSync('identityData',{
  211. type:'collegeAdmin'
  212. });
  213. }else if(data.schoolGroup){
  214. //校级督导组
  215. uni.setStorageSync('identityData',{
  216. type:'schoolGroup',
  217. groupIds:data.groupIds
  218. });
  219. }else if(data.collegeGroup){
  220. //院级督导组
  221. uni.setStorageSync('identityData',{
  222. type:'collegeGroup',
  223. groupIds:data.groupIds
  224. });
  225. }else{
  226. uni.removeStorageSync('identityData');
  227. }
  228. },
  229. },
  230. }
  231. </script>
  232. <style lang="stylus" scoped>
  233. #ssoCertification {
  234. width:100%;
  235. height:100%;
  236. overflow:scroll;
  237. text-align: center;
  238. line-height:200rpx;
  239. }
  240. </style>