fuwencai il y a 4 ans
Parent
commit
62a8f683a9
2 fichiers modifiés avec 9 ajouts et 3 suppressions
  1. 7 2
      src/front/front.go
  2. 2 1
      src/web/templates/login.html

+ 7 - 2
src/front/front.go

@@ -84,6 +84,11 @@ func (f *Front) Login() {
 		// 2. 验证短信验证码
 		session, err := store.Get(f.Request, "dataTagLoginPhoneCode")
 		if err != nil {
+			f.ServeJson(map[string]interface{}{
+				"code":    0,
+				"status":  false,
+				"message": "验证码比对失败",
+			})
 			log.Println("phone-session2获取失败")
 			return
 		}
@@ -447,9 +452,9 @@ func SendPhoneCode(f *Front, phone string) {
 		log.Println("session1保存错误,验证码")
 	}
 	//发送短信
-	//param := map[string]string{"code": s_ranNum}
+	param := map[string]string{"code": s_ranNum}
 	log.Println("短信验证码", phone, s_ranNum)
-	//SendSMS("2828060", phone, param)
+	SendSMS("2828060", phone, param)
 }
 
 //第三个参数是可变参数,可以传入多个,但要和模板相匹配

+ 2 - 1
src/web/templates/login.html

@@ -108,7 +108,6 @@
                             if (r.code === 0) {
                                 if (r.status !== true) {
                                     $("#verifyImg")[0].src = '/code?' + Math.random()
-
                                     alert(r.message)
                                 } else {
                                     addCookie("SecondNum", 60, 60);
@@ -116,6 +115,7 @@
                                     alert("发送成功")
                                 }
                             } else {
+                                $("#verifyImg")[0].src = '/code?' + Math.random()
                                 alert("无响应")
                             }
                         }
@@ -164,6 +164,7 @@
     function checkPhone() {
         var phone = document.getElementById('phone').value;
         if (!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(phone))) {
+            $("#verifyImg")[0].src = '/code?' + Math.random()
             alert("手机号码有误,请重填");
             return false;
         } else return true