accountLogin.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. <!-- 登录 -->
  2. <template>
  3. <view id="accountLogin">
  4. <img class="login-max-big" :src="loginBanner">
  5. <view class="login-box">
  6. <view class="tabTitle">
  7. <view class="tabTitle_li" @tap="tabClick(index)" :key="index" v-for="(item,index) in tabText">
  8. <view :class="{on:curTab==index}" class="tabTitle_text">{{item}}</view>
  9. <!-- <view :class="{on:curTab==index}" class="tabTitle_across"></view> -->
  10. </view>
  11. </view>
  12. <view class="input-max-box-one">
  13. <view class="input-box">
  14. <img :src="imagesUrl('commonality/img_log_in_account.png')">
  15. <input type="text" v-model="username" placeholder="请输入账号" maxlength="20">
  16. </view>
  17. </view>
  18. <view class="input-max-box-two">
  19. <view class="input-box">
  20. <img :src="imagesUrl('commonality/img_log_in_password.png')">
  21. <input type="password" v-model="password" placeholder="请输入密码" maxlength="20">
  22. </view>
  23. </view>
  24. <view class="check-box" @click="checkboxChange()">
  25. <img v-if="checkedType" :src="imagesUrl('commonality/icon_13.png')">
  26. <img v-if="!checkedType" :src="imagesUrl('commonality/icon_12.png')"/>
  27. <view>记住我</view>
  28. </view>
  29. <view class="button-box" @click="login()">登录</view>
  30. <!-- <view class="passwrod-button-box" @click="forgotPasswordButton()">忘记密码?</view> -->
  31. </view>
  32. <view class="loginButton" @click="backButton()">统一身份认证登录</view>
  33. </view>
  34. </template>
  35. <script>
  36. import md5 from '@/utils/md5.js'
  37. import {
  38. config
  39. } from '@/api/request/config.js'
  40. import {
  41. login,
  42. configInfo,
  43. getConfigByType,
  44. systemAppletRolePermission,
  45. systemSubjectCheckIsAdminOrSafeUser,
  46. securityDataStatisticsGetUserIdentity
  47. } from '@/pages/api/index.js'
  48. import {
  49. Encrypt,
  50. Decrypt
  51. } from '@/utils/secret.js'
  52. export default {
  53. onShareAppMessage(res) {
  54. return {
  55. title: '实验室安全智慧化管控系统',
  56. path: '/pages/views/login/login'
  57. }
  58. },
  59. data() {
  60. return {
  61. identityStatus: 1,
  62. username: "",
  63. password: "",
  64. checkedType: false,
  65. loginBanner: uni.getStorageSync('loginBanner'),
  66. infoList: [], //模板消息Id
  67. tabText: ['师生登录'],
  68. curTab: 0,
  69. pageType: 0,
  70. supplierType: false,
  71. }
  72. },
  73. onLoad(option) {
  74. //供应商注册成功后返回到供应商注册页面
  75. if (option.status) {
  76. this.identityStatus = 2
  77. }
  78. if (uni.getStorageSync('userName') && uni.getStorageSync('password')) {
  79. this.username = uni.getStorageSync('userName');
  80. this.password = uni.getStorageSync('password');
  81. this.checkedType = true;
  82. }
  83. },
  84. onShow() {
  85. this.getConfigInfo();
  86. },
  87. methods: {
  88. backButton(){
  89. uni.navigateBack();
  90. },
  91. //顶部tab点击
  92. tabClick(index) {
  93. this.curTab = index;
  94. },
  95. //跳转忘记密码
  96. forgotPasswordButton(){
  97. uni.navigateTo({
  98. url: '/pages_basics/views/forgotPassword/forgotPassword',
  99. });
  100. },
  101. //登录
  102. async login() {
  103. let self = this;
  104. let obj = {
  105. account: this.username,
  106. password: md5.hex_md5(this.password),
  107. }
  108. const {
  109. data
  110. } = await login(obj)
  111. if (data.code == 200) {
  112. if(data.data.userType == 0 || data.data.userType == 1 || data.data.userType == 2){
  113. uni.setStorageSync('dataBoardType', false);
  114. uni.setStorageSync('token', data.data.token);
  115. uni.setStorageSync('userId', data.data.userId);
  116. uni.setStorageSync('isInitPwd', true);
  117. // userType 0-系统 1-教职工 2-学生 3-大屏
  118. uni.setStorageSync('userType', data.data.userType == 0 || data.data.userType == 1 ? '1' :
  119. (data.data.userType == 2 ? '2' : (data.data.userType == 3 ? '3' : 'none')));
  120. if (this.checkedType) {
  121. uni.setStorageSync('userName', this.username)
  122. uni.setStorageSync('password', this.password)
  123. } else {
  124. uni.removeStorageSync('userName')
  125. uni.removeStorageSync('password')
  126. }
  127. //等待配置与字段获取到后跳转
  128. Promise.all([
  129. //获取开发配置
  130. this.getConfigByType(),
  131. //获取权限字段
  132. this.systemAppletRolePermission(),
  133. //查询是否是管理员/安全员
  134. this.systemSubjectCheckIsAdminOrSafeUser(),
  135. //查询身份
  136. this.securityDataStatisticsGetUserIdentity()
  137. ]).then((result) => {
  138. if (uni.getStorageSync('codeData')) {
  139. uni.redirectTo({
  140. url: '/pages/views/saoCode/saoCode',
  141. });
  142. } else if (uni.getStorageSync('warningId')) {
  143. uni.reLaunch({
  144. url: '/pages_basics/views/earlyWarningManage/earlyWarningDetail',
  145. });
  146. } else if (uni.getStorageSync('manageCation')) {
  147. uni.reLaunch({
  148. url: '/pages_manage/views/accessQualification/accessQualificationInfo?item=' + uni.getStorageSync('manageCation')
  149. })
  150. } else if (uni.getStorageSync('studentCation')) {
  151. uni.reLaunch({
  152. url: '/pages_student/views/accessApplication/applicationDetails?item=' + uni.getStorageSync('studentCation')
  153. })
  154. } else if(uni.getStorageSync('recyclingReportRecord')){
  155. //短信跳转-危废回收-报备
  156. uni.removeStorageSync('recyclingReportRecord')
  157. uni.reLaunch({
  158. url: "/pages_hazardousWasteRecycling/views/recyclingReportRecord/index",
  159. });
  160. } else if(uni.getStorageSync('permissionApply')){
  161. //短信跳转-危废回收-申请列表
  162. uni.removeStorageSync('permissionApply')
  163. uni.reLaunch({
  164. url: "/pages_hazardousWasteRecycling/views/permissionApply/listPage",
  165. });
  166. } else {
  167. uni.reLaunch({
  168. url: '/pages/views/home/home',
  169. });
  170. }
  171. }).catch((error) => {
  172. wx.showToast({
  173. title: '数据异常,请稍候再试!',
  174. icon: "none",
  175. duration: 3000
  176. });
  177. })
  178. }else{
  179. wx.showToast({
  180. title: '非教职工/学生账号,无法登录本系统.',
  181. icon: "none",
  182. duration: 3000
  183. });
  184. }
  185. }
  186. },
  187. //获取权限字段
  188. async systemAppletRolePermission() {
  189. let self = this;
  190. const {
  191. data
  192. } = await systemAppletRolePermission();
  193. if (data.code == 200) {
  194. uni.setStorageSync('permissions', data.data.data)
  195. uni.setStorageSync('controlsRestrict', data.data.roleKeys ? data.data.roleKeys : [])
  196. uni.setStorageSync('user', data.data.userInfo)
  197. }
  198. },
  199. switchClick() {
  200. if (this.identityStatus == 1) {
  201. this.identityStatus = 2;
  202. } else {
  203. this.identityStatus = 1;
  204. }
  205. },
  206. //查询公共配置
  207. async getConfigInfo() {
  208. const {
  209. data
  210. } = await configInfo({
  211. type: '1,2,4'
  212. });
  213. if (data.code == 200) {
  214. let list = JSON.parse(data.data)
  215. let newData = {};
  216. list.forEach((item) => {
  217. let obj = JSON.parse(item.configValue)
  218. newData = {
  219. ...newData,
  220. ...obj
  221. }
  222. })
  223. uni.setStorageSync('circularLogo', config.base_url + newData.circularLogo)
  224. uni.setStorageSync('rectangleLogo', config.base_url + newData.rectangleLogo)
  225. uni.setStorageSync('videoCover', config.base_url + newData.videoCover)
  226. this.$set(this, 'loginBanner', config.base_url + newData.loginBanner);
  227. uni.setStorageSync('loginBanner', config.base_url + newData.loginBanner)
  228. this.$set(this, 'supplierType', newData.supplier);
  229. uni.setStorageSync('supplierType', newData.supplier)
  230. uni.setStorageSync('homepageBanner', config.base_url + newData.homepageBanner)
  231. }
  232. },
  233. //获取开发配置
  234. async getConfigByType() {
  235. const {
  236. data
  237. } = await getConfigByType({
  238. category: 2,
  239. configType: 5
  240. });
  241. if (data.code == 200) {
  242. let obj = JSON.parse(data.data.configValue)
  243. //文件预览地址
  244. uni.setStorageSync('filePreviewUrl', 'https://' + obj.fileExtranetUrl)
  245. //小程序视频地址
  246. uni.setStorageSync('cameraExtranetAgent', 'https://' + obj.cameraExtranetAgent)
  247. //MQTT地址
  248. uni.setStorageSync('mqttUrl', Decrypt(obj.mqttExtranetUrl))
  249. //MQTT地址-内网
  250. uni.setStorageSync('mqttIntranetUrl', Decrypt(obj.mqttIntranetUrl))
  251. //MQTT账号
  252. uni.setStorageSync('mqttUser', Decrypt(obj.mqttExtranetUser))
  253. //MQTT密码
  254. uni.setStorageSync('mqttPassword', Decrypt(obj.mqttExtranetPassword))
  255. //文件浏览环境
  256. uni.setStorageSync('fileBrowseEnvironment','http://'+Decrypt(obj.fileBrowseEnvironment))
  257. uni.setStorageSync('fileBrowseEnvironmentExtranet','https://'+Decrypt(obj.fileBrowseEnvironmentExtranet))
  258. }
  259. },
  260. //查询是否是管理员/安全员
  261. async systemSubjectCheckIsAdminOrSafeUser(){
  262. let self = this;
  263. const {
  264. data
  265. } = await systemSubjectCheckIsAdminOrSafeUser();
  266. if (data.code == 200) {
  267. if(data.data.isSafe || data.data.isAdmin){
  268. uni.setStorageSync('subAdmin','1');
  269. }else{
  270. uni.setStorageSync('subAdmin','0');
  271. }
  272. }
  273. },
  274. //查询身份
  275. async securityDataStatisticsGetUserIdentity(routeUrl) {
  276. let self = this;
  277. const {
  278. data
  279. } = await securityDataStatisticsGetUserIdentity();
  280. if(data.schoolAdmin){
  281. //校级管理员
  282. uni.setStorageSync('identityData',{
  283. type:'schoolAdmin'
  284. });
  285. }else if(data.collegeAdmin){
  286. //院级管理员
  287. uni.setStorageSync('identityData',{
  288. type:'collegeAdmin'
  289. });
  290. }else if(data.schoolGroup){
  291. //校级督导组
  292. uni.setStorageSync('identityData',{
  293. type:'schoolGroup',
  294. groupIds:data.groupIds
  295. });
  296. }else if(data.collegeGroup){
  297. //院级督导组
  298. uni.setStorageSync('identityData',{
  299. type:'collegeGroup',
  300. groupIds:data.groupIds
  301. });
  302. }else{
  303. uni.removeStorageSync('identityData');
  304. }
  305. },
  306. checkboxChange() {
  307. this.checkedType = !this.checkedType;
  308. },
  309. },
  310. }
  311. </script>
  312. <style lang="stylus" scoped>
  313. #accountLogin {
  314. height: 100%;
  315. width: 100%;
  316. background #f5f5f5;
  317. position relative;
  318. .login-max-big {
  319. width: 750rpx;
  320. height: 1177rpx;
  321. z-index: 0;
  322. }
  323. .login-box {
  324. z-index: 3;
  325. position: absolute;
  326. top: 430rpx;
  327. left: 46rpx;
  328. width: 658rpx;
  329. height: 700rpx;
  330. // background #fff
  331. /* 切换按钮 */
  332. .tabTitle {
  333. display flex;
  334. width: 100%;
  335. height: 100rpx;
  336. position: absolute;
  337. // top: 50rpx;
  338. justify-content: center;
  339. .tabTitle_li {
  340. width: 168rpx;
  341. text-align center;
  342. .tabTitle_text {
  343. display: inline-block;
  344. font-size: 32rpx;
  345. font-family: PingFang SC;
  346. font-weight: 500;
  347. color: #333333;
  348. line-height: 90rpx;
  349. &.on {
  350. color: #0183FA;
  351. }
  352. }
  353. .tabTitle_across {
  354. width: 100rpx;
  355. height: 4rpx;
  356. background: #0183FA;
  357. border-radius: 2rpx;
  358. margin-left 30rpx;
  359. display none;
  360. &.on {
  361. display block;
  362. }
  363. }
  364. }
  365. }
  366. border-radius:20rpx;
  367. .input-max-box-one {
  368. overflow: hidden;
  369. // margin-top: 68rpx;
  370. .input-box {
  371. display flex;
  372. width: 600rpx;
  373. height: 80rpx;
  374. border: 1rpx solid #e0e0e0;
  375. border-radius: 40rpx;
  376. margin: 147rpx auto 0;
  377. img {
  378. width: 28rpx;
  379. height: 32rpx;
  380. margin: 24rpx 31rpx;
  381. }
  382. input {
  383. flex: 1;
  384. font-size: 24rpx;
  385. height: 80rpx;
  386. line-height: 80rpx;
  387. margin-right: 31rpx;
  388. }
  389. }
  390. .text-box {
  391. height: 59rpx;
  392. line-height: 59rpx;
  393. color: #DC1616;
  394. font-size: 24rpx;
  395. margin-left: 102rpx;
  396. }
  397. }
  398. .input-max-box-two {
  399. margin-top: 40rpx;
  400. .input-box {
  401. display flex;
  402. width: 600rpx;
  403. height: 80rpx;
  404. border: 1rpx solid #e0e0e0;
  405. border-radius: 40rpx;
  406. margin: 0 auto 0;
  407. img {
  408. width: 30rpx;
  409. height: 32rpx;
  410. margin: 24rpx 30rpx;
  411. }
  412. input {
  413. flex: 1;
  414. font-size: 24rpx;
  415. height: 80rpx;
  416. line-height: 80rpx;
  417. margin-right: 31rpx;
  418. }
  419. }
  420. .text-box {
  421. height: 59rpx;
  422. line-height: 59rpx;
  423. color: #DC1616;
  424. font-size: 24rpx;
  425. margin-left: 102rpx;
  426. }
  427. }
  428. .check-box {
  429. margin: 30rpx 0 30rpx 104rpx;
  430. width: 300rpx;
  431. height: 50rpx;
  432. display: flex;
  433. img {
  434. margin-top: 10rpx;
  435. width: 32rpx;
  436. height: 32rpx;
  437. margin-right: 10rpx;
  438. }
  439. view {
  440. font-size: 24rpx;
  441. line-height: 50rpx;
  442. }
  443. }
  444. .button-box {
  445. width: 600rpx;
  446. line-height: 80rpx;
  447. background: #0183FA;
  448. border-radius: 40rpx;
  449. font-size: 36rpx;
  450. color: #fff;
  451. text-align center;
  452. margin: 0 auto 0;
  453. }
  454. .passwrod-button-box{
  455. line-height:60rpx;
  456. width:120rpx;
  457. margin:20rpx 0 0 40rpx;
  458. color:#333;
  459. font-size:24rpx;
  460. }
  461. /* 供应商注册 */
  462. .supplier {
  463. display: flex;
  464. justify-content: space-between;
  465. margin: 30rpx 40rpx 0;
  466. .supplier_l {
  467. font-size: 24rpx;
  468. font-family: PingFang SC;
  469. font-weight: 400;
  470. color: #333333;
  471. line-height: 24rpx;
  472. }
  473. .supplier_r {
  474. font-size: 24rpx;
  475. font-family: PingFang SC;
  476. font-weight: 400;
  477. color: #333333;
  478. line-height: 24rpx;
  479. >text {
  480. color: #0183FA;
  481. }
  482. }
  483. }
  484. /* 供应商切换 */
  485. .switch_btn {
  486. display: flex;
  487. justify-content: center;
  488. align-items: center;
  489. font-size: 24rpx;
  490. font-family: PingFang SC;
  491. font-weight: 400;
  492. color: #0183FA;
  493. line-height: 24rpx;
  494. margin-top: 60rpx;
  495. >img {
  496. width: 24rpx;
  497. height: 24rpx;
  498. margin-left: 12rpx;
  499. }
  500. }
  501. }
  502. .loginButton{
  503. position: absolute;
  504. bottom:40rpx;
  505. left:295rpx;
  506. width:300;
  507. height:80rpx;
  508. line-height:80rpx;
  509. text-align: center;
  510. color:#0183fa;
  511. font-size:28rpx;
  512. }
  513. .top-back {
  514. z-index: 2;
  515. position: absolute;
  516. top: 261rpx;
  517. left: 375rpx;
  518. height: 296rpx;
  519. width: 366rpx;
  520. }
  521. }
  522. </style>