52
+print(result)

+ 48 - 0
utils/kuaidi/synquery.py

@@ -0,0 +1,48 @@
1
+# -*- coding: utf-8 -*-'
2
+
3
+import hashlib
4
+import json
5
+
6
+import requests
7
+from django.conf import settings
8
+
9
+
10
+class KuaiDi100:
11
+    def __init__(self):
12
+        self.key = settings.KUAIDI00.get('key', '')  # TODO 客户授权key
13
+        self.customer = settings.KUAIDI00.get('customer', '')  # TODO 查询公司编号
14
+        self.url = 'https://poll.kuaidi100.com/poll/query.do'  # 请求地址
15
+
16
+    def track(self, com, num, phone=None, ship_from=None, ship_to=None):
17
+        """
18
+        物流轨迹实时查询: https://api.kuaidi100.com/document/5f0ffb5ebc8da837cbd8aefc.html
19
+        :param com: 查询的快递公司的编码,一律用小写字母
20
+        :param num: 查询的快递单号,单号的最大长度是32个字符
21
+        :param phone: 收件人或寄件人的手机号或固话(也可以填写后四位,如果是固话,请不要上传分机号)
22
+        :param ship_from: 出发地城市,省-市-区,非必填,填了有助于提升签收状态的判断的准确率,请尽量提供
23
+        :param ship_to: 目的地城市,省-市-区,非必填,填了有助于提升签收状态的判断的准确率,且到达目的地后会加大监控频率,请尽量提供
24
+        :return: requests.Response.text
25
+        """
26
+        param = {
27
+            'com': com,
28
+            'num': num,
29
+            'phone': phone,
30
+            'from': ship_from,
31
+            'to': ship_to,
32
+            'resultv2': '1',  # 添加此字段表示开通行政区域解析功能。0:关闭(默认),1:开通行政区域解析功能,2:开通行政解析功能并且返回出发、目的及当前城市信息
33
+            'show': '0',  # 返回数据格式。0:json(默认),1:xml,2:html,3:text
34
+            'order': 'desc'  # 返回结果排序方式。desc:降序(默认),asc:升序
35
+        }
36
+        param_str = json.dumps(param)  # 转json字符串
37
+
38
+        # 签名加密, 用于验证身份, 按param + key + customer 的顺序进行MD5加密(注意加密后字符串要转大写), 不需要“+”号
39
+        temp_sign = param_str + self.key + self.customer
40
+        md = hashlib.md5()
41
+        md.update(temp_sign.encode())
42
+        sign = md.hexdigest().upper()
43
+        request_data = {'customer': self.customer, 'param': param_str, 'sign': sign}
44
+        return requests.post(self.url, request_data).text  # 发送请求
45
+
46
+
47
+# result = KuaiDi100().track('yuantong', 'YT9693083639795', '', '广东省江门市', '广东省深圳市')
48
+# print(result)

paiai_ios - Gogs: Go Git Service

Brak opisu

NavigationControllerDelegate.swift 1.6KB

    // // NavigationControllerDelegate.swift // PaiaiUIKit // // Created by ffib on 2019/1/16. // Copyright © 2019 yb. All rights reserved. // import Foundation public protocol NavigationControllerDelegate: class { func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? } public extension NavigationControllerDelegate { func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {} func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {} func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? { return nil } }