="add-code nl-22 ol-22"> 22
+        :param tid: 短信模板ID
23
+        :param sms_content: 短信模板替换内容
24
+        :param order_id: 外部订单号:当该短信发送模板有回调地址时,外部订单号会返回给调用者,方便用户更新数据
25
+        :return: requests.Response.text
26
+        """
27
+        req_params = {
28
+            'sign': self.sign,  # 加密签名信息:MD5(key + userid);加密后字符串转大写
29
+            'userid': self.userid,  # 我方分配给贵司的的短信接口用户ID,点击查看账号信息
30
+            'seller': seller,  # 商户名称签名;最好用简称,该字段信息会在短信标签处显示。不要超过5个字符
31
+            'phone': phone,  # 接收短信手机号
32
+            'tid': tid,  # 短信模板ID
33
+            'content': sms_content,  # 短信模板替换内容
34
+            'outorder': order_id,  # 外部订单号:当该短信发送模板有回调地址时,外部订单号会返回给调用者,方便用户更新数据
35
+            # 'callback': 'https//www.baidu.com/kd100/callback'  # 回调地址:如果客户在发送短信时填写该参数,将按照这个参数回调短信发送状态;如果为空,将按照模板配置的地址回调短信发送状态;如果两个参数都不填写,将不会回调通知状态
36
+        }
37
+
38
+        return requests.post(self.url, req_params).text  # 发送请求
39
+
40
+
41
+content = {  # 短信模板替换内容
42
+    "接收人姓名": "小百",
43
+    "公司名": "快递100",
44
+    "快递单号": "154893238584",
45
+    "url": "https://www.kuaidi100.com"
46
+}
47
+result = KuaiDi100().send_sms('快递100', '13800138000', '11', content, '123456789')
48
+print(result)

+ 52 - 0
utils/kuaidi/subscribe.py

@@ -0,0 +1,52 @@
1
+# -*- coding: utf-8 -*-'
2
+
3
+import json
4
+
5
+import requests
6
+
7
+
8
+class KuaiDi100:
9
+    def __init__(self):
10
+        self.key = ''  # TODO 客户授权key
11
+        self.url = 'https://poll.kuaidi100.com/poll'  # 请求地址
12
+
13
+    def submit(self, com, num, phone, ship_from, ship_to):
14
+        """
15
+        物流轨迹订阅
16
+        :param com: 快递公司编码
17
+        :param num: 快递单号
18
+        :param phone: 收件人或寄件人的手机号或固话(也可以填写后四位,如果是固话,请不要上传分机号)
19
+        :param ship_from: 出发地城市,省-市-区,非必填,填了有助于提升签收状态的判断的准确率,请尽量提供
20
+        :param ship_to: 目的地城市,省-市-区,非必填,填了有助于提升签收状态的判断的准确率,且到达目的地后会加大监控频率,请尽量提供
21
+        :return: requests.Response.text
22
+        """
23
+        param = {
24
+            'company': com,
25
+            'number': num,
26
+            'from': ship_from,
27
+            'to': ship_to,
28
+            'key': self.key,
29
+            'parameters': {
30
+                'callbackurl': 'https://www.baidu.com/kd100/callback',  # 回调接口的地址。如果需要在推送信息回传自己业务参数,可以在回调地址URL后面拼接上去,例如:https://www.baidu.com/kd100/callback?orderId=123
31
+                'salt': None,  # 签名用随机字符串。32位自定义字符串。添加该参数,则推送的时候会增加sign给贵司校验消息的可靠性
32
+                'resultv2': '1',  # 添加此字段表示开通行政区域解析功能。0:关闭(默认),1:开通行政区域解析功能
33
+                'autoCom': '0',  # 添加此字段且将此值设为1,则表示开始智能判断单号所属公司的功能,开启后,company字段可为空,即只传运单号(number字段),我方收到后会根据单号判断出其所属的快递公司(即company字段)。建议只有在无法知道单号对应的快递公司(即company的值)的情况下才开启此功能
34
+                'interCom': '0',  # 添加此字段且将此值设为1,则表示开启国际版,开启后,若订阅的单号(即number字段)属于国际单号,会返回出发国与目的国两个国家的跟踪信息,本功能暂时只支持邮政体系(国际类的邮政小包、EMS)内的快递公司,若单号我方识别为非国际单,即使添加本字段,也不会返回destResult元素组
35
+                'departureCountry': '',  # 出发国家编码,interCom=1的国际单号最好提供该值
36
+                'departureCom': '',  # 出发国家快递公司的编码,interCom=1的国际单号最好提供该值
37
+                'destinationCountry': '',  # 目的国家编码,interCom=1的国际单号最好提供该值
38
+                'destinationCom': '',  # 目的国家快递公司的编码,interCom=1的国际单号最好提供该值
39
+                'phone': phone
40
+            }
41
+        }
42
+
43
+        req_params = {
44
+            'schema': 'json',  # 查询公司编号
45
+            'param': json.dumps(param)  # 参数数据
46
+        }
47
+
48
+        return requests.post(self.url, req_params).text  # 发送请求
49
+
50
+
51
+result = KuaiDi100().submit('yuantong', 'YT9693083639795', '', '江门市', '深圳市')
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)

setting and briefs activity · b5aa29060b - Gogs: Go Git Service

setting and briefs activity

chengzhenyu 10 年之前
父節點
當前提交
b5aa29060b

+ 12 - 0
app/src/main/AndroidManifest.xml

@@ -46,6 +46,18 @@
46 46
             android:label="@string/app_name">
47 47
         </activity>
48 48
 
49
+        <activity
50
+        android:name=".briefs.BriefsActivity"
51
+        android:configChanges="keyboardHidden|orientation|screenSize"
52
+        android:label="@string/app_name">
53
+    </activity>
54
+
55
+        <activity
56
+            android:name=".settings.SettingsActivity"
57
+            android:configChanges="keyboardHidden|orientation|screenSize"
58
+            android:label="@string/app_name">
59
+        </activity>
60
+
49 61
     </application>
50 62
 
51 63
 </manifest>

+ 33 - 0
app/src/main/java/ai/pai/lensman/briefs/BriefsActivity.java

@@ -0,0 +1,33 @@
1
+package ai.pai.lensman.briefs;
2
+
3
+import android.content.Intent;
4
+import android.os.Bundle;
5
+import android.support.annotation.Nullable;
6
+import android.support.v7.app.AppCompatActivity;
7
+
8
+import ai.pai.lensman.R;
9
+import ai.pai.lensman.settings.SettingsActivity;
10
+import butterknife.ButterKnife;
11
+import butterknife.OnClick;
12
+
13
+public class BriefsActivity extends AppCompatActivity{
14
+
15
+    @Override
16
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
17
+        super.onCreate(savedInstanceState);
18
+        setContentView(R.layout.activity_briefs);
19
+
20
+        ButterKnife.bind(this);
21
+    }
22
+
23
+    @OnClick(R.id.title_bar_back_layout)
24
+    void back(){
25
+        finish();
26
+    }
27
+
28
+    @OnClick(R.id.iv_settings)
29
+    void goToSettingPage(){
30
+        startActivity(new Intent(this, SettingsActivity.class));
31
+    }
32
+
33
+}

+ 35 - 0
app/src/main/java/ai/pai/lensman/settings/SettingsActivity.java

@@ -0,0 +1,35 @@
1
+package ai.pai.lensman.settings;
2
+
3
+import android.os.Bundle;
4
+import android.support.annotation.Nullable;
5
+import android.support.v7.app.AppCompatActivity;
6
+
7
+import ai.pai.lensman.R;
8
+import butterknife.ButterKnife;
9
+import butterknife.OnClick;
10
+
11
+/**
12
+ * Created by chengzhenyu on 2016/7/21.
13
+ */
14
+public class SettingsActivity extends AppCompatActivity {
15
+
16
+
17
+    @Override
18
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
19
+        super.onCreate(savedInstanceState);
20
+        setContentView(R.layout.activity_settings);
21
+
22
+        ButterKnife.bind(this);
23
+    }
24
+
25
+    @OnClick(R.id.title_bar_back_layout)
26
+    void back(){
27
+        finish();
28
+    }
29
+
30
+    @OnClick(R.id.iv_options)
31
+    void clickOptionBtn(){
32
+
33
+    }
34
+
35
+}

+ 3 - 1
app/src/main/java/ai/pai/lensman/upload/UploadActivity.java

@@ -1,5 +1,6 @@
1 1
 package ai.pai.lensman.upload;
2 2
 
3
+import android.content.Intent;
3 4
 import android.os.Bundle;
4 5
 import android.support.v7.app.AppCompatActivity;
5 6
 import android.support.v7.widget.GridLayoutManager;
@@ -12,6 +13,7 @@ import android.widget.TextView;
12 13
 import java.util.ArrayList;
13 14
 
14 15
 import ai.pai.lensman.R;
16
+import ai.pai.lensman.briefs.BriefsActivity;
15 17
 import butterknife.BindView;
16 18
 import butterknife.ButterKnife;
17 19
 import butterknife.OnClick;
@@ -52,7 +54,7 @@ public class UploadActivity extends AppCompatActivity implements UploadContract.
52 54
 
53 55
     @OnClick(R.id.iv_briefs)
54 56
     void jumpToBriefs(){
55
-
57
+        startActivity(new Intent(this, BriefsActivity.class));
56 58
     }
57 59
 
58 60
     @OnClick(R.id.iv_add_session)

二進制
app/src/main/res/drawable-xhdpi/option.png


+ 63 - 0
app/src/main/res/layout/activity_briefs.xml

@@ -0,0 +1,63 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    android:layout_width="match_parent"
4
+    android:layout_height="match_parent"
5
+    android:background="@color/background_white">
6
+
7
+    <LinearLayout
8
+        android:id="@+id/title_bar_with_back_btn"
9
+        android:layout_width="match_parent"
10
+        android:layout_height="@dimen/action_bar_height"
11
+        android:background="@color/colorPrimary"
12
+        android:orientation="horizontal">
13
+
14
+        <LinearLayout
15
+            android:id="@+id/title_bar_back_layout"
16
+            android:layout_width="70dp"
17
+            android:layout_height="match_parent"
18
+            android:gravity="center_vertical"
19
+            android:orientation="horizontal"
20
+            android:paddingLeft="12dp">
21
+
22
+            <ImageView
23
+                android:layout_width="32dp"
24
+                android:layout_height="32dp"
25
+                android:src="@drawable/back_selector" />
26
+
27
+        </LinearLayout>
28
+
29
+        <TextView
30
+            android:id="@+id/title_bar_middle_txt"
31
+            android:layout_width="0dp"
32
+            android:layout_height="match_parent"
33
+            android:layout_weight="1"
34
+            android:gravity="center"
35
+            android:paddingLeft="10dp"
36
+            android:paddingRight="10dp"
37
+            android:singleLine="true"
38
+            android:text="@string/briefs"
39
+            android:textColor="@color/text_white"
40
+            android:textSize="@dimen/action_bar_title_medium_text_size" />
41
+
42
+        <LinearLayout
43
+            android:id="@+id/title_bar_option_layout"
44
+            android:layout_width="70dp"
45
+            android:layout_height="match_parent"
46
+            android:gravity="center_vertical|right"
47
+            android:orientation="horizontal"
48
+            android:paddingRight="9dp">
49
+
50
+
51
+            <ImageView
52
+                android:id="@+id/iv_settings"
53
+                android:layout_width="32dp"
54
+                android:layout_height="32dp"
55
+                android:layout_marginLeft="6dp"
56
+                android:src="@drawable/settings" />
57
+
58
+        </LinearLayout>
59
+
60
+    </LinearLayout>
61
+
62
+
63
+</RelativeLayout>

+ 63 - 0
app/src/main/res/layout/activity_settings.xml

@@ -0,0 +1,63 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    android:layout_width="match_parent"
4
+    android:layout_height="match_parent"
5
+    android:background="@color/background_white">
6
+
7
+    <LinearLayout
8
+        android:id="@+id/title_bar_with_back_btn"
9
+        android:layout_width="match_parent"
10
+        android:layout_height="@dimen/action_bar_height"
11
+        android:background="@color/colorPrimary"
12
+        android:orientation="horizontal">
13
+
14
+        <LinearLayout
15
+            android:id="@+id/title_bar_back_layout"
16
+            android:layout_width="70dp"
17
+            android:layout_height="match_parent"
18
+            android:gravity="center_vertical"
19
+            android:orientation="horizontal"
20
+            android:paddingLeft="12dp">
21
+
22
+            <ImageView
23
+                android:layout_width="32dp"
24
+                android:layout_height="32dp"
25
+                android:src="@drawable/back_selector" />
26
+
27
+        </LinearLayout>
28
+
29
+        <TextView
30
+            android:id="@+id/title_bar_middle_txt"
31
+            android:layout_width="0dp"
32
+            android:layout_height="match_parent"
33
+            android:layout_weight="1"
34
+            android:gravity="center"
35
+            android:paddingLeft="10dp"
36
+            android:paddingRight="10dp"
37
+            android:singleLine="true"
38
+            android:text="@string/settings"
39
+            android:textColor="@color/text_white"
40
+            android:textSize="@dimen/action_bar_title_medium_text_size" />
41
+
42
+        <LinearLayout
43
+            android:id="@+id/title_bar_option_layout"
44
+            android:layout_width="70dp"
45
+            android:layout_height="match_parent"
46
+            android:gravity="center_vertical|right"
47
+            android:orientation="horizontal"
48
+            android:paddingRight="9dp">
49
+
50
+
51
+            <ImageView
52
+                android:id="@+id/iv_options"
53
+                android:layout_width="32dp"
54
+                android:layout_height="32dp"
55
+                android:layout_marginLeft="6dp"
56
+                android:src="@drawable/option" />
57
+
58
+        </LinearLayout>
59
+
60
+    </LinearLayout>
61
+
62
+
63
+</RelativeLayout>