From 115997d1d8067b1b4b4f35e303564878a3f3c938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=C2=B7=C3=A6?= <279202647@qq.com> Date: Wed, 21 Apr 2021 21:24:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8D=95sku=E5=AE=9D?= =?UTF-8?q?=E8=B4=9D=E6=B7=BB=E5=8A=A0=E4=B8=8D=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JdShopListener/MainWindowViewModel.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/JdShopListener/JdShopListener/MainWindowViewModel.cs b/JdShopListener/JdShopListener/MainWindowViewModel.cs index ca598e5..656c75a 100644 --- a/JdShopListener/JdShopListener/MainWindowViewModel.cs +++ b/JdShopListener/JdShopListener/MainWindowViewModel.cs @@ -10,6 +10,7 @@ using JdShopListener.SqlHelpers; using System.Windows; using System.Linq; using System.Threading; +using Newtonsoft.Json.Linq; namespace JdShopListener { @@ -26,8 +27,6 @@ namespace JdShopListener } - - public MainWindowViewModel() { ProList = new System.Collections.ObjectModel.ObservableCollection() { new ProModel(){ Name="价格" , Type= ProType.Price}, @@ -227,25 +226,27 @@ namespace JdShopListener { var detail = GetItemDetail(Sku); - var list = detail.product.colorSize; + JArray list = detail.product.colorSize as JArray; //spuId string spuId = detail.product.mainSkuId; - //if (list.Count == 0 || list.Count == null) - //{ - // list.Add(new { skuId = Sku }); - //} + if (list==null||list.Count == 0) + { + list = new JArray(); + list.Add(JToken.FromObject(new { skuId=Sku })); + } List skus = new List(); - foreach (var sku in list) + + foreach (JObject sku in list) { SkuModel model = new SkuModel() { Desc = Desc, - SkuId = sku.skuId, + SkuId = sku["skuId"].ToString(), SpuId = spuId };