赞
踩
vx :sredxc
regist.setOnClickListener(v -> {
Intent intent = new Intent(this, RegiestActivity.class);
startActivity(intent);
});
login.setOnClickListener(v -> {
if (user.getText().toString().isEmpty()){
Toast.makeText(this, "账号不可以为空!", Toast.LENGTH_SHORT).show();
}else if (pwd.getText().toString().isEmpty()){
Toast.makeText(this, "密码不可以为空!", Toast.LENGTH_SHORT).show();
}else {
JSONObject jsonObject=new JSONObject();
try {
jsonObject.put("username", user.getText().toString());
jsonObject.put("password", pwd.getText().toString());
} catch (JSONException e) {
e.printStackTrace();
}
mPresenter.startpostInfoJsonToken(Constant22.BASE_Login, LoginBean.class, jsonObject.toString(),"");
}
});
if(o instanceof LoginBean){
if(((LoginBean) o).getStatus()==200){
SPUtils.putString2SP("user",user.getText().toString());
SPUtils.putString2SP("pwd",pwd.getText().toString());
SPUtils.putString2SP("user_id",((LoginBean) o).getData().getUser_id()+"");
Toast.makeText(this, ((LoginBean) o).getMessage(), Toast.LENGTH_SHORT).show();
Intent intent = new Intent(ZhiWenActivity.this,StartActivity.class);
startActivity(intent);
finish();
}else {
Toast.makeText(this, ((LoginBean) o).getMessage(), Toast.LENGTH_SHORT).show();
}
}
holder.name.setText(list.get(position).getPname());
holder.remark.setText(list.get(position).getDesc());
holder.sum.setnumbet(list.get(position).getProduct_num());
holder.sum.setAddCall(new Addnet.AddCall() {
@Override
public void onClick(int number) {
shopCallBack.addin(1,position,number);
}
});
holder.price.setText(list.get(position).getPrice()+"元");
holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
shopCallBack.onClick(position);
return false;
}
});
holder.small_check.setChecked(list.get(position).isCheck());
holder.small_check.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean stu = list.get(position).isCheck();
shopCallBack.smallidnex(1,position,stu);
}
});
登录servlet
public class userLogin extends HttpServlet {
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//0、解决返回中文乱码问题
resp.setCharacterEncoding("UTF-8");
JSONObject web_dict = JsonObjectWeb.getJsonInfoDict(req);
String username = web_dict.getString("username");
String password = web_dict.getString("password");
User user = new User();//创建user对象
user.setUsername(username);
user.setPassword(password);
注册servlet
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//解决返回中文乱码问题
resp.setCharacterEncoding("UTF-8");
JSONObject web_dict = JsonObjectWeb.getJsonInfoDict(req);
String username = web_dict.getString("username");
String password = web_dict.getString("password");
User user = new User();//创建user对象
user.setUsername(username);
user.setPassword(password);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。