Browse Source

完成注销功能

hy 4 years ago
parent
commit
992b5c8ec0

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

9
import android.os.Bundle;
9
import android.os.Bundle;
10
import android.os.Handler;
10
import android.os.Handler;
11
import android.util.Log;
11
import android.util.Log;
12
import android.view.KeyEvent;
12
import android.view.View;
13
import android.view.View;
13
import android.widget.TextView;
14
import android.widget.TextView;
14
import android.widget.Toast;
15
import android.widget.Toast;
23
import com.electric.chargingpile.util.DES3;
24
import com.electric.chargingpile.util.DES3;
24
import com.electric.chargingpile.util.ImageTools;
25
import com.electric.chargingpile.util.ImageTools;
25
import com.electric.chargingpile.util.JsonUtils;
26
import com.electric.chargingpile.util.JsonUtils;
27
import com.electric.chargingpile.util.ToastUtil;
26
import com.electric.chargingpile.view.StateDialog;
28
import com.electric.chargingpile.view.StateDialog;
27
import com.zhy.http.okhttp.OkHttpUtils;
29
import com.zhy.http.okhttp.OkHttpUtils;
28
import com.zhy.http.okhttp.callback.StringCallback;
30
import com.zhy.http.okhttp.callback.StringCallback;
34
36
35
public class LogOutActivity extends AppCompatActivity {
37
public class LogOutActivity extends AppCompatActivity {
36
38
37
    private TextView text;
39
    private TextView text,addTimeText;
38
    private String state;
40
    private String state;
39
    private View unSubmittedLayout;
41
    private View unSubmittedLayout;
40
    private View unRegisterLayout;
42
    private View unRegisterLayout;
46
        BarColorUtil.initStatusBarColor(LogOutActivity.this);
48
        BarColorUtil.initStatusBarColor(LogOutActivity.this);
47
        initView();
49
        initView();
48
        initIntent();
50
        initIntent();
49
51
        quiryState();
50
    }
52
    }
51
53
52
    private void initIntent() {
54
    private void initIntent() {
64
66
65
    private void initView() {
67
    private void initView() {
66
        findViewById(R.id.iv_back).setOnClickListener(v->{
68
        findViewById(R.id.iv_back).setOnClickListener(v->{
69
70
            if (state !=null && state.equals("1")){
71
                signOut();
72
            }
67
            finish();
73
            finish();
68
        });
74
        });
69
75
70
        text = findViewById(R.id.text);
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
        unRegisterLayout = findViewById(R.id.unRegisterLayout);
79
        unRegisterLayout = findViewById(R.id.unRegisterLayout);
73
        text.setOnClickListener(v->{
80
        text.setOnClickListener(v->{
74
            if (state !=null && state.equals("1")){
81
            if (state !=null && state.equals("1")){
107
                Log.e("onResponse applyLogOutNet", response);
114
                Log.e("onResponse applyLogOutNet", response);
108
                String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
115
                String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
109
                if (rtnCode.equals("01")){
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
                }else{
118
                }else{
122
                    String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");
119
                    String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");
123
                    showDialog(rtnMsg);
120
                    showDialog(rtnMsg);
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
            @Override
153
            @Override
143
            public void onResponse(String response) {
154
            public void onResponse(String response) {
144
                Log.e("onResponse cancelLogout", response);
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
        );
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
     * @param state  0表示由UserCenterMoreActivity打开 1 表示从登录页面跳转过来
279
     * @param state  0表示由UserCenterMoreActivity打开 1 表示从登录页面跳转过来
222
     * */
280
     * */

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

316
                        saveUserInfo(data);
316
                        saveUserInfo(data);
317
                        MobclickAgent.onProfileSignIn(MainApplication.userId);
317
                        MobclickAgent.onProfileSignIn(MainApplication.userId);
318
                        showTextToast("登录成功");
318
                        showTextToast("登录成功");
319
                        setResult(RESULT_SUCCESS);
320
321
                        ProfileManager.getInstance().setCount(getApplicationContext(), 0);
322
                        MainApplication.count = 0;
323
                        finish();
319
                        quiryState();
324
                    } else if ("03".equals(rtnCode)) {
320
                    } else if ("03".equals(rtnCode)) {
325
                        showTextToast("登录超时,请重新登录");
321
                        showTextToast("登录超时,请重新登录");
326
                    } else if ("02".equals(rtnCode)) {
322
                    } else if ("02".equals(rtnCode)) {
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
    private void saveUserInfo(String info) {
366
    private void saveUserInfo(String info) {
339
        String userid = JsonUtils.getKeyResult(info, "userid");
367
        String userid = JsonUtils.getKeyResult(info, "userid");
340
        String nickname = JsonUtils.getKeyResult(info, "nickname");
368
        String nickname = JsonUtils.getKeyResult(info, "nickname");

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

35
    </com.zhy.autolayout.AutoRelativeLayout>
35
    </com.zhy.autolayout.AutoRelativeLayout>
36
36
37
    <LinearLayout
37
    <LinearLayout
38
38
        android:orientation="vertical"
39
        android:orientation="vertical"
39
        android:id="@+id/unSubmittedLayout"
40
        android:id="@+id/unSubmittedLayout"
40
        android:layout_width="match_parent"
41
        android:layout_width="match_parent"
165
    </LinearLayout>
166
    </LinearLayout>
166
167
167
    <LinearLayout
168
    <LinearLayout
168
        tools:visibility="visible"
169
        android:visibility="gone"
169
        android:visibility="gone"
170
        android:id="@+id/unRegisterLayout"
170
        android:id="@+id/unRegisterLayout"
171
        android:orientation="vertical"
171
        android:orientation="vertical"
188
            />
188
            />
189
189
190
        <TextView
190
        <TextView
191
            android:id="@+id/addTime"
191
            android:layout_marginTop="20dp"
192
            android:layout_marginTop="20dp"
192
            android:layout_gravity="center"
193
            android:layout_gravity="center"
193
            android:layout_width="wrap_content"
194
            android:layout_width="wrap_content"
197
            android:textSize="12sp"
198
            android:textSize="12sp"
198
            />
199
            />
199
        <TextView
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
            android:layout_marginTop="20dp"
214
            android:layout_marginTop="20dp"
201
            android:layout_gravity="center"
215
            android:layout_gravity="center"
202
            android:layout_width="wrap_content"
216
            android:layout_width="wrap_content"
203
            android:layout_height="wrap_content"
217
            android:layout_height="wrap_content"
204
            tools:text="审核中不能充值和开启充电,取消注销可继续使用"
218
            android:text="账号正式注销后,再次注册APP将为新注册账号,已注销的账号信息无法找回。"
205
            android:textColor="#ff0e0e0e"
219
            android:textColor="#ff0e0e0e"
206
            android:textSize="12sp"
220
            android:textSize="12sp"
207
            />
221
            />