accountLogin.vue 12 KB

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