login.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. <template>
  2. <view class="login">
  3. <view class="container">
  4. <view class="logo">
  5. <image :src="src1" class="img " />
  6. </view>
  7. <!--插画-->
  8. <view class="right-top-sign"></view>
  9. <view class="wrapper">
  10. <view class="welcome">
  11. 教育局督导评估系统
  12. </view>
  13. <view class="input-content">
  14. <view class="input-item">
  15. <text class="tit">用户名:</text>
  16. <input v-model="username" placeholder="请输入用户名" style="height: 40px;line-height: 40px;"
  17. :focus="isfocus1" @confirm="confirm('1')" />
  18. </view>
  19. <view class="input-item">
  20. <text class="tit">密码:</text>
  21. <input type="password" v-model="password" style="line-height: 40px;height: 40px;"
  22. placeholder="请输入密码" maxlength="20" :focus="isfocus2" @confirm="confirm('2')" />
  23. </view>
  24. <view class="input-item input-item-sms-code">
  25. <view class="input-wrapper">
  26. <view class="oa-input-wrapper">
  27. <view class="tit" style="width:18vw">验证码:</view>
  28. <input v-model="captcha" placeholder="请输入验证码"
  29. style="height: 40px;width:55%;line-height: 40px;" maxlength="4" data-key="mobile"
  30. :focus="isfocus3" @confirm="confirm('3')" />
  31. </view>
  32. <view @click="getCaptcha()">
  33. <img class="sms-code-img" v-bind:src="src" width="100%" height="100%"
  34. style="margin-top:6px"></img>
  35. </view>
  36. </view>
  37. </view>
  38. <view>
  39. <button class="confirm-btn" :class="'bg-' + themeColor.name" v-on:click="prelogin()">
  40. 登录
  41. </button>
  42. <!-- <view style="float: right;margin-top: 5px;margin-right: 10px;" @click="backIndex()">返回首页</view> -->
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import {
  52. toastMsg
  53. } from '@/pages/toast/toast.js'
  54. export default {
  55. components: {
  56. },
  57. data() {
  58. return {
  59. src1: '/static/logo.png',
  60. smsCodeBtnDisabled: false,
  61. src: "",
  62. uuid: "",
  63. captcha: "",
  64. username: "",
  65. password: "",
  66. token: "",
  67. isfocus1: true,
  68. isfocus2: false,
  69. isfocus3: false
  70. };
  71. },
  72. created() {
  73. this.checkStatus();
  74. this.getCaptcha();
  75. },
  76. methods: {
  77. checkStatus() {
  78. },
  79. confirm(index) {
  80. switch (index) {
  81. case '1':
  82. this.isfocus1 = false;
  83. this.isfocus2 = true;
  84. this.isfocus3 = false;
  85. break;
  86. case '2':
  87. this.isfocus1 = false;
  88. this.isfocus2 = false;
  89. this.isfocus3 = true;
  90. break;
  91. case '3':
  92. this.isfocus1 = false;
  93. this.isfocus2 = false;
  94. this.isfocus3 = false;
  95. this.prelogin();
  96. break;
  97. }
  98. },
  99. getCaptcha() {
  100. var url = this.$mConfig.baseUrl + '/captchaImage';
  101. var that = this;
  102. uni.request({
  103. url: url,
  104. success: (res) => {
  105. that.src = "data:image/gif;base64," + res.data.img;
  106. that.uuid = res.data.uuid;
  107. }
  108. });
  109. },
  110. prelogin() {
  111. if (this.username == '') {
  112. toastMsg('warning', "请输入用户名");
  113. return false;
  114. }
  115. if (this.password == '') {
  116. toastMsg('warning', "请输入密码");
  117. return false;
  118. }
  119. if (this.captcha == '') {
  120. toastMsg('warning', "请输入验证码");
  121. return false;
  122. }
  123. toastMsg("loading", "奋力加载中..");
  124. this.login();
  125. },
  126. login() {
  127. var url = this.$mConfig.baseUrl + '/appinterface/login';
  128. var that = this;
  129. uni.request({
  130. url: url,
  131. method: "POST",
  132. data: {
  133. username: this.username,
  134. password: this.password,
  135. code: this.captcha,
  136. uuid: this.uuid
  137. },
  138. dataType: "JSON",
  139. success: (res) => {
  140. uni.hideToast();
  141. if (res.statusCode == "200") {
  142. var data = res.data;
  143. if (data != null) {
  144. if (data.code == "200") {
  145. toastMsg("success", "登录成功");
  146. //保存登录状态信息
  147. that.token = data.token;
  148. that.$store.commit('login', data);
  149. that.getTabBarBadge();
  150. uni.reLaunch({
  151. url: '../index/index'
  152. });
  153. } else {
  154. that.getCaptcha();
  155. toastMsg("warning", data.msg);
  156. }
  157. }
  158. } else {
  159. that.getCaptcha();
  160. toastMsg("warning", "网络异常");
  161. }
  162. }
  163. });
  164. },
  165. backIndex() {
  166. uni.reLaunch({
  167. url: '../index/index'
  168. });
  169. }
  170. }
  171. }
  172. </script>
  173. <style lang="scss">
  174. page {
  175. background: $color-white;
  176. }
  177. .logo {
  178. width: 20vw;
  179. height: 20vw;
  180. margin: 0 auto;
  181. }
  182. .container .input-item {
  183. display: block !important;
  184. height: 40px !important;
  185. line-height: 40px !important;
  186. }
  187. .logo .img {
  188. width: 20vw;
  189. height: 20vw;
  190. }
  191. .container {
  192. padding-top: 115px;
  193. position: relative;
  194. width: 100vw;
  195. overflow: hidden;
  196. background: #fff;
  197. .wrapper {
  198. position: relative;
  199. z-index: 90;
  200. background: #fff;
  201. padding-bottom: 40upx;
  202. }
  203. .back-btn {
  204. position: absolute;
  205. left: 40upx;
  206. z-index: 9999;
  207. padding-top: var(--status-bar-height);
  208. top: 40upx;
  209. font-size: 40upx;
  210. color: $font-color-dark;
  211. }
  212. .left-top-sign {
  213. font-size: 120upx;
  214. color: $page-color-base;
  215. position: relative;
  216. left: -16upx;
  217. }
  218. .right-top-sign {
  219. position: absolute;
  220. top: 80upx;
  221. right: -30upx;
  222. z-index: 95;
  223. &:before,
  224. &:after {
  225. display: block;
  226. content: '';
  227. width: 400upx;
  228. height: 80upx;
  229. background: #b4f3e2;
  230. }
  231. &:before {
  232. transform: rotate(50deg);
  233. border-radius: 0 50px 0 0;
  234. }
  235. &:after {
  236. position: absolute;
  237. right: -198upx;
  238. top: 0;
  239. transform: rotate(-50deg);
  240. border-radius: 50px 0 0 0;
  241. /* background: pink; */
  242. }
  243. }
  244. .left-bottom-sign {
  245. position: absolute;
  246. left: -270upx;
  247. bottom: -320upx;
  248. border: 100upx solid #d0d1fd;
  249. border-radius: 50%;
  250. padding: 180upx;
  251. }
  252. .welcome {
  253. text-align: center;
  254. margin-top: 25upx;
  255. font-size: 46upx;
  256. color: #555;
  257. text-shadow: 1px 0px 1px rgba(0, 0, 0, 0.3);
  258. }
  259. .input-content {
  260. padding: 60upx;
  261. }
  262. .input-item {
  263. display: flex;
  264. flex-direction: column;
  265. align-items: flex-start;
  266. justify-content: center;
  267. padding: 0 30upx;
  268. background: $page-color-light;
  269. height: 120upx;
  270. border-radius: 4px;
  271. margin-bottom: 50upx;
  272. &:last-child {
  273. margin-bottom: 0;
  274. }
  275. .tit {
  276. height: 40px;
  277. width: 18vw;
  278. text-align: right;
  279. float: left;
  280. line-height: 40px;
  281. font-size: $font-sm + 2upx;
  282. color: $font-color-base;
  283. }
  284. input {
  285. height: 60upx;
  286. font-size: $font-base + 2upx;
  287. color: $font-color-dark;
  288. width: 70%;
  289. float: right;
  290. }
  291. }
  292. .input-item-sms-code {
  293. position: relative;
  294. width: 100%;
  295. .sms-code-btn {
  296. position: absolute;
  297. color: #111;
  298. right: 20upx;
  299. bottom: 20upx;
  300. font-size: 28upx;
  301. }
  302. .sms-code-btn,
  303. sms-code-resend {
  304. width: 240upx;
  305. font-size: $font-base - 2upx;
  306. }
  307. .sms-code-resend {
  308. color: #999;
  309. }
  310. .sms-code-btn:after {
  311. border: none;
  312. background-color: transparent;
  313. }
  314. .tit {
  315. height: 50upx;
  316. width: 4rem;
  317. text-align: right;
  318. }
  319. }
  320. .forget-section {
  321. font-size: $font-sm + 2upx;
  322. color: $font-color-spec;
  323. text-align: center;
  324. margin-top: 40upx;
  325. }
  326. .register-section {
  327. margin: 30upx 0 50upx 0;
  328. width: 100%;
  329. font-size: $font-sm + 2upx;
  330. color: $font-color-base;
  331. text-align: center;
  332. text {
  333. color: $font-color-spec;
  334. margin-left: 10upx;
  335. }
  336. text:first-child {
  337. margin-right: 10upx;
  338. }
  339. }
  340. .btn-group {
  341. display: flex;
  342. margin-bottom: 20upx;
  343. }
  344. }
  345. .login-type-2 {
  346. width: 100%;
  347. position: relative;
  348. .back-btn {
  349. position: absolute;
  350. left: 40upx;
  351. z-index: 9999;
  352. padding-top: var(--status-bar-height);
  353. top: 40upx;
  354. font-size: 48upx;
  355. color: $color-white;
  356. }
  357. .login-top {
  358. height: 460upx;
  359. position: relative;
  360. .desc {
  361. position: absolute;
  362. top: 200upx;
  363. left: 40upx;
  364. font-size: 48upx;
  365. .title {
  366. font-size: 48upx;
  367. }
  368. }
  369. .login-pic {
  370. position: absolute;
  371. width: 220upx;
  372. height: 270upx;
  373. right: 30upx;
  374. top: 100upx;
  375. }
  376. }
  377. .login-type-content {
  378. position: relative;
  379. top: -72upx;
  380. .login-bg {
  381. width: 94vw;
  382. height: 94vw;
  383. margin: 0 3vw;
  384. }
  385. .main {
  386. width: 94vw;
  387. position: absolute;
  388. top: 0;
  389. left: 3vw;
  390. .nav-bar {
  391. display: flex;
  392. height: 100upx;
  393. justify-content: center;
  394. align-items: center;
  395. position: relative;
  396. z-index: 10;
  397. .nav-bar-item {
  398. flex: 1;
  399. display: flex;
  400. height: 100%;
  401. line-height: 96upx;
  402. font-size: $font-lg;
  403. display: flex;
  404. margin: 0 120upx;
  405. justify-content: center;
  406. }
  407. .nav-bar-item-active {
  408. border-bottom: 5upx solid;
  409. }
  410. }
  411. .login-type-form {
  412. width: 80%;
  413. margin: 50upx auto;
  414. .iconfont {
  415. font-size: 50upx;
  416. position: absolute;
  417. left: 0;
  418. }
  419. .login-type-input {
  420. height: 90upx;
  421. padding-left: 80upx;
  422. border-bottom: 1upx solid rgba(0, 0, 0, .1);
  423. }
  424. }
  425. .login-type-tips {
  426. padding: 0 50upx;
  427. display: flex;
  428. justify-content: space-between;
  429. }
  430. .confirm-btn {
  431. height: 80upx;
  432. line-height: 80upx;
  433. }
  434. }
  435. }
  436. .login-type-bottom {
  437. width: 100%;
  438. padding-bottom: 30upx;
  439. text-align: center;
  440. font-size: $font-lg;
  441. }
  442. .sms-code-img {
  443. position: absolute;
  444. color: #111;
  445. right: 9px;
  446. bottom: 9px;
  447. font-size: 13px;
  448. }
  449. }
  450. .input-item {
  451. position: relative;
  452. margin-bottom: $spacing-lg;
  453. }
  454. .right_input {
  455. height: 40px;
  456. line-height: 40px !important;
  457. }
  458. </style>