login.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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. uni.setStorageSync('gentleIdentifierData',data.data)
  78. let list=[];
  79. if(data.data.adminGentle || data.data.collegeGentle){//校级管理员
  80. list.push({name:'管理员',pageType:1})
  81. }
  82. if(data.data.applyGentle ||data.data.myApplyGentle){
  83. list.push({name:'检查者',pageType:2})
  84. }
  85. if(data.data.rectifyGentle){
  86. list.push({name:'整改者',pageType:3})
  87. }
  88. if(!data.data.adminGentle && !data.data.applyGentle && !data.data.myApplyGentle && !data.data.applyGentle && !data.data.collegeGentle){
  89. self.pageType='mine'
  90. list.push({name:'暂无权限',pageType:'mine'})
  91. }
  92. uni.setStorageSync('gentleIdentifier',list)
  93. if(uni.getStorageSync('saoCode')){
  94. uni.redirectTo({
  95. url: '/pages/saoCode/saoCode'
  96. });
  97. }else if(self.pageType=='mine'){
  98. uni.redirectTo({
  99. url: '/pages/mine',
  100. });
  101. }else{
  102. uni.redirectTo({
  103. url: '/pages/home',
  104. });
  105. }
  106. }
  107. },
  108. //获取openID
  109. async getOpenId(){
  110. let _this=this;
  111. let code=uni.getStorageSync('code')
  112. const {data} = await getOpenId({code:code});
  113. if(data.code==200){
  114. }else if(data.code==500){
  115. }
  116. },
  117. switchClick(){
  118. if(this.identityStatus==1){
  119. this.identityStatus=2;
  120. }else{
  121. this.identityStatus=1;
  122. }
  123. },
  124. async getLogoInfo(){
  125. const {data} = await getLogoInfo();
  126. if(data.code == 200){
  127. this.loginBanner = config.base_url + data.data.loginBanner;
  128. uni.setStorageSync('circularLogo',config.base_url + data.data.circularLogo)
  129. uni.setStorageSync('loginBanner',config.base_url + data.data.loginBanner)
  130. uni.setStorageSync('homepageBanner',config.base_url + data.data.homepageBanner)
  131. uni.setStorageSync('videoCover',config.base_url + data.data.videoCover)
  132. }
  133. },
  134. async getUrlConfig(){
  135. const {data} = await getUrlConfig();
  136. if(data.code == 200){
  137. //文件预览地址
  138. uni.setStorageSync('filePreviewUrl','https://'+data.data.fileExtranetUrl)
  139. //摄像头代理访问地址
  140. uni.setStorageSync('cameraExtranetAgent','https://'+data.data.cameraExtranetAgent)
  141. //摄像头地址ip段
  142. uni.setStorageSync('cameraIntranetAgent',data.data.cameraIntranetAgent)
  143. //摄像头访问地址
  144. uni.setStorageSync('cameraUrl','https://'+data.data.cameraExtranetUrl)
  145. //MQTT地址
  146. uni.setStorageSync('mqttUrl',Decrypt(data.data.mqttExtranetUrl))
  147. //MQTT账号
  148. uni.setStorageSync('mqttUser',Decrypt(data.data.mqttExtranetUser))
  149. //MQTT密码
  150. uni.setStorageSync('mqttPassword',Decrypt(data.data.mqttExtranetPassword))
  151. }
  152. },
  153. checkboxChange() {
  154. this.checkedType = !this.checkedType;
  155. },
  156. //点击事件
  157. handleClick(doType) {
  158. if(doType=='register'){//供应商注册
  159. uni.redirectTo({
  160. url: '/pages_supplier/register/register?pageStatus=0'
  161. });
  162. }else if(doType=='forget'){//忘记密码
  163. uni.showModal({
  164. showCancel:false,
  165. confirmColor:'#0183FA',
  166. content: '请您联系学校相关管理人员申请重置密码',
  167. success: function (res) {
  168. if (res.confirm) {
  169. }
  170. }
  171. });
  172. }
  173. },
  174. async login() {
  175. let self = this;
  176. let obj = {
  177. username:this.username,
  178. password:this.password,
  179. }
  180. const {data} = await login(obj)
  181. if(data.code == 200){
  182. uni.setStorageSync('token','Bearer '+data.data.access_token);
  183. uni.setStorageSync('userId',data.data.user_id);
  184. this.getOpenId();//获取openid
  185. if(data.data.type == "00" ||data.data.type == "11"){//管理端
  186. uni.setStorageSync('userType',"1");
  187. }else if(data.data.type == 22){//学生端
  188. uni.setStorageSync('userType',"2");
  189. }else if(data.data.type == 33){//供应商端
  190. uni.setStorageSync('userType',"3");
  191. }
  192. if(this.checkedType){
  193. uni.setStorageSync('userName',this.username)
  194. uni.setStorageSync('password',this.password)
  195. }else{
  196. uni.removeStorageSync('userName')
  197. uni.removeStorageSync('password')
  198. }
  199. //获取身份标识
  200. this.getGentleIdentifier();
  201. }
  202. },
  203. },
  204. }
  205. </script>
  206. <style lang="stylus" scoped>
  207. #login{
  208. height:100%;
  209. width:100%;
  210. background #f5f5f5
  211. position relative
  212. .login-max-big{
  213. width:750rpx;
  214. height:1102rpx;
  215. z-index:0;
  216. }
  217. .login-box{
  218. z-index:1;
  219. position: absolute
  220. top:446rpx;
  221. left:46rpx;
  222. width:658rpx;
  223. height:655rpx;
  224. // background #fff
  225. border-radius:20rpx;
  226. .input-max-box-one{
  227. .input-box{
  228. display flex
  229. width:600rpx;
  230. height:80rpx;
  231. border:1rpx solid #e0e0e0;
  232. border-radius:40rpx;
  233. margin:147rpx auto 0;
  234. img{
  235. width:28rpx;
  236. height:32rpx;
  237. margin:24rpx 31rpx;
  238. }
  239. input{
  240. flex:1;
  241. font-size:24rpx;
  242. height:80rpx;
  243. line-height:80rpx;
  244. margin-right:31rpx;
  245. }
  246. }
  247. .text-box{
  248. height:59rpx;
  249. line-height:59rpx;
  250. color:#DC1616;
  251. font-size:24rpx;
  252. margin-left:102rpx;
  253. }
  254. }
  255. .input-max-box-two{
  256. margin-top:40rpx;
  257. .input-box{
  258. display flex
  259. width:600rpx;
  260. height:80rpx;
  261. border:1rpx solid #e0e0e0;
  262. border-radius:40rpx;
  263. margin:0 auto 0;
  264. img{
  265. width:30rpx;
  266. height:32rpx;
  267. margin:24rpx 30rpx;
  268. }
  269. input{
  270. flex:1;
  271. font-size:24rpx;
  272. height:80rpx;
  273. line-height:80rpx;
  274. margin-right:31rpx;
  275. }
  276. }
  277. .text-box{
  278. height:59rpx;
  279. line-height:59rpx;
  280. color:#DC1616;
  281. font-size:24rpx;
  282. margin-left:102rpx;
  283. }
  284. }
  285. .check-max-box{
  286. display flex;
  287. .check-box{
  288. margin:30rpx 0 30rpx 104rpx;
  289. width:300rpx;
  290. height:50rpx;
  291. display:flex;
  292. img{
  293. margin-top:10rpx;
  294. width:32rpx;
  295. height:32rpx;
  296. margin-right:10rpx;
  297. }
  298. view{
  299. font-size:24rpx;
  300. line-height:50rpx;
  301. }
  302. }
  303. .check-right-box{
  304. font-size:24rpx;
  305. line-height:50rpx;
  306. margin:30rpx 0 30rpx 30rpx;
  307. }
  308. }
  309. .button-box{
  310. width: 600rpx;
  311. line-height: 80rpx;
  312. background: #0183FA;
  313. border-radius: 40rpx;
  314. font-size: 36rpx;
  315. color:#fff;
  316. text-align center
  317. margin:0 auto 0;
  318. }
  319. }
  320. .top-back{
  321. z-index:2;
  322. position: absolute
  323. top:261rpx;
  324. left:375rpx;
  325. height:296rpx;
  326. width:366rpx;
  327. }
  328. }
  329. </style>