|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- package hdl
-
- import (
- "applet/app/admin/lib/validate"
- svc2 "applet/app/admin/svc/enterprise_manage"
- "applet/app/customer/md"
- "applet/app/customer/svc"
- "applet/app/e"
- svc3 "applet/app/svc"
- "context"
- "github.com/chromedp/chromedp"
- "github.com/chromedp/chromedp/device"
- "github.com/gin-gonic/gin"
- "github.com/wechatpay-apiv3/wechatpay-go/services/certificates"
- "io/ioutil"
- )
-
- func CurlAlipayPlanetEcocampusApiRosterSignUpInfo(c *gin.Context) {
- var req md.CurlAlipayPlanetEcocampusApiRosterSignUpInfoReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
- err, resp := svc.CurlAlipayPlanetEcocampusApiRosterSignUpInfo(req)
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- e.OutSuc(c, resp, nil)
- return
- }
-
- func DownloadCertificates(c *gin.Context) {
- client, err := svc3.NewWxPayClient(c)
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- // 发送请求,以下载微信支付平台证书为例
- apiSvc := certificates.CertificatesApiService{Client: client}
- resp, result, err := apiSvc.DownloadCertificates(c)
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
-
- println("status=%d resp=%s", result.Response.StatusCode, resp)
- e.OutSuc(c, map[string]interface{}{
- "resp": resp,
- }, nil)
- return
- }
-
- func Demo(c *gin.Context) {
- ordNo := c.DefaultQuery("ord_no", "")
- svc2.JudgePackageOrdOrdState(ordNo)
- e.OutSuc(c, nil, nil)
- return
- }
-
- func SanHu(c *gin.Context) { //实现网页截图
- url := c.DefaultQuery("url", "")
- if url == "" {
- e.OutErr(c, e.ERR_NO_DATA, "网址不能为空")
- return
- }
- ctx, cancel := chromedp.NewContext(context.Background())
- defer cancel()
- var b1, b2 []byte
- if err := chromedp.Run(ctx,
- // emulate iPhone 7 landscape
- chromedp.Emulate(device.IPhone8Plus),
- chromedp.Navigate(url),
- chromedp.CaptureScreenshot(&b1),
-
- // reset
- chromedp.Emulate(device.Reset),
-
- // set really large viewport
- chromedp.EmulateViewport(1920, 2000),
- chromedp.Navigate(url),
- chromedp.CaptureScreenshot(&b2),
- ); err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
-
- if err := ioutil.WriteFile("./static/template/sanHu/IPhone8Plus.png", b1, 0777); err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- if err := ioutil.WriteFile("./static/template/sanHu/Pc.png", b2, 0777); err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- e.OutSuc(c, map[string]interface{}{
- "iphone8_plus": "https://zs.zehaochi.net/template/sanHu/IPhone8Plus.png",
- "Pc": "https://zs.zehaochi.net/template/sanHu/Pc.png",
- }, nil)
- return
- }
|