login.vue 9.6 KB

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