login.vue 10 KB

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