智慧食堂
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

82 lignes
2.0 KiB

  1. package hdl
  2. import (
  3. "applet/app/admin/lib/validate"
  4. svc2 "applet/app/admin/svc/enterprise_manage"
  5. "applet/app/customer/md"
  6. "applet/app/customer/svc"
  7. "applet/app/e"
  8. "context"
  9. "github.com/chromedp/chromedp"
  10. "github.com/chromedp/chromedp/device"
  11. "github.com/gin-gonic/gin"
  12. "io/ioutil"
  13. )
  14. func CurlAlipayPlanetEcocampusApiRosterSignUpInfo(c *gin.Context) {
  15. var req md.CurlAlipayPlanetEcocampusApiRosterSignUpInfoReq
  16. err := c.ShouldBindJSON(&req)
  17. if err != nil {
  18. err = validate.HandleValidateErr(err)
  19. err1 := err.(e.E)
  20. e.OutErr(c, err1.Code, err1.Error())
  21. return
  22. }
  23. err, resp := svc.CurlAlipayPlanetEcocampusApiRosterSignUpInfo(req)
  24. if err != nil {
  25. e.OutErr(c, e.ERR, err.Error())
  26. return
  27. }
  28. e.OutSuc(c, resp, nil)
  29. return
  30. }
  31. func Demo(c *gin.Context) {
  32. ordNo := c.DefaultQuery("ord_no", "")
  33. svc2.JudgePackageOrdOrdState(ordNo)
  34. e.OutSuc(c, nil, nil)
  35. return
  36. }
  37. func SanHu(c *gin.Context) { //实现网页截图
  38. url := c.DefaultQuery("url", "")
  39. if url == "" {
  40. e.OutErr(c, e.ERR_NO_DATA, "网址不能为空")
  41. return
  42. }
  43. ctx, cancel := chromedp.NewContext(context.Background())
  44. defer cancel()
  45. var b1, b2 []byte
  46. if err := chromedp.Run(ctx,
  47. // emulate iPhone 7 landscape
  48. chromedp.Emulate(device.IPhone8Plus),
  49. chromedp.Navigate(url),
  50. chromedp.CaptureScreenshot(&b1),
  51. // reset
  52. chromedp.Emulate(device.Reset),
  53. // set really large viewport
  54. chromedp.EmulateViewport(1920, 2000),
  55. chromedp.Navigate(url),
  56. chromedp.CaptureScreenshot(&b2),
  57. ); err != nil {
  58. e.OutErr(c, e.ERR, err.Error())
  59. return
  60. }
  61. if err := ioutil.WriteFile("./static/template/sanHu/IPhone8Plus.png", b1, 0777); err != nil {
  62. e.OutErr(c, e.ERR, err.Error())
  63. return
  64. }
  65. if err := ioutil.WriteFile("./static/template/sanHu/Pc.png", b2, 0777); err != nil {
  66. e.OutErr(c, e.ERR, err.Error())
  67. return
  68. }
  69. e.OutSuc(c, map[string]interface{}{
  70. "iphone8_plus": "https://zs.zehaochi.net/template/sanHu/IPhone8Plus.png",
  71. "Pc": "https://zs.zehaochi.net/template/sanHu/Pc.png",
  72. }, nil)
  73. return
  74. }