ssoCertification.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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 if(uni.getStorageSync('recyclingReportRecord')){
  93. //短信跳转-危废回收-报备
  94. uni.removeStorageSync('recyclingReportRecord')
  95. uni.reLaunch({
  96. url: "/pages_hazardousWasteRecycling/views/recyclingReportRecord/index",
  97. });
  98. } else if(uni.getStorageSync('permissionApply')){
  99. //短信跳转-危废回收-申请列表
  100. uni.removeStorageSync('permissionApply')
  101. uni.reLaunch({
  102. url: "/pages_hazardousWasteRecycling/views/permissionApply/listPage",
  103. });
  104. } else {
  105. uni.reLaunch({
  106. url: '/pages/views/home/home',
  107. });
  108. }
  109. }).catch((error) => {
  110. uni.showToast({
  111. mask: true,
  112. icon: "none",
  113. position: "center",
  114. title: '数据异常,请稍候再试!',
  115. duration: 2000
  116. });
  117. setTimeout(function() {
  118. uni.redirectTo({
  119. url: '/pages/views/login/login',
  120. });
  121. }, 2000);
  122. })
  123. }else{
  124. uni.redirectTo({
  125. url: '/pages/views/home/home',
  126. });
  127. }
  128. },
  129. //查询是否是管理员/安全员
  130. async systemSubjectCheckIsAdminOrSafeUser(){
  131. let self = this;
  132. const {
  133. data
  134. } = await systemSubjectCheckIsAdminOrSafeUser();
  135. if (data.code == 200) {
  136. if(data.data.isSafe || data.data.isAdmin){
  137. uni.setStorageSync('subAdmin','1');
  138. }else{
  139. uni.setStorageSync('subAdmin','0');
  140. }
  141. }
  142. },
  143. //查询公共配置
  144. async getConfigInfo() {
  145. const {
  146. data
  147. } = await configInfo({
  148. type: '1,2,4'
  149. });
  150. if (data.code == 200) {
  151. let list = JSON.parse(data.data)
  152. let newData = {};
  153. list.forEach((item) => {
  154. let obj = JSON.parse(item.configValue)
  155. newData = {
  156. ...newData,
  157. ...obj
  158. }
  159. })
  160. uni.setStorageSync('circularLogo', config.base_url + newData.circularLogo)
  161. uni.setStorageSync('rectangleLogo', config.base_url + newData.rectangleLogo)
  162. uni.setStorageSync('videoCover', config.base_url + newData.videoCover)
  163. this.$set(this, 'loginBanner', config.base_url + newData.loginBanner);
  164. uni.setStorageSync('loginBanner', config.base_url + newData.loginBanner)
  165. this.$set(this, 'supplierType', newData.supplier);
  166. uni.setStorageSync('supplierType', newData.supplier)
  167. uni.setStorageSync('homepageBanner', config.base_url + newData.homepageBanner)
  168. }
  169. },
  170. //获取开发配置
  171. async getConfigByType() {
  172. const {
  173. data
  174. } = await getConfigByType({
  175. category: 2,
  176. configType: 5
  177. });
  178. if (data.code == 200) {
  179. let obj = JSON.parse(data.data.configValue)
  180. //文件预览地址
  181. uni.setStorageSync('filePreviewUrl', 'https://' + obj.fileExtranetUrl)
  182. //小程序视频地址
  183. uni.setStorageSync('cameraExtranetAgent', 'https://' + obj.cameraExtranetAgent)
  184. //MQTT地址
  185. uni.setStorageSync('mqttUrl', Decrypt(obj.mqttExtranetUrl))
  186. //MQTT地址-内网
  187. uni.setStorageSync('mqttIntranetUrl', Decrypt(obj.mqttIntranetUrl))
  188. //MQTT账号
  189. uni.setStorageSync('mqttUser', Decrypt(obj.mqttExtranetUser))
  190. //MQTT密码
  191. uni.setStorageSync('mqttPassword', Decrypt(obj.mqttExtranetPassword))
  192. //文件浏览环境
  193. uni.setStorageSync('fileBrowseEnvironment','http://'+Decrypt(obj.fileBrowseEnvironment))
  194. uni.setStorageSync('fileBrowseEnvironmentExtranet','https://'+Decrypt(obj.fileBrowseEnvironmentExtranet))
  195. }
  196. },
  197. //获取权限字段
  198. async systemAppletRolePermission() {
  199. let self = this;
  200. const {
  201. data
  202. } = await systemAppletRolePermission();
  203. if (data.code == 200) {
  204. uni.setStorageSync('permissions', data.data.data)
  205. uni.setStorageSync('controlsRestrict', data.data.roleKeys ? data.data.roleKeys : [])
  206. uni.setStorageSync('user', data.data.userInfo)
  207. }
  208. },
  209. //查询身份
  210. async securityDataStatisticsGetUserIdentity(routeUrl) {
  211. let self = this;
  212. const {
  213. data
  214. } = await securityDataStatisticsGetUserIdentity();
  215. if(data.schoolAdmin){
  216. //校级管理员
  217. uni.setStorageSync('identityData',{
  218. type:'schoolAdmin'
  219. });
  220. }else if(data.collegeAdmin){
  221. //院级管理员
  222. uni.setStorageSync('identityData',{
  223. type:'collegeAdmin'
  224. });
  225. }else if(data.schoolGroup){
  226. //校级督导组
  227. uni.setStorageSync('identityData',{
  228. type:'schoolGroup',
  229. groupIds:data.groupIds
  230. });
  231. }else if(data.collegeGroup){
  232. //院级督导组
  233. uni.setStorageSync('identityData',{
  234. type:'collegeGroup',
  235. groupIds:data.groupIds
  236. });
  237. }else{
  238. uni.removeStorageSync('identityData');
  239. }
  240. },
  241. },
  242. }
  243. </script>
  244. <style lang="stylus" scoped>
  245. #ssoCertification {
  246. width:100%;
  247. height:100%;
  248. overflow:scroll;
  249. text-align: center;
  250. line-height:200rpx;
  251. }
  252. </style>