login.vue 13 KB

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