ssoCertification.vue 5.8 KB

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