login.vue 12 KB

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