login.vue 12 KB

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