移动端
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

346 satır
9.9 KiB

  1. <template>
  2. <div class="app-container" style="overflow:auto;">
  3. <div style="width:100%;max-width:500px;margin:0 auto;">
  4. <div class="title">
  5. <img width="150" height="150" style="display: block;margin-right: 10px;margin: 20px auto;" src="../assets/images/housesteadSurvey/logo.png" alt="">
  6. <p style="text-align:center;font-size:40px;">农村宅基地调查</p>
  7. </div>
  8. <van-form>
  9. <div style="width: 90%;
  10. max-widht:462px;
  11. border-radius: 45px;
  12. box-shadow: 2px 10px 10px 0px rgba(125,125,125,0.16);padding: 10px 30px; margin:40px 20px; ">
  13. <van-field
  14. v-model="formData.username"
  15. placeholder="请输入账号"
  16. left-icon="manager"
  17. color="#bfbfbf"
  18. input-align="center"
  19. :rules="[{ required: true, message:'' }]"
  20. />
  21. </div>
  22. <div style="width: 90%;
  23. max-widht:462px;
  24. border-radius: 45px;
  25. box-shadow: 2px 10px 10px 0px rgba(125,125,125,0.16);padding: 10px 30px; margin:40px 20px; ">
  26. <van-field
  27. v-model="formData.password"
  28. type="password"
  29. placeholder="请输入密码"
  30. left-icon="lock"
  31. color="#bfbfbf"
  32. input-align="center"
  33. :rules="[{ required: true, message:'' }]"
  34. />
  35. </div>
  36. <div style="width: 90%;
  37. max-widht:462px;
  38. border-radius: 45px;
  39. box-shadow: 2px 10px 10px 0px rgba(125,125,125,0.16);padding: 10px 30px; margin:40px 20px; " class="codeDiv">
  40. <van-field
  41. v-model="formData.code"
  42. center
  43. clearable
  44. input-align="center"
  45. placeholder="图形验证码"
  46. >
  47. <template #label>
  48. <img style="width: 90px" :src="codeUrl" @click="getCode" />
  49. </template>
  50. </van-field>
  51. </div>
  52. <div style="margin: 10px 5px 5px;padding:10px">
  53. <van-button block round size="large" :color="formData.username!=''&&formData.password!=''?'#7AC943':'#e2e2e2'" :disabled="formData.username==''||formData.password==''" native-type="submit" @click="handleLogin">登录</van-button>
  54. </div>
  55. </van-form>
  56. </div>
  57. <van-popup v-model="showKeyboard" :style="{ height: '100%',width:'100%' }" >
  58. <van-nav-bar
  59. left-arrow
  60. fixed
  61. placeholder
  62. @click-left="showPopup"
  63. />
  64. <div style="padding: 20px">
  65. <h1>输入短信验证码</h1>
  66. <h3 style="color: #878787">验证码已发送至{{(formData.mobile+"").substr(0,3) + "****" + (formData.mobile+"").substr(7)}},请在下方输入框内输入4位数字验证码</h3>
  67. </div>
  68. <van-password-input
  69. :value="smsCodeValue"
  70. :length="4"
  71. :focused="showKeyboard"
  72. @focus="showKeyboard = true"
  73. />
  74. <van-number-keyboard
  75. v-model="smsCodeValue"
  76. :show="showKeyboard"
  77. theme="custom"
  78. close-button-text="完成"
  79. />
  80. </van-popup>
  81. </div>
  82. </template>
  83. <style scoped>
  84. .app-container{
  85. background: #fff;
  86. height: 100vh;
  87. }
  88. .title{
  89. padding-top: 20%;
  90. width: 88%;
  91. margin: 0 auto;
  92. }
  93. .van-tab--active{
  94. font-size: .6rem;
  95. font-weight: bold;
  96. }
  97. .van-tabs__line{
  98. background:#1D6FE9;
  99. width: 0.15rem;
  100. height: 0.15rem;
  101. border-radius: 0.07rem;
  102. bottom: 0.3rem;
  103. }
  104. .van-tabs__nav{
  105. padding:0
  106. }
  107. .van-tab{
  108. display: inline-block;
  109. flex: inherit;
  110. margin-left: 30px;
  111. line-height: .8rem;
  112. }
  113. .van-tab__text--ellipsis {
  114. overflow: auto;
  115. }
  116. .van-password-input{
  117. width: 50%;
  118. margin: 0 auto;
  119. }
  120. [class*=van-hairline]::after{
  121. border:none;
  122. }
  123. .van-password-input__security li{
  124. margin: 0 10px;
  125. border-bottom: 3px solid black;
  126. }
  127. .registerSmsBtn{
  128. color: rgb(29, 111, 233);
  129. font-size: 0.34rem;
  130. }
  131. </style>
  132. <script>
  133. import { getCodeImg, getSmsCode ,getRegisterSmsCode,registerCheck,registerOn} from "../api/login";
  134. import Cookies from "js-cookie";
  135. import { encrypt, decrypt } from "../utils/jsencrypt";
  136. //引用wx sdk
  137. import wx from "weixin-js-sdk";
  138. export default {
  139. name: "homesteadLogin",
  140. data() {
  141. return {
  142. showMessage:false,
  143. smsCodeValue:"",
  144. showKeyboard:false,
  145. formData: {
  146. username: "", //账号
  147. password: "", //密码
  148. code: null, //图片验证码
  149. uuid: null, //识别uuid
  150. mobile: null, //手机号
  151. smsCode: null, //短信验证码
  152. memberName:null, //身份信息
  153. idcard:null, //身份号码
  154. rememberMe:false
  155. },
  156. loading: false,
  157. codeUrl: "", //验证码
  158. isSmsLogin: false, //是否手机验证码
  159. computeTime: 0,
  160. active:1
  161. };
  162. },
  163. created() {
  164. this.getCode();
  165. this.getCookie();
  166. this.reset();
  167. },
  168. methods: {
  169. reset(){
  170. },
  171. showPopup(){
  172. this.showKeyboard = !this.showKeyboard
  173. },
  174. showMessagePop(){
  175. this.showMessage = !this.showMessage
  176. },
  177. getCode() {
  178. getCodeImg().then((res) => {
  179. this.formData.uuid = res.uuid;
  180. this.codeUrl = "data:image/gif;base64," + res.img;
  181. });
  182. },
  183. getCookie() {
  184. const username = Cookies.get("username");
  185. const password = Cookies.get("password");
  186. const rememberMe = Cookies.get("rememberMe");
  187. this.formData = {
  188. username: username === undefined ? this.formData.username : username,
  189. password:
  190. password === undefined ? this.formData.password : decrypt(password),
  191. rememberMe: rememberMe === undefined ? false : Boolean(rememberMe),
  192. };
  193. },
  194. getSmsCode() {
  195. if (this.formData.code == "") {
  196. this.$dialog.alert({
  197. message: '图片验证码不能为空',
  198. });
  199. return false;
  200. }
  201. if (!this.computeTime) {
  202. let myreg = /^[1][3,4,5,7,8,9][0-9]{9}$/;
  203. if (!myreg.test(this.formData.mobile)) {
  204. this.$dialog.alert({
  205. message: '手机号格式不正确',
  206. });
  207. return false;
  208. }
  209. /* getSmsCode(this.formData.mobile).then((res) => {
  210. if (res.code === 200) {
  211. this.$dialog.alert({
  212. message: '验证码已发送',
  213. });
  214. this.showKeyboard = !this.showKeyboard;
  215. this.loginForm.uuid = res.uuid;
  216. this.computeTime = 60;
  217. this.timer = setInterval(() => {
  218. this.computeTime--;
  219. if (this.computeTime <= 0) {
  220. clearInterval(this.timer);
  221. }
  222. }, 1000);
  223. }
  224. });*/
  225. }
  226. },
  227. handleLogin(values) {
  228. //账号密码登录
  229. if (this.formData.username == "") {
  230. this.$dialog.alert({
  231. message: '账号不能为空',
  232. });
  233. return false;
  234. } else if (this.formData.password == "") {
  235. this.$dialog.alert({
  236. message: '密码不能为空',
  237. });
  238. return false;
  239. }
  240. this.$store
  241. .dispatch("Login", this.formData)
  242. .then(() => {
  243. this.$router.push({ path: "/homesteadSurvey/index" }).catch(() => {});
  244. })
  245. .catch((error) => {
  246. this.loading = false;
  247. this.getCode();
  248. });
  249. },
  250. getRegisterSmsCode(){
  251. if (!this.computeTime) {
  252. let myreg = /^[1][3,4,5,7,8,9][0-9]{9}$/;
  253. if (!myreg.test(this.formData.mobile)) {
  254. this.$dialog.alert({
  255. message: '手机号格式不正确',
  256. });
  257. return false;
  258. }else if (this.formData.code == "") {
  259. this.$dialog.alert({
  260. message: '图片验证码不能为空',
  261. });
  262. return false;
  263. }
  264. if (this.active==2) {
  265. let formObj = {
  266. code :this.formData.code,
  267. mobile:this.formData.mobile,
  268. uuid:this.formData.uuid
  269. }
  270. getRegisterSmsCode(formObj).then((res) => {
  271. console.log(res)
  272. console.log(res.code == 200)
  273. if(res.code == 200) {
  274. this.$dialog.alert({
  275. message: '验证码已发送',
  276. });
  277. this.formData.uuid = res.uuid;
  278. this.computeTime = 60;
  279. this.timer = setInterval(() => {
  280. this.computeTime--;
  281. if (this.computeTime <= 0) {
  282. clearInterval(this.timer);
  283. }
  284. }, 1000);
  285. }
  286. }).catch((res)=>{
  287. if(res=='Error: 验证码已失效'){
  288. this.getCode()
  289. }
  290. });
  291. }
  292. }
  293. },
  294. registerSubmit(){
  295. //注册
  296. if (this.formData.memberName == "") {
  297. this.$dialog.alert({
  298. message: '姓名不能为空',
  299. });
  300. return false;
  301. } else if (this.formData.idcard == "") {
  302. this.$dialog.alert({
  303. message: '身份证号不能为空',
  304. });
  305. return false;
  306. } else if (this.formData.mobile == "") {
  307. this.$dialog.alert({
  308. message: '手机号码不能为空',
  309. });
  310. return false;
  311. }else if (this.formData.smsCode == "") {
  312. this.$dialog.alert({
  313. message: '短信验证码不能为空',
  314. });
  315. return false;
  316. }
  317. //registerCheck,registerOn
  318. console.log(this.formData)
  319. registerCheck(this.formData).then((res)=>{
  320. if(res.code == 200){
  321. registerOn(this.formData).then((res)=>{
  322. if(res.code == 200){
  323. //
  324. this.$dialog.alert({
  325. message: '您的初始密码:'+res.password,
  326. }).then(() => {
  327. this.$router.push({ path: "/homesteadSurvey/index" }).catch(() => {});
  328. });
  329. }
  330. })
  331. }
  332. })
  333. }
  334. },
  335. };
  336. </script>
  337. <style scoped lang="scss">
  338. /deep/ .codeDiv .van-field .van-cell__title{
  339. width: 3.0em!important;
  340. }
  341. </style>