login.vue 9.6 KB

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