accountLogin.vue 13 KB

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