ssoLoginH5.vue 7.5 KB

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