accountLogin.vue 14 KB

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