d"> 75
-        }
76
-        if(loginTask.getStatus()== AsyncTask.Status.RUNNING){
77
-            loginTask.cancel(true);
78
-        }
79
-        loginTask = null;
175
+    private void wxLogin(HashMap<String, String> params) {
176
+
177
+        loginTask = new HttpPostTask(params) {
178
+
179
+            String lensmanId;
180
+            String message;
181
+
182
+            @Override
183
+            protected boolean parseResponse(String response) {
184
+                try {
185
+                    JSONObject json = new JSONObject(response);
186
+                    int status = json.getInt("status");
187
+                    if (status == 200) {
188
+                        JSONObject info = json.getJSONObject("data");
189
+                        lensmanId = info.getString("user_id");
190
+                        return true;
191
+                    } else {
192
+                        message = json.getString("message");
193
+                    }
194
+                } catch (Exception e) {
195
+                    e.printStackTrace();
196
+                }
197
+                return false;
198
+            }
199
+
200
+            @Override
201
+            protected void onPostFail() {
202
+                super.onPostFail();
203
+                listener.onInteractFail(message);
204
+            }
205
+
206
+            @Override
207
+            protected void onPostSuccess() {
208
+                super.onPostSuccess();
209
+                listener.onInteractSuccess(lensmanId);
210
+            }
211
+        };
212
+        loginTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), UrlContainer.WX_LOGIN_URL);
80 213
     }
81 214
 
82 215
 }

+ 11 - 7
app/src/main/java/ai/pai/lensman/login/LoginPresenter.java

@@ -1,6 +1,7 @@
1 1
 package ai.pai.lensman.login;
2 2
 
3 3
 import android.content.Context;
4
+import android.text.TextUtils;
4 5
 
5 6
 import com.tencent.mm.sdk.modelmsg.SendAuth;
6 7
 import com.tencent.mm.sdk.openapi.IWXAPI;
@@ -26,13 +27,6 @@ public class LoginPresenter implements LoginContract.Presenter,BaseInteractor.In
26 27
 
27 28
     @Override
28 29
     public void login() {
29
-        view.showProgressView();
30
-        interactor = new LoginInteractor(this);
31
-        interactor.startJob();
32
-    }
33
-
34
-    @Override
35
-    public void start() {
36 30
         IWXAPI api = WXAPIFactory.createWXAPI(context, APP_ID, true);
37 31
         api.registerApp(APP_ID);
38 32
         SendAuth.Req req = new SendAuth.Req();
@@ -42,6 +36,16 @@ public class LoginPresenter implements LoginContract.Presenter,BaseInteractor.In
42 36
     }
43 37
 
44 38
     @Override
39
+    public void start() {
40
+        String wxCode = Preferences.getInstance(context).getWXCode();
41
+        if(!TextUtils.isEmpty(wxCode)){
42
+            view.showProgressView();
43
+            interactor = new LoginInteractor(wxCode,this);
44
+            interactor.startJob();
45
+        }
46
+    }
47
+
48
+    @Override
45 49
     public void stop() {
46 50
         if(interactor!=null){
47 51
             interactor.cancelJob();

+ 21 - 1
app/src/main/java/ai/pai/lensman/utils/UrlContainer.java

@@ -13,7 +13,27 @@ public class UrlContainer {
13 13
 
14 14
     public static final String SESSION_IDS_CREATE = HOST_URL+"uuid";
15 15
 
16
-    public static final String PHOTO_UPLOAD_URL = HOST_URL+"photos/upload";
16
+    /**
17
+     * user_id  # 用户唯一标识
18
+     * nickname  # 用户昵称
19
+     * session_id  # SESSION唯一标识
20
+     * photo_id  # 照片唯一标识
21
+     * photo  # @File 需要上传的照片
22
+     * current_id  # 当前以获取照片最大id,不传默认为-1
23
+     */
24
+    public static final String PHOTO_UPLOAD_URL = HOST_URL+"l/upload";
25
+
26
+    /**
27
+     * unionid  # 摄影师微信授权 Unionid
28
+     * openid  # 摄影师微信授权 Openid
29
+     * sex  # 性别
30
+     * nickname or screen_name  # 昵称,Android 和 iOS 貌似不同
31
+     * headimgurl or profile_image_url  # 头像,Android 和 iOS 貌似不同
32
+     * country  # 国家
33
+     * province  # 省份
34
+     * city  # 城市
35
+     */
36
+    public static final String WX_LOGIN_URL = HOST_URL+"l/wx/authorize";
17 37
 
18 38
 
19 39
 

+ 3 - 0
app/src/main/java/ai/pai/lensman/wxapi/WXEntryActivity.java

@@ -11,6 +11,8 @@ import com.tencent.mm.sdk.openapi.IWXAPI;
11 11
 import com.tencent.mm.sdk.openapi.IWXAPIEventHandler;
12 12
 import com.tencent.mm.sdk.openapi.WXAPIFactory;
13 13
 
14
+import ai.pai.lensman.db.Preferences;
15
+
14 16
 public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
15 17
 
16 18
     private IWXAPI api;
@@ -42,6 +44,7 @@ public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
42 44
         if(resp instanceof SendAuth.Resp){
43 45
             SendAuth.Resp newResp = (SendAuth.Resp) resp;
44 46
             String code = newResp.code;
47
+            Preferences.getInstance(this).setWXCode(code);
45 48
         }
46 49
     }
47 50
 

Pai2/pai2 - Gogs: Go Git Service

36 Commits (65ab52f95a91290c8010d0516496309c4f2a05ed)

Autor SHA1 Mensagem Data
  Brightcells 65ab52f95a spell error 9 anos atrás
  Brightcells 535ac34ee1 add api download_api 9 anos atrás
  Brightcells afcdf74a49 add api group_data_api 9 anos atrás
  Brightcells 03304ad48a add api guest_status_api & modify api guest_login_api 9 anos atrás
  Brightcells 269576f8b9 add guest user 9 anos atrás
  Brightcells fabef63211 set line_length=200 for isort 9 anos atrás
  Brightcells f72ccb1875 isort import 9 anos atrás
  Brightcells 5bf645c33d change order ruler for paiai home, user_id self upload first 9 anos atrás
  Brightcells 102152ca4a add api lensman_photo_bought & modify api wx_order_create_api and adjust return field 9 anos atrás
  Brightcells 98f968c53c add api lesman_photo_price/wx_order_list_api/wx_order_detail_api 9 anos atrás
  Brightcells 0f425ae151 add api wx_order_query_api 9 anos atrás
  Brightcells 5301e7237e unify join group logic 9 anos atrás
  Brightcells 165424743a modify message relative apis 9 anos atrás
  Brightcells 537bd9bd41 add api group_quit_api 9 anos atrás
  Brightcells ebaa78d5ad add api feedback_api 9 anos atrás
  Brightcells c8d93d6339 add api message_delete_api/message_type_delete_api 9 anos atrás
  Brightcells 454f8cd8ec change some info store in redis & remove some unnecessary params check & add some return for some api 9 anos atrás
  Brightcells da2a81fff1 add api pai2_home 9 anos atrás
  Brightcells 0110c29272 rename api name 9 anos atrás
  Brightcells 7a17d0fb90 add api wxpay & add redis relative 9 anos atrás
  Brightcells 30daca135b add api message_list_api/message_type_list_api/message_read_api 9 anos atrás
  Brightcells c72d89f6e5 add api comment_submit_api/comment_list_api/thumbup_submit_api/thumbup_list_api/thumbup_cancel_api 9 anos atrás
  Brightcells df1df69fe3 add api upgrade/splash 9 anos atrás
  Brightcells 814ed79bfc add api group_unlock_api 9 anos atrás
  Brightcells 4afdb94e20 add avatar for GroupUserInfo 9 anos atrás
  Brightcells 5ef425fee7 add api wx_authorize_api 9 anos atrás
  Brightcells f58bde298b add api flyimg_upload/flyimg_list 9 anos atrás
  Brightcells 7467a3e68a add api group_update/group_remove 9 anos atrás
  Brightcells 7e305483ab add api group_detail/group_lock/group_pass/group_refuse 9 anos atrás
  Brightcells e184e7dd5b add api group_create/group_join 9 anos atrás
  Brightcells 3454610bb7 add api of user signup/login 9 anos atrás
  Brightcells 00e8234de9 add api photo_standard_api 9 anos atrás
  Brightcells e0ba30f506 add api session_detail_api 9 anos atrás
  Brightcells 434468279f add api of lesman login & update other api 9 anos atrás
  Brightcells 52ce35cbfc add api uuid_init/uuid 9 anos atrás
  Brightcells 4defb80fdc gogs first init 9 anos atrás