accountLogin.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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" 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" 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.reLaunch({
  138. url: '/pages_basics/views/earlyWarningManage/earlyWarningDetail',
  139. });
  140. } else if (uni.getStorageSync('manageCation')) {
  141. uni.reLaunch({
  142. url: '/pages_manage/views/accessQualification/accessQualificationInfo?item=' + uni.getStorageSync('manageCation')
  143. })
  144. } else if (uni.getStorageSync('studentCation')) {
  145. uni.reLaunch({
  146. url: '/pages_student/views/accessApplication/applicationDetails?item=' + uni.getStorageSync('studentCation')
  147. })
  148. } else {
  149. uni.reLaunch({
  150. url: '/pages/views/home/home',
  151. });
  152. }
  153. }).catch((error) => {
  154. wx.showToast({
  155. title: '数据异常,请稍候再试!',
  156. icon: "none",
  157. duration: 3000
  158. });
  159. })
  160. }else{
  161. wx.showToast({
  162. title: '非教职工/学生账号,无法登录本系统.',
  163. icon: "none",
  164. duration: 3000
  165. });
  166. }
  167. }
  168. },
  169. //获取权限字段
  170. async systemAppletRolePermission() {
  171. let self = this;
  172. const {
  173. data
  174. } = await systemAppletRolePermission();
  175. if (data.code == 200) {
  176. uni.setStorageSync('permissions', data.data.data)
  177. uni.setStorageSync('controlsRestrict', data.data.roleKeys ? data.data.roleKeys : [])
  178. uni.setStorageSync('user', data.data.userInfo)
  179. }
  180. },
  181. switchClick() {
  182. if (this.identityStatus == 1) {
  183. this.identityStatus = 2;
  184. } else {
  185. this.identityStatus = 1;
  186. }
  187. },
  188. //查询公共配置
  189. async getConfigInfo() {
  190. const {
  191. data
  192. } = await configInfo({
  193. type: '1,2,4'
  194. });
  195. if (data.code == 200) {
  196. let list = JSON.parse(data.data)
  197. let newData = {};
  198. list.forEach((item) => {
  199. let obj = JSON.parse(item.configValue)
  200. newData = {
  201. ...newData,
  202. ...obj
  203. }
  204. })
  205. uni.setStorageSync('circularLogo', config.base_url + newData.circularLogo)
  206. uni.setStorageSync('rectangleLogo', config.base_url + newData.rectangleLogo)
  207. uni.setStorageSync('videoCover', config.base_url + newData.videoCover)
  208. this.$set(this, 'loginBanner', config.base_url + newData.loginBanner);
  209. uni.setStorageSync('loginBanner', config.base_url + newData.loginBanner)
  210. this.$set(this, 'supplierType', newData.supplier);
  211. uni.setStorageSync('supplierType', newData.supplier)
  212. uni.setStorageSync('homepageBanner', config.base_url + newData.homepageBanner)
  213. }
  214. },
  215. //获取开发配置
  216. async getConfigByType() {
  217. const {
  218. data
  219. } = await getConfigByType({
  220. category: 2,
  221. configType: 5
  222. });
  223. if (data.code == 200) {
  224. let obj = JSON.parse(data.data.configValue)
  225. //文件预览地址
  226. uni.setStorageSync('filePreviewUrl', 'https://' + obj.fileExtranetUrl)
  227. //小程序视频地址
  228. uni.setStorageSync('cameraExtranetAgent', 'https://' + obj.cameraExtranetAgent)
  229. //MQTT地址
  230. uni.setStorageSync('mqttUrl', Decrypt(obj.mqttExtranetUrl))
  231. //MQTT地址-内网
  232. uni.setStorageSync('mqttIntranetUrl', Decrypt(obj.mqttIntranetUrl))
  233. //MQTT账号
  234. uni.setStorageSync('mqttUser', Decrypt(obj.mqttExtranetUser))
  235. //MQTT密码
  236. uni.setStorageSync('mqttPassword', Decrypt(obj.mqttExtranetPassword))
  237. //文件浏览环境
  238. uni.setStorageSync('fileBrowseEnvironment','http://'+Decrypt(obj.fileBrowseEnvironment))
  239. uni.setStorageSync('fileBrowseEnvironmentExtranet','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. bottom:40rpx;
  487. left:295rpx;
  488. width:300;
  489. height:80rpx;
  490. line-height:80rpx;
  491. text-align: center;
  492. color:#0183fa;
  493. font-size:28rpx;
  494. }
  495. .top-back {
  496. z-index: 2;
  497. position: absolute;
  498. top: 261rpx;
  499. left: 375rpx;
  500. height: 296rpx;
  501. width: 366rpx;
  502. }
  503. }
  504. </style>