瀏覽代碼

登录返回手机号

fuwencai 4 年之前
父節點
當前提交
c491e0040f

+ 1 - 1
src/github.com/baiy/Cadmin-server-go/system/index/index.go

@@ -99,7 +99,7 @@ func Login(context *admin.Context) (interface{}, error) {
 	if param.LoginType == "2" { //点击发送手机验证码
 	if param.LoginType == "2" { //点击发送手机验证码
 		if u.Phone != "" {
 		if u.Phone != "" {
 			if SendPhoneIdentCode(context, u.Phone) {
 			if SendPhoneIdentCode(context, u.Phone) {
-				return map[string]interface{}{"status": 3}, nil
+				return map[string]interface{}{"status": 3,"phone":u.Phone}, nil
 			} else {
 			} else {
 				return nil, errors.New("手机验证码发送失败")
 				return nil, errors.New("手机验证码发送失败")
 			}
 			}

+ 9 - 9
src/github.com/baiy/Cadmin-server-go/system/user/user.go

@@ -82,16 +82,16 @@ func Save(context *admin.Context) (interface{}, error) {
 	if param.Password != "" {
 	if param.Password != "" {
 		password = string(admin.Passworder.Hash([]byte(param.Password)))
 		password = string(admin.Passworder.Hash([]byte(param.Password)))
 	}
 	}
-	phoneExist, _ := thisModel.GetByPhone(param.Phone)
-	if phoneExist.Id > 0 {
-		if phoneExist.Id != param.Id {
-			return nil, errors.New("手机号已绑定其他账号")
-		} else {
-			return nil, errors.New("手机号与原手机号一致")
-		}
-	}
-	if param.LoginType == "2" { //点击发送手机验证码
 
 
+	if param.LoginType == "2" { //点击发送手机验证码
+		phoneExist, _ := thisModel.GetByPhone(param.Phone)
+		if phoneExist.Id > 0 {
+			if phoneExist.Id != param.Id {
+				return nil, errors.New("手机号已绑定其他账号")
+			} else {
+				return nil, errors.New("手机号与原手机号一致")
+			}
+		}
 		if SendPhoneIdentCode(context, param.Phone) {
 		if SendPhoneIdentCode(context, param.Phone) {
 			return map[string]interface{}{"status": 3}, nil
 			return map[string]interface{}{"status": 3}, nil
 		} else {
 		} else {