api.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package frontc
  2. import(
  3. "encoding/json"
  4. "wuyebaoxiuapi/libs"
  5. "fmt"
  6. )
  7. type ApiController struct {
  8. BBaseController
  9. }
  10. // 模拟登录
  11. func (this *ApiController)Login() {
  12. http :=libs.NewHttp()
  13. params := make(map[string]interface{})
  14. userInfo := make(map[string]interface{})
  15. userInfo["nickName"] = "pengjs"
  16. userInfo["avatarUrl"] = "1.jpg"
  17. userInfo["gender"] = 1
  18. userInfo["school"] = "xxx"
  19. params["is_repair_user"] = 2
  20. params["username"] = "admin"
  21. params["password"] = "123456"
  22. params["types"] = 2
  23. params["is_wechat_login"] = 0
  24. params["openid"] = "o6iCm1FeosWAhRS88jOXmrXCUbUI"
  25. params["username"] = "admin"
  26. params["password"] = "123456"
  27. jsonStr,_ := json.Marshal(userInfo)
  28. params["userInfo"] = string(jsonStr)
  29. fmt.Println("b:", string(jsonStr))
  30. fmt.Println("c:", params["userInfo"])
  31. result := http.Post("http://localhost:8081/user/login",params)
  32. mapJson := libs.JsonToMap(result)
  33. this.ajaxMsg(1,mapJson["message"],mapJson["data"])
  34. }
  35. // 修改密码
  36. func (this *ApiController)UpdatePassword() {
  37. http :=libs.NewHttp()
  38. params := make(map[string]interface{})
  39. params["old_password"] = "123456"
  40. params["new_password"] = "111111"
  41. params["confirm_password"] = "o6iCm1FeosWAhRS88jOXmrXCUbUI"
  42. result := http.Post("http://localhost:8081/user/UpdatePassword",params)
  43. mapJson := libs.JsonToMap(result)
  44. this.ajaxMsg(1,mapJson["message"],mapJson["data"])
  45. }