Login.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <div class="login_par">
  3. <div class="login_head">
  4. <div class="login_logo">
  5. <img src="../assets/image/login_logo.png" style="width:80px;height:80px;"/>
  6. </div>
  7. <mt-navbar v-model="selected">
  8. <mt-tab-item id="login"><div class="login_tab">登录</div></mt-tab-item>
  9. <!-- <mt-tab-item id="registered"><div class="login_tab"></div></mt-tab-item> -->
  10. </mt-navbar>
  11. </div>
  12. <mt-tab-container v-model="selected" class="login_box">
  13. <mt-tab-container-item id="login">
  14. <div>
  15. <!-- <mt-field placeholder="请输入手机号" :state="login.account" type="number" v-model="ruleForm.account"></mt-field>
  16. <mt-field placeholder="请输入密码" :state="login.password" type="password" v-model="ruleForm.password"></mt-field> -->
  17. <div class="out_input">
  18. <img class="phone" src="../assets/image/user.png">
  19. <input class="input" placeholder="请输入账号" v-model="ruleForm.loginName" />
  20. </div>
  21. <div class="out_input">
  22. <img src="../assets/image/password.png">
  23. <input class="input" placeholder="请输入密码" type="password" v-model="ruleForm.password" />
  24. </div>
  25. <mt-button size="large" type="primary" @click="handleLogin">登录</mt-button>
  26. </div>
  27. </mt-tab-container-item>
  28. <mt-tab-container-item id="registered">
  29. <div>
  30. <!-- <mt-field placeholder="请输入姓名" v-model="ruleForm.regName"></mt-field>
  31. <mt-field placeholder="请输入手机号" type="number" v-model="ruleForm.regPhone"></mt-field>
  32. <mt-field placeholder="请输入验证码" type="number" v-model="ruleForm.regAccount">
  33. <span class="getCode" @click="getCode">获取验证码</span>
  34. </mt-field>
  35. <mt-field placeholder="请输入密码" type="password" v-model="ruleForm.regPassWord"></mt-field>
  36. <mt-field placeholder="请确认密码" type="password" v-model="ruleForm.regPassWord1"></mt-field> -->
  37. <div class="out_input">
  38. <img src="../assets/image/user.png">
  39. <input class="input" placeholder="请输入姓名" v-model="ruleForm.regName" />
  40. </div>
  41. <div class="out_input">
  42. <img class="phone" src="../assets/image/phone.png">
  43. <input class="input" placeholder="请输入手机号" type="number" v-model="ruleForm.regPhone" />
  44. </div>
  45. <div class="out_input">
  46. <img class="phone" src="../assets/image/vcode.png">
  47. <input class="input" placeholder="请输入验证码" oninput="if(value.length>6)value=value.slice(0,6)" type="number" v-model="ruleForm.regAccount" />
  48. <span class="text" @click="getCode()">{{code == "获取验证码"?'获取验证码':code+'s'}}</span>
  49. </div>
  50. <div class="out_input">
  51. <img src="../assets/image/password.png">
  52. <input class="input" placeholder="请输入密码" type="password" v-model="ruleForm.regPassWord" />
  53. </div>
  54. <div class="out_input">
  55. <img src="../assets/image/password.png">
  56. <input class="input" placeholder="请确认密码" type="password" v-model="ruleForm.regPassWord1" />
  57. </div>
  58. <mt-button size="large" type="primary" @click="handleRegistered">注册</mt-button>
  59. </div>
  60. </mt-tab-container-item>
  61. </mt-tab-container>
  62. </div>
  63. </template>
  64. <script>
  65. export default {
  66. data() {
  67. return {
  68. selected: 'login',
  69. logining: false,
  70. code: "获取验证码",
  71. // 登录信息
  72. ruleForm: {
  73. loginName: '',
  74. password: '',
  75. regName: '',
  76. regPhone: '',
  77. regAccount: '',
  78. regPassWord: '',
  79. regPassWord1: '',
  80. },
  81. login: {
  82. loginName: "",
  83. password: "",
  84. },
  85. canClick: true,
  86. };
  87. },
  88. methods: {
  89. handleLogin() {
  90. if(this.canClick) {
  91. this.canClick = false;
  92. if(this.ruleForm.loginName == "") {
  93. this.$toast({
  94. message: '请输入账号',
  95. duration: 2000
  96. });
  97. return false;
  98. } else if(this.ruleForm.password == "") {
  99. this.$toast({
  100. message: '请输入密码',
  101. duration: 2000
  102. });
  103. return false;
  104. } else {
  105. this.$indicator.open();
  106. this.http.post(this.port.manage.login, {
  107. "loginName": this.ruleForm.loginName,
  108. "password": this.ruleForm.password,
  109. } , res => {
  110. this.canClick = true;
  111. this.$indicator.close();
  112. if (res.code == "ok") {
  113. sessionStorage.setItem('user', JSON.stringify(res.data));
  114. var str = '';
  115. for(var i in res.data.functions) {
  116. str += res.data.functions[i].code + ",";
  117. }
  118. sessionStorage.setItem('power',str)
  119. this.$router.push({ path: '/assets' });
  120. } else {
  121. this.$toast({
  122. message: res.msg,
  123. duration: 2000
  124. });
  125. }
  126. }, error => {
  127. this.canClick = true;
  128. this.$indicator.close();
  129. this.$toast({
  130. message: error,
  131. duration: 2000
  132. });
  133. })
  134. }
  135. }
  136. },
  137. getCode() {
  138. if(this.ruleForm.regPhone == "") {
  139. this.$toast({
  140. message: '请输入手机号',
  141. duration: 2000
  142. });
  143. return false;
  144. } else if(!(/^1[23456789]\d{9}$/.test(this.ruleForm.regPhone))){
  145. this.$toast({
  146. message: '手机号码有误,请重填',
  147. duration: 2000
  148. });
  149. return false;
  150. }
  151. if(this.code == "获取验证码") {
  152. var auth_timer = setInterval(()=>{
  153. if(this.code == "获取验证码") {
  154. this.code = 60;
  155. }
  156. this.code--;
  157. if(this.code <= 0){
  158. this.code = "获取验证码"
  159. clearInterval(auth_timer)
  160. }
  161. },1000)
  162. }
  163. },
  164. handleRegistered() {
  165. if(this.ruleForm.regName == "") {
  166. this.$toast({
  167. message: '请输入姓名',
  168. duration: 2000
  169. });
  170. return false;
  171. } else if(this.ruleForm.regPhone == "") {
  172. this.$toast({
  173. message: '请输入手机号',
  174. duration: 2000
  175. });
  176. return false;
  177. } else if(this.ruleForm.regAccount == "") {
  178. this.$toast({
  179. message: '请输入验证码',
  180. duration: 2000
  181. });
  182. return false;
  183. } else if(this.ruleForm.regPassWord == "") {
  184. this.$toast({
  185. message: '请输入密码',
  186. duration: 2000
  187. });
  188. return false;
  189. } else if(this.ruleForm.regPassWord1 == "") {
  190. this.$toast({
  191. message: '请确认密码',
  192. duration: 2000
  193. });
  194. return false;
  195. } else if(this.ruleForm.regPassWord != this.ruleForm.regPassWord1) {
  196. this.$toast({
  197. message: '请输入相同密码',
  198. duration: 2000
  199. });
  200. return false;
  201. } else {
  202. this.$indicator.open();
  203. this.http.post(this.port.manage.regist, {
  204. "name": this.ruleForm.regName,
  205. "code": this.ruleForm.regAccount,
  206. "phone": this.ruleForm.regPhone,
  207. "password": this.ruleForm.regPassWord,
  208. } , res => {
  209. this.$indicator.close();
  210. this.ruleForm = {
  211. loginName: '',
  212. password: '',
  213. regName: '',
  214. regPhone: '',
  215. regAccount: '',
  216. regPassWord: '',
  217. regPassWord1: '',
  218. }
  219. if (res.code == "ok") {
  220. this.$toast({
  221. message: "提交注册成功,等待管理员审核账号",
  222. duration: 2000
  223. });
  224. } else {
  225. this.$toast({
  226. message: res.msg,
  227. duration: 2000
  228. });
  229. }
  230. }, error => {
  231. this.$indicator.close();
  232. this.ruleForm = {
  233. loginName: '',
  234. password: '',
  235. regName: '',
  236. regPhone: '',
  237. regAccount: '',
  238. regPassWord: '',
  239. regPassWord1: '',
  240. }
  241. this.$toast({
  242. message: error,
  243. duration: 2000
  244. });
  245. })
  246. }
  247. }
  248. },
  249. }
  250. </script>
  251. <style lang="scss" scoped>
  252. .login_par {
  253. position: relative;
  254. }
  255. .login_logo {
  256. text-align: center;
  257. margin: 0 0 20px 0;
  258. }
  259. .login_head {
  260. padding: 0.48rem 0;
  261. }
  262. .login_head , .mint-navbar {
  263. background: #2680EB;
  264. }
  265. .login_tab {
  266. height: 0.20rem;
  267. line-height: 0.20rem;
  268. font-size: 0.15rem!important;
  269. color: #fff;
  270. }
  271. .login_box {
  272. width: 80%;
  273. margin: 0 auto;
  274. padding: 0.45rem 0;
  275. position: relative;
  276. top: -0.45rem;
  277. background: #fff;
  278. border-radius: 20px 20px 0 0;
  279. }
  280. .login_box .mint-cell {
  281. margin: 0 0.18rem 0.1rem;
  282. border-bottom: 1px solid #D7D7D7;
  283. }
  284. .mint-button--large {
  285. width: 90%;
  286. margin:0.4rem auto 0;
  287. }
  288. .out_input {
  289. position: relative;
  290. }
  291. .out_input img {
  292. width: 0.14rem;
  293. height: 0.15rem;
  294. position: absolute;
  295. left: 0.2rem;
  296. top: 0.09rem;
  297. }
  298. .out_input img.phone {
  299. width: 0.12rem;
  300. }
  301. .input {
  302. background: none;
  303. outline: none;
  304. border: none;
  305. border-radius: 0;
  306. border-bottom: 1px solid #D7D7D7;
  307. display: block;
  308. width: 80%;
  309. margin: 0 auto 0.24rem;
  310. height: 0.35rem;
  311. line-height: 0.35rem;
  312. font-size: 0.14rem;
  313. padding: 0 0 0 0.2rem;
  314. }
  315. .text {
  316. color: #2680EB;
  317. position: absolute;
  318. right: 0.2rem;
  319. top: 0.06rem;
  320. }
  321. </style>
  322. <style>
  323. /* 插件样式修改 */
  324. .login_par .mint-navbar .mint-tab-item.is-selected .login_tab {
  325. font-size: 0.19rem!important;
  326. }
  327. .login_par .mint-navbar .mint-tab-item.is-selected {
  328. border-bottom: none!important;
  329. font-size: 0.22rem!important;
  330. font-weight: 800;
  331. }
  332. .login_box .mint-cell-value {
  333. border: 0!important;
  334. }
  335. .login_par .mint-cell-wrapper {
  336. background-image: none!important;
  337. }
  338. .login_par .mint-button--primary {
  339. background-color: #2680EB!important;
  340. }
  341. </style>