login.vue 13 KB

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