[*]
陈奇
2018-11-27 a45036d4003974f8e78eb819a932895291d677d6
app/src/main/java/com/moral/yunfushao/activity/LoginActivity.java
@@ -1,5 +1,6 @@
package com.moral.yunfushao.activity;
import android.animation.ObjectAnimator;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
@@ -20,6 +21,9 @@
import com.moral.yunfushao.httputils.HttpCallBack;
import com.moral.yunfushao.httputils.HttpUtils;
import com.moral.yunfushao.model.User;
import com.tencent.mm.opensdk.modelmsg.SendAuth;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import java.util.HashMap;
import java.util.Map;
@@ -29,9 +33,12 @@
 */
public class LoginActivity extends BaseActivity {
    private Button bt_sure;
    private TextView tv_forget,tv_register;
    private Button bt_sure, weixinlogin;
    private TextView tv_forget, tv_register;
    private EditText et_phone, et_pwd;
    private IWXAPI iwxapi;
    private ObjectAnimator animator;
    @Override
    protected void getBundleExtras(Bundle extras) {
@@ -41,7 +48,23 @@
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        StatusBarUtil.translucentStatusBar(LoginActivity.this);
        regToWx();
    }
    private void regToWx() {
        iwxapi = WXAPIFactory.createWXAPI(this, "app_id", true);
        iwxapi.registerApp("app_id");
    }
    private void sendReq() {
        //授权
        SendAuth.Req req = new SendAuth.Req();
        req.scope = "snsapi_userinfo";
        req.state = "wechat_sdk_demo_test";
        iwxapi.sendReq(req);
        System.out.println("chenqi fasongcehngqo");
    }
    @Override
    protected int getLayoutId() {
@@ -55,8 +78,25 @@
        tv_register = findView(R.id.tv_register);
        et_phone = findView(R.id.et_phone);
        et_pwd = findView(R.id.et_pwd);
        et_phone.setText("15950198162");
        et_pwd.setText("888888");
        weixinlogin = findView(R.id.weixinlogin);
//        et_phone.setText("18362724160");
//        et_pwd.setText("123456");
        initAnimator();
    }
    private void initAnimator() {
//        ObjectAnimator an = ObjectAnimator.ofFloat(bt_sure, "translationX", 500f, 0f);
//        an.start();
////        ObjectAnimator translationY = ObjectAnimator.ofFloat(bt_sure, "rotation", 360f, 0f);
//        ObjectAnimator scaleY = ObjectAnimator.ofFloat(bt_sure, "scaleY", 0f, 1f);
//        ObjectAnimator scaleX = ObjectAnimator.ofFloat(bt_sure, "scaleX", 0f, 1f);
//
//        AnimatorSet oo = new AnimatorSet();
//        oo.playTogether(scaleY, scaleX);
//        oo.setDuration(500);
//        oo.start();
    }
    @Override
@@ -64,6 +104,7 @@
        bt_sure.setOnClickListener(this);
        tv_forget.setOnClickListener(this);
        tv_register.setOnClickListener(this);
        weixinlogin.setOnClickListener(this);
    }
    @Override
@@ -73,7 +114,7 @@
    @Override
    protected void processClick(View view) {
        switch (view.getId()){
        switch (view.getId()) {
            case R.id.bt_sure:
                String userphone = et_phone.getText().toString().trim();
                String password = et_pwd.getText().toString().trim();
@@ -85,17 +126,24 @@
                    mToatUtils.showSingletonToast("请输入密码");
                    return;
                }
                login(userphone,password);
                login(userphone, password);
                break;
            case R.id.tv_forget:
                Intent intent = new Intent(LoginActivity.this,ForgetPasswordActivity.class);
                Intent intent = new Intent(LoginActivity.this, ForgetPasswordActivity.class);
                startActivity(intent);
                break;
            case R.id.tv_register:
                Intent intentRgister = new Intent(LoginActivity.this,RegisterActivity.class);
                Intent intentRgister = new Intent(LoginActivity.this, RegisterActivity.class);
                startActivity(intentRgister);
                break;
            case R.id.weixinlogin:
                weixinlogin();
                break;
        }
    }
    private void weixinlogin() {
        sendReq();
    }
    @Override
@@ -106,7 +154,7 @@
    private void login(String tel, final String pwd) {
        String url = API.LOGIN;
        Map<String, String> params = new HashMap<>();
        params.put("username", tel);
        params.put("phone", tel);
        params.put("password", pwd);
        HttpUtils.doPost(url, params, CacheMode.DEFAULT, true, new HttpCallBack() {
            @Override
@@ -115,13 +163,13 @@
                if (progressDialog.isShowing()) {
                    progressDialog.dismiss();
                }
                User user = FastJsonTools.getJson(res,User.class);
                if(user!=null){
                User user = FastJsonTools.getJson(res, User.class);
                if (user != null) {
                    MainApp.theApp.sharedPreferencesUtil.saveLoginInfo(user);
//                    MainApp.theApp.userId = user.get_id();
                    MainApp.theApp.userId = user.get_id();
                    Intent intent = new Intent(getApplicationContext(), MainActivity.class);
                    Bundle bundle = new Bundle();
                    bundle.putBoolean("islogin",true);
                    bundle.putBoolean("islogin", true);
                    intent.putExtras(bundle);
                    startActivity(intent);
                    finish();
@@ -135,7 +183,7 @@
            }
            @Override
            public void onFail(int errno,String s) {
            public void onFail(int errno, String s) {
                mToatUtils.showSingletonToast(s);
                if (progressDialog.isShowing()) {
                    progressDialog.dismiss();