login.vue 12 KB

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