login.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <!-- 登录 -->
  2. <template>
  3. <view id="login">
  4. <!-- <img class="login-max-big" src="@/images/img_bg_dl.png"> -->
  5. <img class="login-max-big" :src="loginBanner">
  6. <view class="login-box">
  7. <view class="tabTitle">
  8. <view class="tabTitle_li" @tap="tabClick(index)" :key="index" v-for="(item,index) in tabText">
  9. <view :class="{on:curTab==index}" class="tabTitle_text">{{item}}</view>
  10. <view :class="{on:curTab==index}" class="tabTitle_across"></view>
  11. </view>
  12. </view>
  13. <view class="input-max-box-one">
  14. <view class="input-box">
  15. <img src="@/images/img_log_in_account.png"/>
  16. <input type="text" v-model="username" placeholder="请输入账号" maxlength="20">
  17. </view>
  18. </view>
  19. <view class="input-max-box-two">
  20. <view class="input-box">
  21. <img src="@/images/img_log_in_password.png"/>
  22. <input type="password" v-model="password" placeholder="请输入密码" maxlength="20">
  23. </view>
  24. </view>
  25. <view class="check-box" @click="checkboxChange">
  26. <img v-if="checkedType" src="@/images/icon_13.png"/>
  27. <img v-if="!checkedType" src="@/images/icon_12.png"/>
  28. <view>记住我</view>
  29. </view>
  30. <view class="button-box" @click="login">登录</view>
  31. <view class="supplier" v-if="curTab==1">
  32. <view class="supplier_l" @click="handleClick('forget')">忘记密码</view>
  33. <view class="supplier_r" @click="handleClick('register')">没有账号,<text>立即注册</text></view>
  34. </view>
  35. </view>
  36. <!-- <img class="top-back" src="@/images/img_sys_bg.png"/> -->
  37. </view>
  38. </template>
  39. <script>
  40. import { config } from '@/api/request/config.js'
  41. import { login,getLogoInfo,getDemoInfoList,getOpenId,getUrlConfig,getGentleIdentifier} from '@/api/index.js'
  42. import { Encrypt,Decrypt} from '@/utils/secret.js'
  43. export default {
  44. data() {
  45. return {
  46. identityStatus:1,
  47. username:"",
  48. password:"",
  49. checkedType:false,
  50. loginBanner:uni.getStorageSync('loginBanner'),
  51. infoList:[],//模板消息Id
  52. tabText:['师生登录','供应商登录'],
  53. curTab:0,
  54. pageType:0,
  55. }
  56. },
  57. onLoad(option) {
  58. //供应商注册成功后返回到供应商注册页面
  59. if(option.status){
  60. this.identityStatus=2
  61. }
  62. if(uni.getStorageSync('userName') && uni.getStorageSync('password')){
  63. this.username = uni.getStorageSync('userName');
  64. this.password = uni.getStorageSync('password');
  65. this.checkedType = true;
  66. }
  67. },
  68. onShow(){
  69. this.getLogoInfo();
  70. this.getUrlConfig();
  71. },
  72. methods: {
  73. //顶部tab点击
  74. tabClick(index) {
  75. this.curTab = index;
  76. },
  77. //获取用户身份标识"adminGentle": false, 管理员身份 "rectifyGentle": false, 整改身份"applyGentle": false 检查者身份
  78. async getGentleIdentifier(){
  79. let self = this;
  80. const {data} = await getGentleIdentifier();
  81. if(data.code==200){
  82. // 如果是管理员 检查者和整改者
  83. if(data.data.adminGentle && data.data.applyGentle && data.data.rectifyGentle){
  84. self.pageType=0
  85. }else if(data.data.adminGentle && data.data.applyGentle && !data.data.rectifyGentle){
  86. self.pageType=0
  87. }else if(data.data.adminGentle && !data.data.applyGentle && data.data.rectifyGentle){
  88. self.pageType=0
  89. }else if(!data.data.adminGentle && data.data.applyGentle && data.data.rectifyGentle){
  90. self.pageType=1
  91. }else if(data.data.adminGentle && !data.data.applyGentle && !data.data.rectifyGentle){
  92. self.pageType=0
  93. }else if(!data.data.adminGentle && data.data.applyGentle && !data.data.rectifyGentle){
  94. self.pageType=1
  95. }else if(!data.data.adminGentle && !data.data.applyGentle && data.data.rectifyGentle){
  96. self.pageType=2
  97. }else if(!data.data.adminGentle && !data.data.applyGentle && !data.data.rectifyGentle){
  98. console.log('暂无权限')
  99. self.pageType='mine'
  100. }
  101. uni.setStorageSync('gentleIdentifier',self.pageType)
  102. console.log('安全检查身份',self.pageType)
  103. if(self.pageType=='mine'){
  104. uni.redirectTo({
  105. url: '/pages/mine',
  106. });
  107. }else{
  108. uni.redirectTo({
  109. url: '/pages/home',
  110. });
  111. }
  112. }
  113. },
  114. //获取openID
  115. async getOpenId(){
  116. let _this=this;
  117. let code=uni.getStorageSync('code')
  118. const {data} = await getOpenId({code:code});
  119. if(data.code==200){
  120. }else if(data.code==500){
  121. }
  122. },
  123. switchClick(){
  124. if(this.identityStatus==1){
  125. this.identityStatus=2;
  126. }else{
  127. this.identityStatus=1;
  128. }
  129. },
  130. async getLogoInfo(){
  131. const {data} = await getLogoInfo();
  132. if(data.code == 200){
  133. this.loginBanner = config.base_url + data.data.loginBanner;
  134. uni.setStorageSync('loginBanner',config.base_url + data.data.loginBanner)
  135. uni.setStorageSync('homepageBanner',config.base_url + data.data.homepageBanner)
  136. uni.setStorageSync('videoCover',config.base_url + data.data.videoCover)
  137. }
  138. },
  139. async getUrlConfig(){
  140. const {data} = await getUrlConfig();
  141. if(data.code == 200){
  142. //文件预览地址
  143. uni.setStorageSync('filePreviewUrl','https://'+data.data.fileExtranetUrl)
  144. //摄像头代理访问地址
  145. uni.setStorageSync('cameraExtranetAgent','https://'+data.data.cameraExtranetAgent)
  146. //摄像头地址ip段
  147. uni.setStorageSync('cameraIntranetAgent',data.data.cameraIntranetAgent)
  148. //摄像头访问地址
  149. uni.setStorageSync('cameraUrl','https://'+data.data.cameraExtranetUrl)
  150. //MQTT地址
  151. uni.setStorageSync('mqttUrl',Decrypt(data.data.mqttExtranetUrl))
  152. //MQTT账号
  153. uni.setStorageSync('mqttUser',Decrypt(data.data.mqttExtranetUser))
  154. //MQTT密码
  155. uni.setStorageSync('mqttPassword',Decrypt(data.data.mqttExtranetPassword))
  156. }
  157. },
  158. checkboxChange() {
  159. this.checkedType = !this.checkedType;
  160. },
  161. //点击事件
  162. handleClick(doType) {
  163. if(doType=='register'){//供应商注册
  164. uni.redirectTo({
  165. url: '/pages_supplier/register/register?pageStatus=0'
  166. });
  167. }else if(doType=='forget'){//忘记密码
  168. uni.showModal({
  169. showCancel:false,
  170. confirmColor:'#0183FA',
  171. content: '请您联系学校相关管理人员申请重置密码',
  172. success: function (res) {
  173. if (res.confirm) {
  174. }
  175. }
  176. });
  177. }
  178. },
  179. async login() {
  180. let self = this;
  181. let obj = {
  182. username:this.username,
  183. password:this.password,
  184. }
  185. const {data} = await login(obj)
  186. if(data.code == 200){
  187. uni.setStorageSync('token','Bearer '+data.data.access_token);
  188. uni.setStorageSync('userId',data.data.user_id);
  189. this.getOpenId();//获取openid
  190. if(data.data.type == "00" ||data.data.type == "11"){//管理端
  191. uni.setStorageSync('userType',"1");
  192. }else if(data.data.type == 22){//学生端
  193. uni.setStorageSync('userType',"2");
  194. }else if(data.data.type == 33){//供应商端
  195. uni.setStorageSync('userType',"3");
  196. }
  197. if(this.checkedType){
  198. uni.setStorageSync('userName',this.username)
  199. uni.setStorageSync('password',this.password)
  200. }else{
  201. uni.removeStorageSync('userName')
  202. uni.removeStorageSync('password')
  203. }
  204. //获取身份标识
  205. this.getGentleIdentifier();
  206. }
  207. },
  208. },
  209. }
  210. </script>
  211. <style lang="stylus" scoped>
  212. #login{
  213. height:100%;
  214. width:100%;
  215. background #f5f5f5
  216. position relative
  217. .login-max-big{
  218. width:750rpx;
  219. height:1177rpx;
  220. z-index:0;
  221. }
  222. .login-box{
  223. z-index:3;
  224. position: absolute
  225. top:446rpx;
  226. left:46rpx;
  227. width:658rpx;
  228. height:700rpx;
  229. // background #fff
  230. /* 切换按钮 */
  231. .tabTitle{
  232. display flex;
  233. width:100%;
  234. height: 100rpx;
  235. position: absolute;
  236. top: 50rpx;
  237. justify-content: center;
  238. >view:nth-of-type(1){
  239. margin-right: 100rpx;
  240. }
  241. .tabTitle_li{
  242. width:168rpx;
  243. text-align center;
  244. .tabTitle_text{
  245. display: inline-block;
  246. font-size: 32rpx;
  247. font-family: PingFang SC;
  248. font-weight: 500;
  249. color: #333333;
  250. line-height: 90rpx;
  251. &.on{
  252. color:#0183FA;
  253. }
  254. }
  255. .tabTitle_across{
  256. width: 100rpx;
  257. height: 4rpx;
  258. background: #0183FA;
  259. border-radius: 2rpx;
  260. margin-left 30rpx;
  261. display none;
  262. &.on{
  263. display block;
  264. }
  265. }
  266. }
  267. }
  268. border-radius:20rpx;
  269. .input-max-box-one{
  270. overflow: hidden;
  271. margin-top:68rpx;
  272. .input-box{
  273. display flex
  274. width:600rpx;
  275. height:80rpx;
  276. border:1rpx solid #e0e0e0;
  277. border-radius:40rpx;
  278. margin:147rpx auto 0;
  279. img{
  280. width:28rpx;
  281. height:32rpx;
  282. margin:24rpx 31rpx;
  283. }
  284. input{
  285. flex:1;
  286. font-size:24rpx;
  287. height:80rpx;
  288. line-height:80rpx;
  289. margin-right:31rpx;
  290. }
  291. }
  292. .text-box{
  293. height:59rpx;
  294. line-height:59rpx;
  295. color:#DC1616;
  296. font-size:24rpx;
  297. margin-left:102rpx;
  298. }
  299. }
  300. .input-max-box-two{
  301. margin-top:40rpx;
  302. .input-box{
  303. display flex
  304. width:600rpx;
  305. height:80rpx;
  306. border:1rpx solid #e0e0e0;
  307. border-radius:40rpx;
  308. margin:0 auto 0;
  309. img{
  310. width:30rpx;
  311. height:32rpx;
  312. margin:24rpx 30rpx;
  313. }
  314. input{
  315. flex:1;
  316. font-size:24rpx;
  317. height:80rpx;
  318. line-height:80rpx;
  319. margin-right:31rpx;
  320. }
  321. }
  322. .text-box{
  323. height:59rpx;
  324. line-height:59rpx;
  325. color:#DC1616;
  326. font-size:24rpx;
  327. margin-left:102rpx;
  328. }
  329. }
  330. .check-box{
  331. margin:30rpx 0 30rpx 104rpx;
  332. width:300rpx;
  333. height:50rpx;
  334. display:flex;
  335. img{
  336. margin-top:10rpx;
  337. width:32rpx;
  338. height:32rpx;
  339. margin-right:10rpx;
  340. }
  341. view{
  342. font-size:24rpx;
  343. line-height:50rpx;
  344. }
  345. }
  346. .button-box{
  347. width: 600rpx;
  348. line-height: 80rpx;
  349. background: #0183FA;
  350. border-radius: 40rpx;
  351. font-size: 36rpx;
  352. color:#fff;
  353. text-align center
  354. margin:0 auto 0;
  355. }
  356. /* 供应商注册 */
  357. .supplier{
  358. display: flex;
  359. justify-content: space-between;
  360. margin:30rpx 40rpx 0;
  361. .supplier_l{
  362. font-size: 24rpx;
  363. font-family: PingFang SC;
  364. font-weight: 400;
  365. color: #333333;
  366. line-height: 24rpx;
  367. }
  368. .supplier_r{
  369. font-size: 24rpx;
  370. font-family: PingFang SC;
  371. font-weight: 400;
  372. color: #333333;
  373. line-height: 24rpx;
  374. >text{
  375. color: #0183FA;
  376. }
  377. }
  378. }
  379. /* 供应商切换 */
  380. .switch_btn{
  381. display: flex;
  382. justify-content: center;
  383. align-items: center;
  384. font-size: 24rpx;
  385. font-family: PingFang SC;
  386. font-weight: 400;
  387. color: #0183FA;
  388. line-height: 24rpx;
  389. margin-top: 60rpx;
  390. >img{
  391. width: 24rpx;
  392. height: 24rpx;
  393. margin-left: 12rpx;
  394. }
  395. }
  396. }
  397. .top-back{
  398. z-index:2;
  399. position: absolute
  400. top:261rpx;
  401. left:375rpx;
  402. height:296rpx;
  403. width:366rpx;
  404. }
  405. }
  406. </style>