login.vue 12 KB

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