From 16c2784ace2e37fb6b2c3cd244c8d20cf739f56f Mon Sep 17 00:00:00 2001 From: cdle <798731886@qq.com> Date: Wed, 18 Aug 2021 16:10:36 +0800 Subject: [PATCH] x --- models/asset.go | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/models/asset.go b/models/asset.go index 5d0c16e..7d855b5 100644 --- a/models/asset.go +++ b/models/asset.go @@ -9,7 +9,6 @@ import ( "time" "github.com/beego/beego/v2/client/httplib" - "github.com/buger/jsonparser" ) type Asset struct { @@ -517,6 +516,38 @@ func initPetTown(cookie string, state chan string) { } func jsGold(cookie string, state chan int64) { // + + type BalanceVO struct { + CashBalance string `json:"cashBalance"` + EstimatedAmount string `json:"estimatedAmount"` + ExchangeGold string `json:"exchangeGold"` + FormatGoldBalance string `json:"formatGoldBalance"` + GoldBalance int `json:"goldBalance"` + } + type Gears struct { + Amount string `json:"amount"` + ExchangeAmount string `json:"exchangeAmount"` + Order int `json:"order"` + Status int `json:"status"` + Type int `json:"type"` + } + type Data struct { + Advertise string `json:"advertise"` + BalanceVO BalanceVO `json:"balanceVO"` + Gears []Gears `json:"gears"` + IsGetCoupon bool `json:"isGetCoupon"` + IsGetCouponEid bool `json:"isGetCouponEid"` + IsLogin bool `json:"isLogin"` + NewPeople bool `json:"newPeople"` + } + type AutoGenerated struct { + Code int `json:"code"` + Data Data `json:"data"` + IsSuccess bool `json:"isSuccess"` + Message string `json:"message"` + RequestID string `json:"requestId"` + } + a := AutoGenerated{} req := httplib.Post(`https://api.m.jd.com??functionId=MyAssetsService.execute&appid=market-task-h5`) req.Header("Accept", "application/json, text/plain, */*") req.Header("Accept-Encoding", "gzip, deflate, br") @@ -529,6 +560,6 @@ func jsGold(cookie string, state chan int64) { // req.Header("Referer", "https://gold.jd.com/") req.Body(`functionId=MyAssetsService.execute&body={"method":"goldShopPage","data":{"channel":1}}&_t=` + fmt.Sprint(time.Now().Unix()) + `&appid=market-task-h5;`) data, _ := req.Bytes() - gold, _ := jsonparser.GetInt(data, "data.balanceVO.goldBalance") - state <- gold + json.Unmarshal(data, &a) + state <- int64(a.Data.BalanceVO.GoldBalance) }