login.vue 9.1 KB

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