最近写的两个项目,娘的下周单位项目的那个需求还不知道怎么写呢‘’
也不知道写的对不对,都是二手项目,我看下登录的时候都返回什么值
登录项目A
返回的数据如下
{
"userid": "940",
"password": "e10adc3949ba59abbe56e057f20f883e",
"openid": "",
"nickname": "m2613",
"sex": "1",
"city": null,
"country": null,
"province": null,
"language": null,
"headimgurl": null,
"subscribe_time": null,
"phone": "15289488613",
"company": null,
"company_name": null,
"profession": null,
"inputtime": "1509804482",
"updatetime": "1509804482",
"logintype": "0",
"device": "",
"status": null,
"key": "a04a43790b894451a1e5acf3ecb655f8"
}
我们保存了
editor.putString("userid", user.getUserid());
editor.putString("key", user.getKey());
登录的时候我们传递了
RequestBody body = new FormBody.Builder().add("phone",phone).add("password",pwd)
.add("client", Constant.client).add("logintype", String.valueOf(Constant.login))
.add("device",imei).build();
这个imei
/**
* Created by Administrator on 2016/10/29.
* 获取手机的唯一标识
*/
public class ImeiUtil {
public static String getIMEI(Context context){
TelephonyManager TelephonyMgr = (TelephonyManager)context.getSystemService(TELEPHONY_SERVICE);
return TelephonyMgr.getDeviceId();
}
}
logintype 是登录状态,在线是1,不在线是0 当初设计的目的是为了,防止二次登录
好了,这个项目就先看到这个,去隔壁看下另外一个正在写的二手代码,
菜鸡程序员表示,写二手代码,心里还是不好受的, 而且自己会的也有限,写起来有些吃力
主要是改坏了,不好改回来这不是
Map<String, String> map = new HashMap<>();
map.put("username", account);
map.put("mark", "1");
map.put("code", veify);
map.put("sign", ConfigConstants.SIGN);
mark 1是android 2是ios
veify是验证码,我用的是短信验证登录
SIGN是
public static final String SIGN = GetTime.getMd5Sign();
public static String getMd5Sign() {
SimpleDateFormat dff = new SimpleDateFormat("yyyy-MM-dd");
dff.setTimeZone(TimeZone.getTimeZone("GMT+08"));
String ee = dff.format(new Date());
try {
parse = dff.parse(ee);
s = String.valueOf(parse.getTime()).substring(0, 10) + "YYXC65474yyxc";
} catch (ParseException e) {
e.printStackTrace();
}
return MD5Util.MD5(s);
}
登录的时候合后台服务器对比,生成一个以当前日期+随机数的一个MD5值,如果一样予以登录
登陆成功后,返回
{
status='success',
code='2000',
msg='登录成功',
uid='319',
token='6718f8490c981821864817cda8c627c7641fb237',
avatar='AVA',
nickname='学员917585',
recommend_code='59cda6833f036',
tel='15289472613',
mark='2'
}
我们存储了
SharedPreferencesUtil.putString(getActivity(), "uid", loginEntity.uid);
SharedPreferencesUtil.putString(getActivity(), "token", loginEntity.token);
SharedPreferencesUtil.putString(getActivity(), "nickname", loginEntity.nickname);
SharedPreferencesUtil.putString(getActivity(), "recommend_code", loginEntity.recommend_code);
SharedPreferencesUtil.putString(getActivity(), "tel", loginEntity.tel);
SharedPreferencesUtil.putString(getActivity(), "avatar", loginEntity.avatar);
SharedPreferencesUtil.putBoolean(getActivity(), "isLogin", true);
SharedPreferencesUtil.putString(getActivity(),"mark",loginEntity.mark);