accountLogin.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  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. if(config.weChatProgramVersion === obj.weChatProgramVersion){
  257. uni.setStorageSync('weChatProgramVersion', true)
  258. }else{
  259. uni.setStorageSync('weChatProgramVersion', false)
  260. }
  261. //文件浏览环境
  262. uni.setStorageSync('fileBrowseEnvironment','http://'+Decrypt(obj.fileBrowseEnvironment))
  263. uni.setStorageSync('fileBrowseEnvironmentExtranet','https://'+Decrypt(obj.fileBrowseEnvironmentExtranet))
  264. }
  265. },
  266. //查询是否是管理员/安全员
  267. async systemSubjectCheckIsAdminOrSafeUser(){
  268. let self = this;
  269. const {
  270. data
  271. } = await systemSubjectCheckIsAdminOrSafeUser();
  272. if (data.code == 200) {
  273. if(data.data.isSafe || data.data.isAdmin){
  274. uni.setStorageSync('subAdmin','1');
  275. }else{
  276. uni.setStorageSync('subAdmin','0');
  277. }
  278. }
  279. },
  280. //查询身份
  281. async securityDataStatisticsGetUserIdentity(routeUrl) {
  282. let self = this;
  283. const {
  284. data
  285. } = await securityDataStatisticsGetUserIdentity();
  286. if(data.schoolAdmin){
  287. //校级管理员
  288. uni.setStorageSync('identityData',{
  289. type:'schoolAdmin'
  290. });
  291. }else if(data.collegeAdmin){
  292. //院级管理员
  293. uni.setStorageSync('identityData',{
  294. type:'collegeAdmin'
  295. });
  296. }else if(data.schoolGroup){
  297. //校级督导组
  298. uni.setStorageSync('identityData',{
  299. type:'schoolGroup',
  300. groupIds:data.groupIds
  301. });
  302. }else if(data.collegeGroup){
  303. //院级督导组
  304. uni.setStorageSync('identityData',{
  305. type:'collegeGroup',
  306. groupIds:data.groupIds
  307. });
  308. }else{
  309. uni.removeStorageSync('identityData');
  310. }
  311. },
  312. checkboxChange() {
  313. this.checkedType = !this.checkedType;
  314. },
  315. },
  316. }
  317. </script>
  318. <style lang="stylus" scoped>
  319. #accountLogin {
  320. height: 100%;
  321. width: 100%;
  322. background #f5f5f5;
  323. position relative;
  324. .login-max-big {
  325. width: 750rpx;
  326. height: 1177rpx;
  327. z-index: 0;
  328. }
  329. .login-box {
  330. z-index: 3;
  331. position: absolute;
  332. top: 430rpx;
  333. left: 46rpx;
  334. width: 658rpx;
  335. height: 700rpx;
  336. // background #fff
  337. /* 切换按钮 */
  338. .tabTitle {
  339. display flex;
  340. width: 100%;
  341. height: 100rpx;
  342. position: absolute;
  343. // top: 50rpx;
  344. justify-content: center;
  345. .tabTitle_li {
  346. width: 168rpx;
  347. text-align center;
  348. .tabTitle_text {
  349. display: inline-block;
  350. font-size: 32rpx;
  351. font-family: PingFang SC;
  352. font-weight: 500;
  353. color: #333333;
  354. line-height: 90rpx;
  355. &.on {
  356. color: #0183FA;
  357. }
  358. }
  359. .tabTitle_across {
  360. width: 100rpx;
  361. height: 4rpx;
  362. background: #0183FA;
  363. border-radius: 2rpx;
  364. margin-left 30rpx;
  365. display none;
  366. &.on {
  367. display block;
  368. }
  369. }
  370. }
  371. }
  372. border-radius:20rpx;
  373. .input-max-box-one {
  374. overflow: hidden;
  375. // margin-top: 68rpx;
  376. .input-box {
  377. display flex;
  378. width: 600rpx;
  379. height: 80rpx;
  380. border: 1rpx solid #e0e0e0;
  381. border-radius: 40rpx;
  382. margin: 147rpx auto 0;
  383. img {
  384. width: 28rpx;
  385. height: 32rpx;
  386. margin: 24rpx 31rpx;
  387. }
  388. input {
  389. flex: 1;
  390. font-size: 24rpx;
  391. height: 80rpx;
  392. line-height: 80rpx;
  393. margin-right: 31rpx;
  394. }
  395. }
  396. .text-box {
  397. height: 59rpx;
  398. line-height: 59rpx;
  399. color: #DC1616;
  400. font-size: 24rpx;
  401. margin-left: 102rpx;
  402. }
  403. }
  404. .input-max-box-two {
  405. margin-top: 40rpx;
  406. .input-box {
  407. display flex;
  408. width: 600rpx;
  409. height: 80rpx;
  410. border: 1rpx solid #e0e0e0;
  411. border-radius: 40rpx;
  412. margin: 0 auto 0;
  413. img {
  414. width: 30rpx;
  415. height: 32rpx;
  416. margin: 24rpx 30rpx;
  417. }
  418. input {
  419. flex: 1;
  420. font-size: 24rpx;
  421. height: 80rpx;
  422. line-height: 80rpx;
  423. margin-right: 31rpx;
  424. }
  425. }
  426. .text-box {
  427. height: 59rpx;
  428. line-height: 59rpx;
  429. color: #DC1616;
  430. font-size: 24rpx;
  431. margin-left: 102rpx;
  432. }
  433. }
  434. .check-box {
  435. margin: 30rpx 0 30rpx 104rpx;
  436. width: 300rpx;
  437. height: 50rpx;
  438. display: flex;
  439. img {
  440. margin-top: 10rpx;
  441. width: 32rpx;
  442. height: 32rpx;
  443. margin-right: 10rpx;
  444. }
  445. view {
  446. font-size: 24rpx;
  447. line-height: 50rpx;
  448. }
  449. }
  450. .button-box {
  451. width: 600rpx;
  452. line-height: 80rpx;
  453. background: #0183FA;
  454. border-radius: 40rpx;
  455. font-size: 36rpx;
  456. color: #fff;
  457. text-align center;
  458. margin: 0 auto 0;
  459. }
  460. .passwrod-button-box{
  461. line-height:60rpx;
  462. width:120rpx;
  463. margin:20rpx 0 0 40rpx;
  464. color:#333;
  465. font-size:24rpx;
  466. }
  467. /* 供应商注册 */
  468. .supplier {
  469. display: flex;
  470. justify-content: space-between;
  471. margin: 30rpx 40rpx 0;
  472. .supplier_l {
  473. font-size: 24rpx;
  474. font-family: PingFang SC;
  475. font-weight: 400;
  476. color: #333333;
  477. line-height: 24rpx;
  478. }
  479. .supplier_r {
  480. font-size: 24rpx;
  481. font-family: PingFang SC;
  482. font-weight: 400;
  483. color: #333333;
  484. line-height: 24rpx;
  485. >text {
  486. color: #0183FA;
  487. }
  488. }
  489. }
  490. /* 供应商切换 */
  491. .switch_btn {
  492. display: flex;
  493. justify-content: center;
  494. align-items: center;
  495. font-size: 24rpx;
  496. font-family: PingFang SC;
  497. font-weight: 400;
  498. color: #0183FA;
  499. line-height: 24rpx;
  500. margin-top: 60rpx;
  501. >img {
  502. width: 24rpx;
  503. height: 24rpx;
  504. margin-left: 12rpx;
  505. }
  506. }
  507. }
  508. .loginButton{
  509. position: absolute;
  510. bottom:40rpx;
  511. left:295rpx;
  512. width:300;
  513. height:80rpx;
  514. line-height:80rpx;
  515. text-align: center;
  516. color:#0183fa;
  517. font-size:28rpx;
  518. }
  519. .top-back {
  520. z-index: 2;
  521. position: absolute;
  522. top: 261rpx;
  523. left: 375rpx;
  524. height: 296rpx;
  525. width: 366rpx;
  526. }
  527. }
  528. </style>