This commit is contained in:
cdle 2021-08-18 16:10:36 +08:00
parent 6fa17cfa02
commit 16c2784ace

View File

@ -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)
}