ssoCertification.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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.reLaunch({
  79. url: '/pages_basics/views/earlyWarningManage/earlyWarningDetail',
  80. });
  81. } else if (uni.getStorageSync('manageCation')) {
  82. uni.reLaunch({
  83. url: '/pages_manage/views/accessQualification/accessQualificationInfo?item=' + uni.getStorageSync('manageCation')
  84. })
  85. } else if (uni.getStorageSync('studentCation')) {
  86. uni.reLaunch({
  87. url: '/pages_student/views/accessApplication/applicationDetails?item=' + uni.getStorageSync('studentCation')
  88. })
  89. } else {
  90. uni.reLaunch({
  91. url: '/pages/views/home/home',
  92. });
  93. }
  94. }).catch((error) => {
  95. uni.showToast({
  96. mask: true,
  97. icon: "none",
  98. position: "center",
  99. title: '数据异常,请稍候再试!',
  100. duration: 2000
  101. });
  102. setTimeout(function() {
  103. uni.redirectTo({
  104. url: '/pages/views/login/login',
  105. });
  106. }, 2000);
  107. })
  108. }else{
  109. uni.redirectTo({
  110. url: '/pages/views/home/home',
  111. });
  112. }
  113. },
  114. //查询公共配置
  115. async getConfigInfo() {
  116. const {
  117. data
  118. } = await configInfo({
  119. type: '1,2,4'
  120. });
  121. if (data.code == 200) {
  122. let list = JSON.parse(data.data)
  123. let newData = {};
  124. list.forEach((item) => {
  125. let obj = JSON.parse(item.configValue)
  126. newData = {
  127. ...newData,
  128. ...obj
  129. }
  130. })
  131. uni.setStorageSync('circularLogo', config.base_url + newData.circularLogo)
  132. uni.setStorageSync('rectangleLogo', config.base_url + newData.rectangleLogo)
  133. uni.setStorageSync('videoCover', config.base_url + newData.videoCover)
  134. this.$set(this, 'loginBanner', config.base_url + newData.loginBanner);
  135. uni.setStorageSync('loginBanner', config.base_url + newData.loginBanner)
  136. this.$set(this, 'supplierType', newData.supplier);
  137. uni.setStorageSync('supplierType', newData.supplier)
  138. uni.setStorageSync('homepageBanner', config.base_url + newData.homepageBanner)
  139. }
  140. },
  141. //获取开发配置
  142. async getConfigByType() {
  143. const {
  144. data
  145. } = await getConfigByType({
  146. category: 2,
  147. configType: 5
  148. });
  149. if (data.code == 200) {
  150. let obj = JSON.parse(data.data.configValue)
  151. //文件预览地址
  152. uni.setStorageSync('filePreviewUrl', 'https://' + obj.fileExtranetUrl)
  153. //小程序视频地址
  154. uni.setStorageSync('cameraExtranetAgent', 'https://' + obj.cameraExtranetAgent)
  155. //MQTT地址
  156. uni.setStorageSync('mqttUrl', Decrypt(obj.mqttExtranetUrl))
  157. //MQTT地址-内网
  158. uni.setStorageSync('mqttIntranetUrl', Decrypt(obj.mqttIntranetUrl))
  159. //MQTT账号
  160. uni.setStorageSync('mqttUser', Decrypt(obj.mqttExtranetUser))
  161. //MQTT密码
  162. uni.setStorageSync('mqttPassword', Decrypt(obj.mqttExtranetPassword))
  163. //文件浏览环境
  164. uni.setStorageSync('fileBrowseEnvironment','http://'+Decrypt(obj.fileBrowseEnvironment))
  165. uni.setStorageSync('fileBrowseEnvironmentExtranet','https://'+Decrypt(obj.fileBrowseEnvironmentExtranet))
  166. }
  167. },
  168. //获取权限字段
  169. async systemAppletRolePermission() {
  170. let self = this;
  171. const {
  172. data
  173. } = await systemAppletRolePermission();
  174. if (data.code == 200) {
  175. uni.setStorageSync('permissions', data.data.data)
  176. uni.setStorageSync('controlsRestrict', data.data.roleKeys ? data.data.roleKeys : [])
  177. uni.setStorageSync('user', data.data.userInfo)
  178. }
  179. },
  180. //查询身份
  181. async securityDataStatisticsGetUserIdentity(routeUrl) {
  182. let self = this;
  183. const {
  184. data
  185. } = await securityDataStatisticsGetUserIdentity();
  186. if(data.schoolAdmin){
  187. //校级管理员
  188. uni.setStorageSync('identityData',{
  189. type:'schoolAdmin'
  190. });
  191. }else if(data.collegeAdmin){
  192. //院级管理员
  193. uni.setStorageSync('identityData',{
  194. type:'collegeAdmin'
  195. });
  196. }else if(data.schoolGroup){
  197. //校级督导组
  198. uni.setStorageSync('identityData',{
  199. type:'schoolGroup',
  200. groupIds:data.groupIds
  201. });
  202. }else if(data.collegeGroup){
  203. //院级督导组
  204. uni.setStorageSync('identityData',{
  205. type:'collegeGroup',
  206. groupIds:data.groupIds
  207. });
  208. }else{
  209. uni.removeStorageSync('identityData');
  210. }
  211. },
  212. },
  213. }
  214. </script>
  215. <style lang="stylus" scoped>
  216. #ssoCertification {
  217. width:100%;
  218. height:100%;
  219. overflow:scroll;
  220. text-align: center;
  221. line-height:200rpx;
  222. }
  223. </style>