login.vue 10 KB

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