login.vue 11 KB

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