login.vue 11 KB

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