login.vue 13 KB

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