login.vue 9.6 KB

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