login.vue 8.1 KB

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