let obj = { "error": "", "extra": { "batchFlagUrl": "//trade.taobao.com/trade/memo/update_sell_memo.htm", "batchFreePostUrl": "//trade.taobao.com/trade/freePostFee.htm", "batchSendGoods": true, "batchSendGoodsUrl": "//trade.taobao.com/trade/wuliuListScreen.htm", "durexReturnURI": "//trade.taobao.com/trade/itemlist/mid/durex.htm", "durexURI": "//aq.taobao.com/durex/validate", "needAuth": true, "queryTitleMaxSize": 15 }, "mainOrders": [{ "buyer": { "guestUser": false, "id": 894139664, "memberUrl": "//member1.taobao.com/member/userProfile.jhtml?userID=tzyyih&sign=dd56f659be8cf855712deb618f5b8352", "nick": "tzyyih", "operations": [{ "action": "a14", "imgUrl": "//gtd.alicdn.com/tps/i8/T1KNtuXc4rXXXXXXXX-12-12.png", "style": "t0", "title": "查询该买家订单", "type": "operation", "url": "/trade/itemlist/list_sold_items.htm?action=itemlist/SoldQueryAction&event_submit_do_query=1" }], "phoneNum": "156********" }, "extra": { "batchSendGoods": 1, "currency": "CNY", "currencySymbol": "¥", "disableCheckbox": false, "inHold": false, "isShowSellerService": false, "sellerFlag": 1 }, "id": "593609380706136496", "operations": [{ "action": "a2", "dataUrl": "/trade/json/memoInfo.htm?user_type=seller&_input_charset=utf-8&orderid=593609380706136496", "id": "flag", "style": "thead", "text": "编辑标记信息,仅自己可见", "type": "operation", "url": "/trade/memo/update_sell_memo.htm?seller_id=273202702&biz_order_id=593609380706136496&user_type=1&pageNum=1&auctionTitle=null&dateBegin=0&dateEnd=0&commentStatus=&buyerNick=&auctionStatus=SUCCESS&logisticsService=" }, { "style": "t16", "text": "我已评价", "type": "operation", "url": "//rate.taobao.com/RateDetailSeller.htm?parentTradeId=593609380706136496" }], "orderInfo": { "createTime": "2020-05-22 23:17:08", "id": "593609380706136496" }, "payInfo": { "actualFee": "199.50", "icons": [{ "linkTitle": "该订单来自您的手机淘宝店铺", "linkUrl": "http://www.taobao.com/go/act/integrated/maijia-index.php?sprefer=symj27", "type": 3, "url": "//img.alicdn.com/tps/i1/T1xRBqXdNAXXXXXXXX-46-16.png" }], "operations": [{ "style": "t16", "text": "查看物流", "type": "operation", "url": "//wuliu.taobao.com/user/order_detail_new.htm?trade_id=593609380706136496&seller_id=273202702" }], "postType": "(含快递:¥0.00)" }, "statusInfo": { "operations": [{ "style": "t16", "text": "详情", "type": "operation", "url": "//trade.taobao.com/trade/detail/trade_item_detail.htm?bizOrderId=593609380706136496" }], "text": "交易成功", "type": "t0" }, "subOrders": [{ "itemInfo": { "itemUrl": "//trade.taobao.com/trade/detail/tradeSnap.htm?tradeID=593609380706136496&snapShot=true", "pic": "//img.alicdn.com/imgextra/i1/273202702/O1CN01Hm6Pvh1VpYiknVbK2_!!273202702.jpg_sum.jpg", "serviceIcons": [{ "linkTitle": "消费者保障服务,卖家承诺7天无理由退换货", "linkUrl": "http://www.taobao.com/go/act/315/xbqt090304.php?ad_id=&am_id=130011831021c2f3caab&cm_id=&pm_id=", "type": 3, "url": "//img.alicdn.com/tps/i3/T1Vyl6FCBlXXaSQP_X-16-16.png" }, { "linkTitle": "消费者保障服务,卖家承诺商品如实描述", "linkUrl": "http://www.taobao.com/go/act/315/xfzbz_rsms.php?ad_id=&am_id=130011830696bce9eda3&cm_id=&pm_id=", "type": 3, "url": "//img.alicdn.com/tps/i4/T1BCidFrNlXXaSQP_X-16-16.png" }, { "linkTitle": "订单险", "linkUrl": "http://baoxian.taobao.com/xsell/orderins/sellerPolicyDetail.html?bizOrderId=593609380706136496", "type": 3, "url": "//img.alicdn.com/tps/i4/TB14MJXLVXXXXaraXXXAz6UFXXX-16-16.png" }], "skuId": 0, "skuText": [{ "name": "颜色分类", "value": "1瓶冻膜", "visible": "SOLID" }], "title": "TST庭秘密冰肌如玉修护冻膜男女免洗面膜锁水改善肌肤官方正品" }, "operations": [{ "style": "t16", "text": "退运保险", "type": "operation", "url": "//baoxian.taobao.com/thwy/detail.html?biz_trade_id=593609380706136496&biz_order_id=593609380706136496&type=yfx1" }], "priceInfo": { "realTotal": "199.50" }, "quantity": "1" }] }], "page": { "currentPage": 1, "globalCodes": [], "pageSize": 15, "queryForTitle": false, "totalNumber": 1, "totalPage": 1 }, "query": { "action": "itemlist/SoldQueryAction", "auctionType": 0, "buyerNick": "", "cartItemDOList": [], "close": 0, "dateBegin": 0, "dateEnd": 0, "extra": {}, "logisticsService": "", "orderId": "593609380706136496", "orderStatus": "SUCCESS", "pageNum": 1, "pageSize": 15, "queryMore": true, "queryOrder": "desc", "rateStatus": "", "refund": "", "rxAuditFlag": 0, "rxElectronicAllFlag": 0, "rxElectronicAuditFlag": 0, "rxHasSendFlag": 0, "rxOldFlag": 0, "rxSendFlag": 0, "rxSuccessflag": 0, "rxWaitSendflag": 0, "sellerNick": "", "tabCode": "success", "tradeTag": 0, "useCheckcode": false, "useOrderInfo": false }, "queryOption": { "aftersaleType": [{ "label": "全部", "value": "ALL" }, { "label": "买家投诉", "value": "BUYER_SUIT" }, { "label": "我已投诉", "value": "SELLER_SUIT" }, { "label": "退款中", "value": "REFUNDING" }], "bizType": [{ "label": "全部", "value": "ALL" }, { "label": "机票订单", "value": "1400" }, { "label": "数字订单", "value": "1500" }, { "label": "理财订单", "value": "3000" }, { "label": "网游订单", "value": "900" }, { "label": "酒店订单", "value": "710" }, { "label": "保险订单", "value": "1102" }, { "label": "企采订单", "value": "corpMarket" }, { "label": "送礼订单", "value": "giftMarket" }, { "label": "租赁订单", "value": "leaseMarket" }, { "label": "海外订单", "value": "oversea" }], "commonTradeType": [{ "label": "所有类型", "value": 0 }, { "label": "一口价", "value": 1 }, { "label": "拍卖", "value": 2 }], "logisticsType": [{ "label": "全部", "value": "ALL" }, { "label": "货到付款", "value": "COD" }, { "label": "卖家物流", "value": "SELLER_PAYED" }], "orderStatus": [{ "label": "全部", "value": "ALL" }, { "label": "等待买家付款", "value": "NOT_PAID" }, { "label": "买家已付款", "value": "PAID" }, { "label": "卖家已发货", "value": "SEND" }, { "label": "交易成功", "value": "SUCCESS" }, { "label": "交易关闭", "value": "DROP" }, { "label": "待付款和待发货订单", "value": "NOT_PAID_AND_NOT_SEND" }, { "label": "未完成的订单", "value": "NOT_FINISHED" }, { "label": "退款中的订单", "value": "REFUNDING" }, { "label": "定金已付", "value": "FRONT_PAID" }, { "label": "异常订单", "value": "EXCEPTIONAL" }], "preSaleTradeType": [{ "label": "全部", "value": "ALL" }, { "label": "预付款已付未确认", "value": "waitConfirm" }, { "label": "已确认未付尾款", "value": "waitPayWeikuan" }], "rateStatus": [{ "label": "全部", "value": "ALL" }, { "label": "需我评价", "value": "I_HAS_NOT_COMMENT" }, { "label": "我已评价", "value": "I_HAS_COMMENT" }, { "label": "对方已评", "value": "OTHER_HAS_COMMENT" }, { "label": "双方已评", "value": "ALL_COMMENT" }] }, "tabs": [{ "code": "latest3Months", "herf": "/trade/itemlist/list_sold_items.htm", "text": "近三个月订单" }, { "code": "waitBuyerPay", "herf": "/trade/itemlist/list_sold_items.htm?action=itemlist/SoldQueryAction&event_submit_do_query=1&auctionStatus=NOT_PAID&tabCode=waitBuyerPay", "text": "等待买家付款" }, { "code": "waitSend", "herf": "/trade/itemlist/list_sold_items.htm?action=itemlist/SoldQueryAction&event_submit_do_query=1&auctionStatus=PAID&tabCode=waitSend", "text": "等待发货" }, { "code": "haveSendGoods", "herf": "/trade/itemlist/list_sold_items.htm?action=itemlist/SoldQueryAction&event_submit_do_query=1&auctionStatus=SEND&tabCode=haveSendGoods", "text": "已发货" }, { "code": "refunding", "herf": "/trade/itemlist/list_sold_items.htm?action=itemlist/SoldQueryAction&event_submit_do_query=1&auctionStatus=REFUNDING&tabCode=refunding", "text": "退款中" }, { "code": "waitRate", "herf": "/trade/itemlist/list_sold_items.htm?action=itemlist/SoldQueryAction&event_submit_do_query=1&commentStatus=I_HAS_NOT_COMMENT&tabCode=waitRate", "text": "需要评价" }, { "code": "success", "herf": "/trade/itemlist/list_sold_items.htm?action=itemlist/SoldQueryAction&event_submit_do_query=1&auctionStatus=SUCCESS&tabCode=success", "selected": true, "text": "成功的订单" }, { "code": "closed", "herf": "/trade/itemlist/list_sold_items.htm?action=itemlist/SoldQueryAction&event_submit_do_query=1&auctionStatus=DROP&tabCode=closed", "text": "关闭的订单" }, { "code": "before3Months", "herf": "/trade/itemlist/list_sold_items.htm?action=itemlist/SoldHisQueryAction&event_submit_do_query=1&tabCode=before3Months", "text": "三个月前订单" }] }
function findresult(value, key) {
let type = Object.prototype.toString.call(value)
if (type == "[object Array]") {
let temp = ""
for (let i in value) {
temp = temp + value[i][key]
}
arr.push(temp)
} else {
arr.push(value[key])
}
}
function find(value, objname, key) {
let type = Object.prototype.toString.call(value)
if (type == "[object Object]") {
if (value.hasOwnProperty(objname)) {
findresult(value[objname], key)
} else {
//objloop(value, objname, key)
for (let i in value) {
find(value[i], objname, key)
}
}
} else if (type == "[object Array]") {
//arrloop(value, objname, key)
for (let item of value) {
find(item, objname, key)
}
} else {
//console.log(value)
return value
}
}
var arr = []
for (let i in obj.mainOrders) {
//console.log(obj.mainOrders[i].statusInfo.text)
//console.log(obj.mainOrders[i].payInfo.actualFee)
find(obj.mainOrders[i], "operations", "text")//参数1:json数据,参数2:最终value的对象名,参数3:最终值
console.log(arr)
}
let a = Object.prototype.toString.call('string'); //"[object String]"
let b = Object.prototype.toString.call(1111); //"[object Number]"
let c = Object.prototype.toString.call(true); //"[object Boolean]"
let d = Object.prototype.toString.call(null); //"[object Null]"
let e = Object.prototype.toString.call(undefined); //"[object Undefined]"
let f = Object.prototype.toString.call(Symbol('111')); //"[object Symbol]"
let g = Object.prototype.toString.call({}); //"[object Object]"
let h = Object.prototype.toString.call([]);
//console.log(a, b, c, d, e, f, g, h);
console