patrolLogin.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <!-- 登录 -->
  2. <template>
  3. <view id="patrolLogin">
  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',true);
  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. uni.reLaunch({
  136. url: '/pages_safetyCheck/views/safetyCheck',
  137. });
  138. }).catch((error) => {
  139. uni.showToast({
  140. title: '数据异常,请稍候再试!',
  141. icon: "none",
  142. duration: 3000
  143. });
  144. })
  145. }else{
  146. uni.showToast({
  147. title: '该账号无法登录本系统,请联系管理员.',
  148. icon: "none",
  149. duration: 3000
  150. });
  151. }
  152. }
  153. },
  154. //获取权限字段
  155. async systemAppletRolePermission() {
  156. let self = this;
  157. const {
  158. data
  159. } = await systemAppletRolePermission();
  160. if (data.code == 200) {
  161. uni.setStorageSync('permissions', data.data.data)
  162. uni.setStorageSync('controlsRestrict', data.data.roleKeys ? data.data.roleKeys : [])
  163. uni.setStorageSync('user', data.data.userInfo)
  164. }
  165. },
  166. switchClick() {
  167. if (this.identityStatus == 1) {
  168. this.identityStatus = 2;
  169. } else {
  170. this.identityStatus = 1;
  171. }
  172. },
  173. //查询公共配置
  174. async getConfigInfo() {
  175. const {
  176. data
  177. } = await configInfo({
  178. type: '1,2,4'
  179. });
  180. if (data.code == 200) {
  181. let list = JSON.parse(data.data)
  182. let newData = {};
  183. list.forEach((item) => {
  184. let obj = JSON.parse(item.configValue)
  185. newData = {
  186. ...newData,
  187. ...obj
  188. }
  189. })
  190. uni.setStorageSync('circularLogo', config.base_url + newData.circularLogo)
  191. uni.setStorageSync('rectangleLogo', config.base_url + newData.rectangleLogo)
  192. uni.setStorageSync('videoCover', config.base_url + newData.videoCover)
  193. this.$set(this, 'loginBanner', config.base_url + newData.loginBanner);
  194. uni.setStorageSync('loginBanner', config.base_url + newData.loginBanner)
  195. this.$set(this, 'supplierType', newData.supplier);
  196. uni.setStorageSync('supplierType', newData.supplier)
  197. uni.setStorageSync('homepageBanner', config.base_url + newData.homepageBanner)
  198. }
  199. },
  200. //获取开发配置
  201. async getConfigByType() {
  202. const {
  203. data
  204. } = await getConfigByType({
  205. category: 2,
  206. configType: 5
  207. });
  208. if (data.code == 200) {
  209. let obj = JSON.parse(data.data.configValue)
  210. //文件预览地址
  211. uni.setStorageSync('filePreviewUrl', 'https://' + obj.fileExtranetUrl)
  212. //小程序视频地址
  213. uni.setStorageSync('cameraExtranetAgent', 'https://' + obj.cameraExtranetAgent)
  214. //MQTT地址
  215. uni.setStorageSync('mqttUrl', Decrypt(obj.mqttExtranetUrl))
  216. //MQTT地址-内网
  217. uni.setStorageSync('mqttIntranetUrl', Decrypt(obj.mqttIntranetUrl))
  218. //MQTT账号
  219. uni.setStorageSync('mqttUser', Decrypt(obj.mqttExtranetUser))
  220. //MQTT密码
  221. uni.setStorageSync('mqttPassword', Decrypt(obj.mqttExtranetPassword))
  222. //文件浏览环境
  223. uni.setStorageSync('fileBrowseEnvironment','http://'+Decrypt(obj.fileBrowseEnvironment))
  224. uni.setStorageSync('fileBrowseEnvironmentS','https://'+Decrypt(obj.fileBrowseEnvironment))
  225. uni.setStorageSync('fileBrowseEnvironmentExtranet','http://'+Decrypt(obj.fileBrowseEnvironmentExtranet))
  226. uni.setStorageSync('fileBrowseEnvironmentExtranetS','https://'+Decrypt(obj.fileBrowseEnvironmentExtranet))
  227. }
  228. },
  229. //查询是否是管理员/安全员
  230. async systemSubjectCheckIsAdminOrSafeUser(){
  231. let self = this;
  232. const {
  233. data
  234. } = await systemSubjectCheckIsAdminOrSafeUser();
  235. if (data.code == 200) {
  236. if(data.data.isSafe || data.data.isAdmin){
  237. uni.setStorageSync('subAdmin','1');
  238. }else{
  239. uni.setStorageSync('subAdmin','0');
  240. }
  241. }
  242. },
  243. //查询身份
  244. async securityDataStatisticsGetUserIdentity(routeUrl) {
  245. let self = this;
  246. const {
  247. data
  248. } = await securityDataStatisticsGetUserIdentity();
  249. if(data.schoolAdmin){
  250. //校级管理员
  251. uni.setStorageSync('identityData',{
  252. type:'schoolAdmin'
  253. });
  254. }else if(data.collegeAdmin){
  255. //院级管理员
  256. uni.setStorageSync('identityData',{
  257. type:'collegeAdmin'
  258. });
  259. }else if(data.schoolGroup){
  260. //校级督导组
  261. uni.setStorageSync('identityData',{
  262. type:'schoolGroup',
  263. groupIds:data.groupIds
  264. });
  265. }else if(data.collegeGroup){
  266. //院级督导组
  267. uni.setStorageSync('identityData',{
  268. type:'collegeGroup',
  269. groupIds:data.groupIds
  270. });
  271. }else{
  272. uni.removeStorageSync('identityData');
  273. }
  274. },
  275. checkboxChange() {
  276. this.checkedType = !this.checkedType;
  277. },
  278. },
  279. }
  280. </script>
  281. <style lang="stylus" scoped>
  282. #patrolLogin {
  283. height: 100%;
  284. width: 100%;
  285. background #f5f5f5;
  286. position relative;
  287. .login-max-big {
  288. width: 750rpx;
  289. height: 1177rpx;
  290. z-index: 0;
  291. }
  292. .login-box {
  293. z-index: 3;
  294. position: absolute;
  295. top: 430rpx;
  296. left: 46rpx;
  297. width: 658rpx;
  298. height: 700rpx;
  299. // background #fff
  300. /* 切换按钮 */
  301. .tabTitle {
  302. display flex;
  303. width: 100%;
  304. height: 100rpx;
  305. position: absolute;
  306. // top: 50rpx;
  307. justify-content: center;
  308. .tabTitle_li {
  309. width: 168rpx;
  310. text-align center;
  311. .tabTitle_text {
  312. display: inline-block;
  313. font-size: 32rpx;
  314. font-family: PingFang SC;
  315. font-weight: 500;
  316. color: #333333;
  317. line-height: 90rpx;
  318. &.on {
  319. color: #0183FA;
  320. }
  321. }
  322. .tabTitle_across {
  323. width: 100rpx;
  324. height: 4rpx;
  325. background: #0183FA;
  326. border-radius: 2rpx;
  327. margin-left 30rpx;
  328. display none;
  329. &.on {
  330. display block;
  331. }
  332. }
  333. }
  334. }
  335. border-radius:20rpx;
  336. .input-max-box-one {
  337. overflow: hidden;
  338. // margin-top: 68rpx;
  339. .input-box {
  340. display flex;
  341. width: 600rpx;
  342. height: 80rpx;
  343. border: 1rpx solid #e0e0e0;
  344. border-radius: 40rpx;
  345. margin: 147rpx auto 0;
  346. img {
  347. width: 28rpx;
  348. height: 32rpx;
  349. margin: 24rpx 31rpx;
  350. }
  351. input {
  352. flex: 1;
  353. font-size: 24rpx;
  354. height: 80rpx;
  355. line-height: 80rpx;
  356. margin-right: 31rpx;
  357. }
  358. }
  359. .text-box {
  360. height: 59rpx;
  361. line-height: 59rpx;
  362. color: #DC1616;
  363. font-size: 24rpx;
  364. margin-left: 102rpx;
  365. }
  366. }
  367. .input-max-box-two {
  368. margin-top: 40rpx;
  369. .input-box {
  370. display flex;
  371. width: 600rpx;
  372. height: 80rpx;
  373. border: 1rpx solid #e0e0e0;
  374. border-radius: 40rpx;
  375. margin: 0 auto 0;
  376. img {
  377. width: 30rpx;
  378. height: 32rpx;
  379. margin: 24rpx 30rpx;
  380. }
  381. input {
  382. flex: 1;
  383. font-size: 24rpx;
  384. height: 80rpx;
  385. line-height: 80rpx;
  386. margin-right: 31rpx;
  387. }
  388. }
  389. .text-box {
  390. height: 59rpx;
  391. line-height: 59rpx;
  392. color: #DC1616;
  393. font-size: 24rpx;
  394. margin-left: 102rpx;
  395. }
  396. }
  397. .check-box {
  398. margin: 30rpx 0 30rpx 104rpx;
  399. width: 300rpx;
  400. height: 50rpx;
  401. display: flex;
  402. img {
  403. margin-top: 10rpx;
  404. width: 32rpx;
  405. height: 32rpx;
  406. margin-right: 10rpx;
  407. }
  408. view {
  409. font-size: 24rpx;
  410. line-height: 50rpx;
  411. }
  412. }
  413. .button-box {
  414. width: 600rpx;
  415. line-height: 80rpx;
  416. background: #0183FA;
  417. border-radius: 40rpx;
  418. font-size: 36rpx;
  419. color: #fff;
  420. text-align center;
  421. margin: 0 auto 0;
  422. }
  423. .passwrod-button-box{
  424. line-height:60rpx;
  425. width:120rpx;
  426. margin:20rpx 0 0 40rpx;
  427. color:#333;
  428. font-size:24rpx;
  429. }
  430. /* 供应商注册 */
  431. .supplier {
  432. display: flex;
  433. justify-content: space-between;
  434. margin: 30rpx 40rpx 0;
  435. .supplier_l {
  436. font-size: 24rpx;
  437. font-family: PingFang SC;
  438. font-weight: 400;
  439. color: #333333;
  440. line-height: 24rpx;
  441. }
  442. .supplier_r {
  443. font-size: 24rpx;
  444. font-family: PingFang SC;
  445. font-weight: 400;
  446. color: #333333;
  447. line-height: 24rpx;
  448. >text {
  449. color: #0183FA;
  450. }
  451. }
  452. }
  453. /* 供应商切换 */
  454. .switch_btn {
  455. display: flex;
  456. justify-content: center;
  457. align-items: center;
  458. font-size: 24rpx;
  459. font-family: PingFang SC;
  460. font-weight: 400;
  461. color: #0183FA;
  462. line-height: 24rpx;
  463. margin-top: 60rpx;
  464. >img {
  465. width: 24rpx;
  466. height: 24rpx;
  467. margin-left: 12rpx;
  468. }
  469. }
  470. }
  471. .loginButton{
  472. position: absolute;
  473. width:100%;
  474. bottom:40rpx;
  475. height:80rpx;
  476. line-height:80rpx;
  477. text-align: center;
  478. color:#0183fa;
  479. font-size:28rpx;
  480. }
  481. .top-back {
  482. z-index: 2;
  483. position: absolute;
  484. top: 261rpx;
  485. left: 375rpx;
  486. height: 296rpx;
  487. width: 366rpx;
  488. }
  489. }
  490. </style>