Selaa lähdekoodia

完成注销功能

hy 3 vuotta sitten
vanhempi
commit
992b5c8ec0

+ 73 - 15
app/src/main/java/com/electric/chargingpile/activity/LogOutActivity.java

@ -9,6 +9,7 @@ import android.content.SharedPreferences;
9 9
import android.os.Bundle;
10 10
import android.os.Handler;
11 11
import android.util.Log;
12
import android.view.KeyEvent;
12 13
import android.view.View;
13 14
import android.widget.TextView;
14 15
import android.widget.Toast;
@ -23,6 +24,7 @@ import com.electric.chargingpile.util.BarColorUtil;
23 24
import com.electric.chargingpile.util.DES3;
24 25
import com.electric.chargingpile.util.ImageTools;
25 26
import com.electric.chargingpile.util.JsonUtils;
27
import com.electric.chargingpile.util.ToastUtil;
26 28
import com.electric.chargingpile.view.StateDialog;
27 29
import com.zhy.http.okhttp.OkHttpUtils;
28 30
import com.zhy.http.okhttp.callback.StringCallback;
@ -34,7 +36,7 @@ import pub.devrel.easypermissions.EasyPermissions;
34 36
35 37
public class LogOutActivity extends AppCompatActivity {
36 38
37
    private TextView text;
39
    private TextView text,addTimeText;
38 40
    private String state;
39 41
    private View unSubmittedLayout;
40 42
    private View unRegisterLayout;
@ -46,7 +48,7 @@ public class LogOutActivity extends AppCompatActivity {
46 48
        BarColorUtil.initStatusBarColor(LogOutActivity.this);
47 49
        initView();
48 50
        initIntent();
49
51
        quiryState();
50 52
    }
51 53
52 54
    private void initIntent() {
@ -64,11 +66,16 @@ public class LogOutActivity extends AppCompatActivity {
64 66
65 67
    private void initView() {
66 68
        findViewById(R.id.iv_back).setOnClickListener(v->{
69
70
            if (state !=null && state.equals("1")){
71
                signOut();
72
            }
67 73
            finish();
68 74
        });
69 75
70 76
        text = findViewById(R.id.text);
71
        unSubmittedLayout = findViewById(R.id.unRegisterLayout);
77
        addTimeText = findViewById(R.id.addTime);
78
        unSubmittedLayout = findViewById(R.id.unSubmittedLayout);
72 79
        unRegisterLayout = findViewById(R.id.unRegisterLayout);
73 80
        text.setOnClickListener(v->{
74 81
            if (state !=null && state.equals("1")){
@ -107,17 +114,7 @@ public class LogOutActivity extends AppCompatActivity {
107 114
                Log.e("onResponse applyLogOutNet", response);
108 115
                String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
109 116
                if (rtnCode.equals("01")){
110
                    try {
111
                        sendLoginStatus();
112
                    } catch (Exception e) {
113
                        e.printStackTrace();
114
                    }
115
116
                    deleteUserInfo();
117
                    SharedPreferences sharedPreferences = getSharedPreferences("userInfo",
118
                            Activity.MODE_PRIVATE);
119
                    sharedPreferences.edit().clear();
120
                    startActivity(new Intent(LogOutActivity.this,MainMapActivity.class));
117
                    signOut();
121 118
                }else{
122 119
                    String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");
123 120
                    showDialog(rtnMsg);
@ -128,6 +125,20 @@ public class LogOutActivity extends AppCompatActivity {
128 125
129 126
    }
130 127
128
    private void signOut() {
129
        try {
130
            sendLoginStatus();
131
        } catch (Exception e) {
132
            e.printStackTrace();
133
        }
134
135
        deleteUserInfo();
136
        SharedPreferences sharedPreferences = getSharedPreferences("userInfo",
137
                Activity.MODE_PRIVATE);
138
        sharedPreferences.edit().clear();
139
        startActivity(new Intent(LogOutActivity.this,MainMapActivity.class));
140
    }
141
131 142
    /**
132 143
     * 取消注销
133 144
     * */
@ -142,7 +153,42 @@ public class LogOutActivity extends AppCompatActivity {
142 153
            @Override
143 154
            public void onResponse(String response) {
144 155
                Log.e("onResponse cancelLogout", response);
145
                String code = JsonUtils.getKeyResult(response, "code");
156
                String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
157
                if (rtnCode.equals("01")){
158
                    finish();
159
                }else{
160
                    String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");
161
                    ToastUtil.showToast(LogOutActivity.this,rtnMsg, Toast.LENGTH_SHORT);
162
                }
163
            }
164
        });
165
166
    }
167
    /**
168
     * 查询是否注销
169
     * */
170
    private void quiryState(){
171
        String url=MainApplication.url +"/zhannew/basic/web/index.php/userdel/get?phone="+ MainApplication.userPhone+"&password="+MainApplication.userPassword;
172
        OkHttpUtils.get().url(url).build().execute(new StringCallback() {
173
            @Override
174
            public void onError(Call call, Exception e) {
175
176
            }
177
178
            @Override
179
            public void onResponse(String response) {
180
                Log.e("onResponse quiryState", response);
181
                String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
182
                if (rtnCode.equals("01")){
183
                    String data = JsonUtils.getKeyResult(response, "data");
184
                    String addTime = JsonUtils.getKeyResult(data, "addTime");
185
                    String status = JsonUtils.getKeyResult(data, "status");
186
                    addTimeText.setText(addTime);
187
188
                }else{
189
//                    String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");
190
//                    ToastUtil.showToast(LogOutActivity.this,rtnMsg, Toast.LENGTH_SHORT);
191
                }
146 192
            }
147 193
        });
148 194
@ -217,6 +263,18 @@ public class LogOutActivity extends AppCompatActivity {
217 263
        );
218 264
    }
219 265
266
    @Override
267
    public boolean onKeyDown(int keyCode, KeyEvent event) {
268
        if (keyCode == KeyEvent.KEYCODE_BACK){
269
            if (state !=null && state.equals("1")){
270
                signOut();
271
                return true;
272
            }
273
        }
274
        return super.onKeyDown(keyCode, event);
275
    }
276
277
220 278
    /**
221 279
     * @param state  0表示由UserCenterMoreActivity打开 1 表示从登录页面跳转过来
222 280
     * */

+ 33 - 5
app/src/main/java/com/electric/chargingpile/activity/LoginActivity.java

@ -316,11 +316,7 @@ public class LoginActivity extends Activity implements View.OnClickListener {
316 316
                        saveUserInfo(data);
317 317
                        MobclickAgent.onProfileSignIn(MainApplication.userId);
318 318
                        showTextToast("登录成功");
319
                        setResult(RESULT_SUCCESS);
320
321
                        ProfileManager.getInstance().setCount(getApplicationContext(), 0);
322
                        MainApplication.count = 0;
323
                        finish();
319
                        quiryState();
324 320
                    } else if ("03".equals(rtnCode)) {
325 321
                        showTextToast("登录超时,请重新登录");
326 322
                    } else if ("02".equals(rtnCode)) {
@ -335,6 +331,38 @@ public class LoginActivity extends Activity implements View.OnClickListener {
335 331
        }
336 332
    }
337 333
334
    /**
335
     * 查询是否注销
336
     *
337
     **/
338
    private void quiryState(){
339
        String url=MainApplication.url +"/zhannew/basic/web/index.php/userdel/get?phone="+ MainApplication.userPhone+"&password="+MainApplication.userPassword;
340
        OkHttpUtils.get().url(url).build().execute(new StringCallback() {
341
            @Override
342
            public void onError(Call call, Exception e) {
343
                ToastUtil.showToast(getApplicationContext(), "网络异常,请检查您的网络连接", Toast.LENGTH_SHORT);
344
                CrashReport.postCatchedException(e);
345
            }
346
347
            @Override
348
            public void onResponse(String response) {
349
                Log.e("onResponse quiryState", response);
350
                String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
351
                if (rtnCode.equals("01")){
352
                    LogOutActivity.actionStart(LoginActivity.this,"1");
353
                    finish();
354
                }else{
355
                    setResult(RESULT_SUCCESS);
356
357
                    ProfileManager.getInstance().setCount(getApplicationContext(), 0);
358
                    MainApplication.count = 0;
359
                    finish();
360
                }
361
            }
362
        });
363
364
    }
365
338 366
    private void saveUserInfo(String info) {
339 367
        String userid = JsonUtils.getKeyResult(info, "userid");
340 368
        String nickname = JsonUtils.getKeyResult(info, "nickname");

+ 16 - 2
app/src/main/res/layout/activity_logout.xml

@ -35,6 +35,7 @@
35 35
    </com.zhy.autolayout.AutoRelativeLayout>
36 36
37 37
    <LinearLayout
38
38 39
        android:orientation="vertical"
39 40
        android:id="@+id/unSubmittedLayout"
40 41
        android:layout_width="match_parent"
@ -165,7 +166,6 @@
165 166
    </LinearLayout>
166 167
167 168
    <LinearLayout
168
        tools:visibility="visible"
169 169
        android:visibility="gone"
170 170
        android:id="@+id/unRegisterLayout"
171 171
        android:orientation="vertical"
@ -188,6 +188,7 @@
188 188
            />
189 189
190 190
        <TextView
191
            android:id="@+id/addTime"
191 192
            android:layout_marginTop="20dp"
192 193
            android:layout_gravity="center"
193 194
            android:layout_width="wrap_content"
@ -197,11 +198,24 @@
197 198
            android:textSize="12sp"
198 199
            />
199 200
        <TextView
201
            android:layout_marginEnd="20dp"
202
            android:layout_marginStart="20dp"
203
            android:layout_marginTop="20dp"
204
            android:layout_gravity="center"
205
            android:layout_width="wrap_content"
206
            android:layout_height="wrap_content"
207
            android:text="您的账号已提交注销申请,账号将冻结15天,冻结期内可登录APP撤销申请,不可使用APP功能,将在15天后正式注销账号,清除账号相关信息。"
208
            android:textColor="#ff0e0e0e"
209
            android:textSize="12sp"
210
            />
211
        <TextView
212
            android:layout_marginEnd="20dp"
213
            android:layout_marginStart="20dp"
200 214
            android:layout_marginTop="20dp"
201 215
            android:layout_gravity="center"
202 216
            android:layout_width="wrap_content"
203 217
            android:layout_height="wrap_content"
204
            tools:text="审核中不能充值和开启充电,取消注销可继续使用"
218
            android:text="账号正式注销后,再次注册APP将为新注册账号,已注销的账号信息无法找回。"
205 219
            android:textColor="#ff0e0e0e"
206 220
            android:textSize="12sp"
207 221
            />