智慧食堂
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 rivejä
2.6 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. svc3 "applet/app/svc"
  9. "context"
  10. "github.com/chromedp/chromedp"
  11. "github.com/chromedp/chromedp/device"
  12. "github.com/gin-gonic/gin"
  13. "github.com/wechatpay-apiv3/wechatpay-go/services/certificates"
  14. "io/ioutil"
  15. )
  16. func CurlAlipayPlanetEcocampusApiRosterSignUpInfo(c *gin.Context) {
  17. var req md.CurlAlipayPlanetEcocampusApiRosterSignUpInfoReq
  18. err := c.ShouldBindJSON(&req)
  19. if err != nil {
  20. err = validate.HandleValidateErr(err)
  21. err1 := err.(e.E)
  22. e.OutErr(c, err1.Code, err1.Error())
  23. return
  24. }
  25. err, resp := svc.CurlAlipayPlanetEcocampusApiRosterSignUpInfo(req)
  26. if err != nil {
  27. e.OutErr(c, e.ERR, err.Error())
  28. return
  29. }
  30. e.OutSuc(c, resp, nil)
  31. return
  32. }
  33. func DownloadCertificates(c *gin.Context) {
  34. client, err := svc3.NewWxPayClient(c)
  35. if err != nil {
  36. e.OutErr(c, e.ERR, err.Error())
  37. return
  38. }
  39. // 发送请求,以下载微信支付平台证书为例
  40. apiSvc := certificates.CertificatesApiService{Client: client}
  41. resp, result, err := apiSvc.DownloadCertificates(c)
  42. if err != nil {
  43. e.OutErr(c, e.ERR, err.Error())
  44. return
  45. }
  46. println("status=%d resp=%s", result.Response.StatusCode, resp)
  47. e.OutSuc(c, map[string]interface{}{
  48. "resp": resp,
  49. }, nil)
  50. return
  51. }
  52. func Demo(c *gin.Context) {
  53. ordNo := c.DefaultQuery("ord_no", "")
  54. svc2.JudgePackageOrdOrdState(ordNo)
  55. e.OutSuc(c, nil, nil)
  56. return
  57. }
  58. func SanHu(c *gin.Context) { //实现网页截图
  59. url := c.DefaultQuery("url", "")
  60. if url == "" {
  61. e.OutErr(c, e.ERR_NO_DATA, "网址不能为空")
  62. return
  63. }
  64. ctx, cancel := chromedp.NewContext(context.Background())
  65. defer cancel()
  66. var b1, b2 []byte
  67. if err := chromedp.Run(ctx,
  68. // emulate iPhone 7 landscape
  69. chromedp.Emulate(device.IPhone8Plus),
  70. chromedp.Navigate(url),
  71. chromedp.CaptureScreenshot(&b1),
  72. // reset
  73. chromedp.Emulate(device.Reset),
  74. // set really large viewport
  75. chromedp.EmulateViewport(1920, 2000),
  76. chromedp.Navigate(url),
  77. chromedp.CaptureScreenshot(&b2),
  78. ); err != nil {
  79. e.OutErr(c, e.ERR, err.Error())
  80. return
  81. }
  82. if err := ioutil.WriteFile("./static/template/sanHu/IPhone8Plus.png", b1, 0777); err != nil {
  83. e.OutErr(c, e.ERR, err.Error())
  84. return
  85. }
  86. if err := ioutil.WriteFile("./static/template/sanHu/Pc.png", b2, 0777); err != nil {
  87. e.OutErr(c, e.ERR, err.Error())
  88. return
  89. }
  90. e.OutSuc(c, map[string]interface{}{
  91. "iphone8_plus": "https://zs.zehaochi.net/template/sanHu/IPhone8Plus.png",
  92. "Pc": "https://zs.zehaochi.net/template/sanHu/Pc.png",
  93. }, nil)
  94. return
  95. }