ssoCertification.vue 5.5 KB

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