首页 新闻 会员 周边 捐助

这个类干了什么?

0
悬赏园豆:10 [已解决问题] 解决于 2017-03-30 11:59

 要在这个类中加公共的方法怎么加,要调用里面的公共方法怎么调用

兔兔涂涂凸的主页 兔兔涂涂凸 | 初学一级 | 园豆:13
提问于:2017-03-29 17:09
< >
分享
最佳答案
1

啥也没干`

收获园豆:10
吴瑞祥 | 高人七级 |园豆:29449 | 2017-03-29 17:46

我要在这里面加一个公共的js方法怎么加,谢谢

兔兔涂涂凸 | 园豆:13 (初学一级) | 2017-03-29 17:47

@兔兔涂涂凸: 你这不是已经加了吗.

吴瑞祥 | 园豆:29449 (高人七级) | 2017-03-29 17:48

@兔兔涂涂凸: 把那行代码.从function里拿到外面

吴瑞祥 | 园豆:29449 (高人七级) | 2017-03-29 17:48

@吴瑞祥: function initialCampaignTriggerListShare() {}我要加一个这样的方法应该加在哪里,又该怎样在其它js中调用?

兔兔涂涂凸 | 园豆:13 (初学一级) | 2017-03-29 17:52

@兔兔涂涂凸: 你要写一个能在任何地方调用的js方法?

吴瑞祥 | 园豆:29449 (高人七级) | 2017-03-29 17:58

@吴瑞祥: 他们是在一个分类下面的

兔兔涂涂凸 | 园豆:13 (初学一级) | 2017-03-29 18:06

@兔兔涂涂凸: 重点还是你要在哪里调用.像你问题里代码也能实现.只是作用域不一样

吴瑞祥 | 园豆:29449 (高人七级) | 2017-03-29 18:55

@吴瑞祥: campaignprogram和programcampaign和synccampaign调用campaigncommon

兔兔涂涂凸 | 园豆:13 (初学一级) | 2017-03-29 19:05

@兔兔涂涂凸: 在页面A上面你要先引用campaigncommon 再引用其它JS

就跟你要写jquery代码得先引用jqeury一样.

吴瑞祥 | 园豆:29449 (高人七级) | 2017-03-29 20:48

@吴瑞祥: 引用了,就是不太明白campaigncommon里面的方法应该怎么写别的地方才能去调用

兔兔涂涂凸 | 园豆:13 (初学一级) | 2017-03-30 09:50

@兔兔涂涂凸: 就跟在一个js文件里的代码一样....没有区别.你多试试不就知道了.总共没几种情况.

吴瑞祥 | 园豆:29449 (高人七级) | 2017-03-30 10:57

@吴瑞祥: 好的,谢谢,解决了

兔兔涂涂凸 | 园豆:13 (初学一级) | 2017-03-30 11:59

@吴瑞祥: 

向您再请教一个问题:  
js tree树形规则菜单内容怎么样让他默认打开状态 
兔兔涂涂凸 | 园豆:13 (初学一级) | 2017-03-30 16:58

@兔兔涂涂凸: 只能说:查文档..在官网上一般都会有参数说明

吴瑞祥 | 园豆:29449 (高人七级) | 2017-03-30 17:57

@吴瑞祥: 

我用了这个方法,同一种类型的树能加载出来,可是一旦换了一种类型再加载就会报错。请问是怎么回事?

兔兔涂涂凸 | 园豆:13 (初学一级) | 2017-03-31 14:55

@吴瑞祥: 大佬,麻烦能问个接口签名的问题么?

兔兔涂涂凸 | 园豆:13 (初学一级) | 2017-10-17 12:16

@兔兔涂涂凸: 直接写问题..

吴瑞祥 | 园豆:29449 (高人七级) | 2017-10-17 13:15

@吴瑞祥: 

兔兔涂涂凸 | 园豆:13 (初学一级) | 2017-10-17 16:38

@兔兔涂涂凸: 你把result的值输出出来.在把反序列化实体类的结构发出来.

不过看着是反序列化成接口?

吴瑞祥 | 园豆:29449 (高人七级) | 2017-10-17 16:44

@吴瑞祥: {"kaola_order_search_response":{"orders":[{"buyer_account":"qakaolatest@163.com","buyer_phone":"","cert_id_no":null,"cert_name":null,"coupon_amount":"0.00","deliver_time":"","express_fee":"10.00","finish_time":"","invoice_amount":"","invoice_title":"","need_invoice":0,"order_business_remark":null,"order_buyer_remark":null,"order_expresses":[{"express_company_code":"","express_no":""}],"order_id":"2017100915370000000105360","order_origin_price":"110.00","order_real_price":"90.00","order_skus":[{"activity_totle_amount":"20.00","barcode":"P0000005568","count":1,"coupon_totle_amount":"0","first_unit":null,"first_unit_num":null,"goods_no":"P0000005568","hs_code":null,"hs_key":null,"is_gift":0,"item_key":"858980-518755","order_serial_num":0,"origin_price":"100.00","product_name":"猴姑 健胃饼干 720g","real_totle_price":"80.00","second_unit":null,"second_unit_num":null,"sku_key":"1161708-518755","sku_outer_id":"","sku_tax_fee":0,"warehouse_code":"182","warehouse_id":182,"warehouse_name":"fniki111"}],"order_status":1,"order_time":"2017-10-09 15:37:01","pay_method_name":"网易宝PC","pay_method_subname":"网易宝","pay_success_time":"2017-10-09 15:37:13","photo_urls":null,"pre_deliver_time":"","presale_order":0,"receiver_address_detail":"网易大厦","receiver_city_name":"北京市","receiver_district_name":"东城区","receiver_name":"刘灰灰","receiver_phone":"15050527361","receiver_post_code":"","receiver_province_name":"北京市","tax_fee":"0.00","taxpayer_no":"","trade_no":null,"waiting_cancel_time":"","waiting_deliver_time":"2017-10-09 16:41:56"},{"buyer_account":"qakaolatest@163.com","buyer_phone":"","cert_id_no":null,"cert_name":null,"coupon_amount":"0.00","deliver_time":"","express_fee":"10.00","finish_time":"","invoice_amount":"","invoice_title":"","need_invoice":0,"order_business_remark":null,"order_buyer_remark":null,"order_expresses":[{"express_company_code":"","express_no":""}],"order_id":"2017100915360000000105358","order_origin_price":"110.00","order_real_price":"90.00","order_skus":[{"activity_totle_amount":"20.00","barcode":"P0000005568","count":1,"coupon_totle_amount":"0","first_unit":null,"first_unit_num":null,"goods_no":"P0000005568","hs_code":null,"hs_key":null,"is_gift":0,"item_key":"858980-518755","order_serial_num":0,"origin_price":"100.00","product_name":"猴姑 健胃饼干 720g","real_totle_price":"80.00","second_unit":null,"second_unit_num":null,"sku_key":"1161708-518755","sku_outer_id":"","sku_tax_fee":0,"warehouse_code":"182","warehouse_id":182,"warehouse_name":"fniki111"}],"order_status":1,"order_time":"2017-10-09 15:36:01","pay_method_name":"网易宝PC","pay_method_subname":"网易宝","pay_success_time":"2017-10-09 15:36:16","photo_urls":null,"pre_deliver_time":"","presale_order":0,"receiver_address_detail":"网易大厦","receiver_city_name":"北京市","receiver_district_name":"东城区","receiver_name":"刘灰灰","receiver_phone":"15050527361","receiver_post_code":"","receiver_province_name":"北京市","tax_fee":"0.00","taxpayer_no":"","trade_no":null,"waiting_cancel_time":"","waiting_deliver_time":"2017-10-09 16:41:56"}],"total_count":2,"totle_count":2}}

兔兔涂涂凸 | 园豆:13 (初学一级) | 2017-10-17 16:47

@吴瑞祥: 你json在线解析一下,,我这边解析的格式发不过去

兔兔涂涂凸 | 园豆:13 (初学一级) | 2017-10-17 16:48

@吴瑞祥: 

namespace SkyeSdk.Kaola.Response
{
public class OrderSearchResponse : KaolaResponse
{
/// <summary>
/// 订单信息
/// </summary>
public Order[] orders { get; set; }

/// <summary>
/// 订单总数
/// </summary>
public int total_count { get; set; }
}

public class Order
{
/// <summary>
/// 买家用户名
/// </summary>
public string buyer_account { get; set; }

/// <summary>
/// 买家手机号
/// </summary>
public string buyer_phone { get; set; }

/// <summary>
/// 订单状态1(已付款)、2(已发货)、3(已签收)、4(缺货订单)、5(取消待确认)、6(已取消)、7(取消处理中)、8(发货处理中)说明:7是处于取消和已取消的一个中间状态,当查询条件为5的时候会返回该状态;8是处于已付款和待发货的一个中间状态,当查询条件为1的时候会返回该状态
/// </summary>
public int order_status { get; set; }

/// <summary>
/// 订单号
/// </summary>
public string order_id { get; set; }

/// <summary>
/// 收件人姓名
/// </summary>
public string receiver_name { get; set; }

/// <summary>
/// 收件人手机
/// </summary>
public string receiver_phone { get; set; }

/// <summary>
/// 收件人省名称
/// </summary>
public string receiver_province_name { get; set; }

/// <summary>
/// 收件人市名称
/// </summary>
public string receiver_city_name { get; set; }

/// <summary>
/// 收件人区(县)名称
/// </summary>
public string receiver_district_name { get; set; }

/// <summary>
/// 收件人详细地址
/// </summary>
public string receiver_address_detail { get; set; }

/// <summary>
/// 收件人邮政编码
/// </summary>
public string receiver_post_code { get; set; }

/// <summary>
/// 支付成功时间YYYY-MM-DD hh:mm:ss
/// </summary>
public string pay_success_time { get; set; }

/// <summary>
/// 订单实际价格
/// </summary>
public string order_real_price { get; set; }

/// <summary>
/// 订单原始价格
/// </summary>
public string order_origin_price { get; set; }

/// <summary>
/// 邮费
/// </summary>
public string express_fee { get; set; }

/// <summary>
/// 支付方式
/// </summary>
public string pay_method_name { get; set; }

/// <summary>
/// 优惠券优惠金额
/// </summary>
public string coupon_amount { get; set; }

/// <summary>
/// 订单完成时间
/// </summary>
public string finish_time { get; set; }

/// <summary>
/// 发货时间
/// </summary>
public string deliver_time { get; set; }

/// <summary>
/// 订单SKU
/// </summary>
public OrderSku[] order_skus { get; set; }

/// <summary>
/// 实名认证姓名
/// </summary>
public string cert_name { get; set; }

/// <summary>
/// 实名认证身份证号码
/// </summary>
public string cert_id_no { get; set; }

/// <summary>
/// 订单税费
/// </summary>
public string tax_fee { get; set; }

/// <summary>
/// 订单交易流水号
/// </summary>
public string trade_no { get; set; }

/// <summary>
/// 是否需要发票 1:是 0:否
/// </summary>
public int need_invoice { get; set; }

/// <summary>
/// 发票金额
/// </summary>
public string invoice_amount { get; set; }

/// <summary>
/// 发票抬头
/// </summary>
public string invoice_title { get; set; }

/// <summary>
/// 订单待发货时间[备注:此字段为新增字段,历史数据可能为空]
/// </summary>
public string waiting_deliver_time { get; set; }

/// <summary>
/// 取消待商家处理时间[备注:此字段为用户申请取消客服同意待商家确认的时间,若用户没有申请,可能为空]
/// </summary>
public string waiting_cancel_time { get; set; }

/// <summary>
/// 0-非预售订单;1-预售订单
/// </summary>
public int presale_order { get; set; }

/// <summary>
/// 预计发货时间
/// </summary>
public string pre_deliver_time { get; set; }

/// <summary>
/// 快递信息
/// </summary>
public OrderExpress[] order_expresses { get; set; }

/// <summary>
/// 订单下单时间
/// </summary>
public string order_time { get; set; }

/// <summary>
/// 卖家备注信息
/// </summary>
public string order_business_remark { get; set; }

/// <summary>
/// 纳税人识别号
/// </summary>
public string taxpayer_no { get; set; }
}

public class OrderExpress
{
/// <summary>
/// 快递公司编码
/// </summary>
public string express_company_code { get; set; }

/// <summary>
/// 快递运单号
/// </summary>
public string express_no { get; set; }
}

public class OrderSku
{
/// <summary>
/// SkuId
/// </summary>
public string sku_key { get; set; }

/// <summary>
/// 商品名称
/// </summary>
public string product_name { get; set; }
/// <summary>
/// 订单原始单价
/// </summary>
public string origin_price { get; set; }

/// <summary>
/// 购买数量
/// </summary>
public int count { get; set; }
/// <summary>
/// 实付总价
/// </summary>
public string real_totle_price { get; set; }

/// <summary>
/// 活动优惠总金额
/// </summary>
public string activity_totle_amount { get; set; }

/// <summary>
/// 货号
/// </summary>
public string goods_no { get; set; }

/// <summary>
/// 优惠券优惠总金额
/// </summary>
public string coupon_totle_amount { get; set; }

/// <summary>
/// 商品条形码
/// </summary>
public string barcode { get; set; }

/// <summary>
/// 仓库编码
/// </summary>
public int warehouse_code { get; set; }

/// <summary>
/// 仓库名称
/// </summary>
public string warehouse_name { get; set; }

/// <summary>
/// 序列号:报关时使用到排序
/// </summary>
public int order_serial_num { get; set; }
}
}

兔兔涂涂凸 | 园豆:13 (初学一级) | 2017-10-17 16:48

@吴瑞祥: 这是实体类的结构

兔兔涂涂凸 | 园豆:13 (初学一级) | 2017-10-17 16:49

@兔兔涂涂凸: 是你的实体类格式不对.你把第一级直接吃掉了.把第一级吐出来加回去.

复制json字符串,然后在实体类文件的最后一行点一下把光标移过去

然后点菜单里的->编辑->选择性粘贴->将json粘贴为类

就能得到正确格式.

吴瑞祥 | 园豆:29449 (高人七级) | 2017-10-18 10:06

@吴瑞祥: 好的了,,谢谢

兔兔涂涂凸 | 园豆:13 (初学一级) | 2017-10-18 11:59

@兔兔涂涂凸: 请教一个问题,,

public TResponse Execute<TResponse>(IKaolaRequest<TResponse> request) where TResponse : KaolaResponse
{
var timestamp = DateTime.UtcNow.AddHours(8).ToString("yyyy-MM-dd HH:mm:ss");
var method = request.Method;

string result = "";
SortedList<string, string> sortedList = new SortedList<string, string>(request.GetDictionary());
sortedList.Add("timestamp", timestamp);
sortedList.Add("method", method);
sortedList.Add("app_key", appKey);
sortedList.Add("access_token", accessToken);
var sign = CreateSign(sortedList, appSecret);

string url = $"{serverUrl}?sign={sign}&timestamp={timestamp}&method={method}&app_key={appKey}&access_token={accessToken}";
foreach (var item in request.GetDictionary())
{
url += $"&{item.Key}={item.Value}";
}
using (HttpClient client = new HttpClient())
{
result = client.GetAsync(url).Result.Content.ReadAsStringAsync().Result;
}

return JsonConvert.DeserializeObject<TResponse>(result);
}

 

我这个方法的返回值是根据传进来的request对应的response。,, public class OrderSearchRequest : IKaolaRequest<OrderSearchResponse>{}   

 

现在是这样,, 当result = client.GetAsync(url).Result.Content.ReadAsStringAsync().Result;  result得到的是错误的时候,我想返回一个Errorrespnse,这时候就会报错,因为当你request传进来的时候,TResponse就是这个request对应的response了,,这时候我再想返回Errorrsponse就会报错了,,请问有没有什么好的解决方法。谢谢

兔兔涂涂凸 | 园豆:13 (初学一级) | 2017-10-18 14:28

@吴瑞祥: 

请教一个问题,,

public TResponse Execute<TResponse>(IKaolaRequest<TResponse> request) where TResponse : KaolaResponse
{
var timestamp = DateTime.UtcNow.AddHours(8).ToString("yyyy-MM-dd HH:mm:ss");
var method = request.Method;

string result = "";
SortedList<string, string> sortedList = new SortedList<string, string>(request.GetDictionary());
sortedList.Add("timestamp", timestamp);
sortedList.Add("method", method);
sortedList.Add("app_key", appKey);
sortedList.Add("access_token", accessToken);
var sign = CreateSign(sortedList, appSecret);

string url = $"{serverUrl}?sign={sign}&timestamp={timestamp}&method={method}&app_key={appKey}&access_token={accessToken}";
foreach (var item in request.GetDictionary())
{
url += $"&{item.Key}={item.Value}";
}
using (HttpClient client = new HttpClient())
{
result = client.GetAsync(url).Result.Content.ReadAsStringAsync().Result;
}

return JsonConvert.DeserializeObject<TResponse>(result);
}

 

我这个方法的返回值是根据传进来的request对应的response。,, public class OrderSearchRequest : IKaolaRequest<OrderSearchResponse>{}   

 

现在是这样,, 当result = client.GetAsync(url).Result.Content.ReadAsStringAsync().Result;  result得到的是错误的时候,我想返回一个Errorrespnse,这时候就会报错,因为当你request传进来的时候,TResponse就是这个request对应的response了,,这时候我再想返回Errorrsponse就会报错了,,请问有没有什么好的解决方法。谢谢

兔兔涂涂凸 | 园豆:13 (初学一级) | 2017-10-18 14:36

@兔兔涂涂凸: 做法看不懂.

吴瑞祥 | 园豆:29449 (高人七级) | 2017-10-18 14:46

返回值TResponse是传过来的request对应的response,,

,现在如果要返回一个错误类型的Response该怎么办

兔兔涂涂凸 | 园豆:13 (初学一级) | 2017-10-18 17:47

@兔兔涂涂凸: 不可以.你可以把是否成功标识放在接口里

吴瑞祥 | 园豆:29449 (高人七级) | 2017-10-18 18:16
其他回答(1)
-1

()(XXXXCommon)  ---   这里写一个你的那个XXXXCommon对象

最佳损友。 | 园豆:63 (初学一级) | 2017-03-29 17:57

 不太明白,麻烦详细点,谢谢

支持(0) 反对(0) 兔兔涂涂凸 | 园豆:13 (初学一级) | 2017-03-29 17:59

{"kaola_order_search_response":{"orders":[{"buyer_account":"qakaolatest@163.com","buyer_phone":"","cert_id_no":null,"cert_name":null,"coupon_amount":"0.00","deliver_time":"","express_fee":"10.00","finish_time":"","invoice_amount":"","invoice_title":"","need_invoice":0,"order_business_remark":null,"order_buyer_remark":null,"order_expresses":[{"express_company_code":"","express_no":""}],"order_id":"2017100915370000000105360","order_origin_price":"110.00","order_real_price":"90.00","order_skus":[{"activity_totle_amount":"20.00","barcode":"P0000005568","count":1,"coupon_totle_amount":"0","first_unit":null,"first_unit_num":null,"goods_no":"P0000005568","hs_code":null,"hs_key":null,"is_gift":0,"item_key":"858980-518755","order_serial_num":0,"origin_price":"100.00","product_name":"猴姑 健胃饼干 720g","real_totle_price":"80.00","second_unit":null,"second_unit_num":null,"sku_key":"1161708-518755","sku_outer_id":"","sku_tax_fee":0,"warehouse_code":"182","warehouse_id":182,"warehouse_name":"fniki111"}],"order_status":1,"order_time":"2017-10-09 15:37:01","pay_method_name":"网易宝PC","pay_method_subname":"网易宝","pay_success_time":"2017-10-09 15:37:13","photo_urls":null,"pre_deliver_time":"","presale_order":0,"receiver_address_detail":"网易大厦","receiver_city_name":"北京市","receiver_district_name":"东城区","receiver_name":"刘灰灰","receiver_phone":"15050527361","receiver_post_code":"","receiver_province_name":"北京市","tax_fee":"0.00","taxpayer_no":"","trade_no":null,"waiting_cancel_time":"","waiting_deliver_time":"2017-10-09 16:41:56"},{"buyer_account":"qakaolatest@163.com","buyer_phone":"","cert_id_no":null,"cert_name":null,"coupon_amount":"0.00","deliver_time":"","express_fee":"10.00","finish_time":"","invoice_amount":"","invoice_title":"","need_invoice":0,"order_business_remark":null,"order_buyer_remark":null,"order_expresses":[{"express_company_code":"","express_no":""}],"order_id":"2017100915360000000105358","order_origin_price":"110.00","order_real_price":"90.00","order_skus":[{"activity_totle_amount":"20.00","barcode":"P0000005568","count":1,"coupon_totle_amount":"0","first_unit":null,"first_unit_num":null,"goods_no":"P0000005568","hs_code":null,"hs_key":null,"is_gift":0,"item_key":"858980-518755","order_serial_num":0,"origin_price":"100.00","product_name":"猴姑 健胃饼干 720g","real_totle_price":"80.00","second_unit":null,"second_unit_num":null,"sku_key":"1161708-518755","sku_outer_id":"","sku_tax_fee":0,"warehouse_code":"182","warehouse_id":182,"warehouse_name":"fniki111"}],"order_status":1,"order_time":"2017-10-09 15:36:01","pay_method_name":"网易宝PC","pay_method_subname":"网易宝","pay_success_time":"2017-10-09 15:36:16","photo_urls":null,"pre_deliver_time":"","presale_order":0,"receiver_address_detail":"网易大厦","receiver_city_name":"北京市","receiver_district_name":"东城区","receiver_name":"刘灰灰","receiver_phone":"15050527361","receiver_post_code":"","receiver_province_name":"北京市","tax_fee":"0.00","taxpayer_no":"","trade_no":null,"waiting_cancel_time":"","waiting_deliver_time":"2017-10-09 16:41:56"}],"total_count":2,"totle_count":2}}

支持(0) 反对(0) 兔兔涂涂凸 | 园豆:13 (初学一级) | 2017-10-17 16:47
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册