login.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  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('fileBrowseEnvironmentExtranet','https://'+Decrypt(obj.fileBrowseEnvironmentExtranet))
  238. }
  239. },
  240. //查询是否是管理员/安全员
  241. async systemSubjectCheckIsAdminOrSafeUser(){
  242. let self = this;
  243. const {
  244. data
  245. } = await systemSubjectCheckIsAdminOrSafeUser();
  246. if (data.code == 200) {
  247. if(data.data.isSafe || data.data.isAdmin){
  248. uni.setStorageSync('subAdmin','1');
  249. }else{
  250. uni.setStorageSync('subAdmin','0');
  251. }
  252. }
  253. },
  254. //查询身份
  255. async securityDataStatisticsGetUserIdentity(routeUrl) {
  256. let self = this;
  257. const {
  258. data
  259. } = await securityDataStatisticsGetUserIdentity();
  260. if(data.schoolAdmin){
  261. //校级管理员
  262. uni.setStorageSync('identityData',{
  263. type:'schoolAdmin'
  264. });
  265. }else if(data.collegeAdmin){
  266. //院级管理员
  267. uni.setStorageSync('identityData',{
  268. type:'collegeAdmin'
  269. });
  270. }else if(data.schoolGroup){
  271. //校级督导组
  272. uni.setStorageSync('identityData',{
  273. type:'schoolGroup',
  274. groupIds:data.groupIds
  275. });
  276. }else if(data.collegeGroup){
  277. //院级督导组
  278. uni.setStorageSync('identityData',{
  279. type:'collegeGroup',
  280. groupIds:data.groupIds
  281. });
  282. }else{
  283. uni.removeStorageSync('identityData');
  284. }
  285. },
  286. checkboxChange() {
  287. this.checkedType = !this.checkedType;
  288. },
  289. },
  290. }
  291. </script>
  292. <style lang="stylus" scoped>
  293. #accountLogin {
  294. height: 100%;
  295. width: 100%;
  296. background #f5f5f5;
  297. position relative;
  298. .login-max-big {
  299. width: 750rpx;
  300. height: 1177rpx;
  301. z-index: 0;
  302. }
  303. .login-box {
  304. z-index: 3;
  305. position: absolute;
  306. top: 430rpx;
  307. left: 46rpx;
  308. width: 658rpx;
  309. height: 700rpx;
  310. // background #fff
  311. /* 切换按钮 */
  312. .tabTitle {
  313. display flex;
  314. width: 100%;
  315. height: 100rpx;
  316. position: absolute;
  317. // top: 50rpx;
  318. justify-content: center;
  319. .tabTitle_li {
  320. width: 168rpx;
  321. text-align center;
  322. .tabTitle_text {
  323. display: inline-block;
  324. font-size: 32rpx;
  325. font-family: PingFang SC;
  326. font-weight: 500;
  327. color: #333333;
  328. line-height: 90rpx;
  329. &.on {
  330. color: #0183FA;
  331. }
  332. }
  333. .tabTitle_across {
  334. width: 100rpx;
  335. height: 4rpx;
  336. background: #0183FA;
  337. border-radius: 2rpx;
  338. margin-left 30rpx;
  339. display none;
  340. &.on {
  341. display block;
  342. }
  343. }
  344. }
  345. }
  346. border-radius:20rpx;
  347. .input-max-box-one {
  348. overflow: hidden;
  349. // margin-top: 68rpx;
  350. .input-box {
  351. display flex;
  352. width: 600rpx;
  353. height: 80rpx;
  354. border: 1rpx solid #e0e0e0;
  355. border-radius: 40rpx;
  356. margin: 147rpx auto 0;
  357. img {
  358. width: 28rpx;
  359. height: 32rpx;
  360. margin: 24rpx 31rpx;
  361. }
  362. input {
  363. flex: 1;
  364. font-size: 24rpx;
  365. height: 80rpx;
  366. line-height: 80rpx;
  367. margin-right: 31rpx;
  368. }
  369. }
  370. .text-box {
  371. height: 59rpx;
  372. line-height: 59rpx;
  373. color: #DC1616;
  374. font-size: 24rpx;
  375. margin-left: 102rpx;
  376. }
  377. }
  378. .input-max-box-two {
  379. margin-top: 40rpx;
  380. .input-box {
  381. display flex;
  382. width: 600rpx;
  383. height: 80rpx;
  384. border: 1rpx solid #e0e0e0;
  385. border-radius: 40rpx;
  386. margin: 0 auto 0;
  387. img {
  388. width: 30rpx;
  389. height: 32rpx;
  390. margin: 24rpx 30rpx;
  391. }
  392. input {
  393. flex: 1;
  394. font-size: 24rpx;
  395. height: 80rpx;
  396. line-height: 80rpx;
  397. margin-right: 31rpx;
  398. }
  399. }
  400. .text-box {
  401. height: 59rpx;
  402. line-height: 59rpx;
  403. color: #DC1616;
  404. font-size: 24rpx;
  405. margin-left: 102rpx;
  406. }
  407. }
  408. .check-box {
  409. margin: 30rpx 0 30rpx 104rpx;
  410. width: 300rpx;
  411. height: 50rpx;
  412. display: flex;
  413. img {
  414. margin-top: 10rpx;
  415. width: 32rpx;
  416. height: 32rpx;
  417. margin-right: 10rpx;
  418. }
  419. view {
  420. font-size: 24rpx;
  421. line-height: 50rpx;
  422. }
  423. }
  424. .button-box {
  425. width: 600rpx;
  426. line-height: 80rpx;
  427. background: #0183FA;
  428. border-radius: 40rpx;
  429. font-size: 36rpx;
  430. color: #fff;
  431. text-align center;
  432. margin: 0 auto 0;
  433. }
  434. .passwrod-button-box{
  435. line-height:60rpx;
  436. width:120rpx;
  437. margin:20rpx 0 0 40rpx;
  438. color:#333;
  439. font-size:24rpx;
  440. }
  441. /* 供应商注册 */
  442. .supplier {
  443. display: flex;
  444. justify-content: space-between;
  445. margin: 30rpx 40rpx 0;
  446. .supplier_l {
  447. font-size: 24rpx;
  448. font-family: PingFang SC;
  449. font-weight: 400;
  450. color: #333333;
  451. line-height: 24rpx;
  452. }
  453. .supplier_r {
  454. font-size: 24rpx;
  455. font-family: PingFang SC;
  456. font-weight: 400;
  457. color: #333333;
  458. line-height: 24rpx;
  459. >text {
  460. color: #0183FA;
  461. }
  462. }
  463. }
  464. /* 供应商切换 */
  465. .switch_btn {
  466. display: flex;
  467. justify-content: center;
  468. align-items: center;
  469. font-size: 24rpx;
  470. font-family: PingFang SC;
  471. font-weight: 400;
  472. color: #0183FA;
  473. line-height: 24rpx;
  474. margin-top: 60rpx;
  475. >img {
  476. width: 24rpx;
  477. height: 24rpx;
  478. margin-left: 12rpx;
  479. }
  480. }
  481. }
  482. .loginButton{
  483. position: absolute;
  484. width:100%;
  485. bottom:40rpx;
  486. height:80rpx;
  487. line-height:80rpx;
  488. text-align: center;
  489. color:#0183fa;
  490. font-size:28rpx;
  491. }
  492. .top-back {
  493. z-index: 2;
  494. position: absolute;
  495. top: 261rpx;
  496. left: 375rpx;
  497. height: 296rpx;
  498. width: 366rpx;
  499. }
  500. }
  501. </style>