accountLogin.vue 12 KB

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