accountLogin.vue 14 KB

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