accountLogin.vue 12 KB

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