Commit d19e7154 authored by david's avatar david Committed by 杨秀秀

修改图片

parent 9f9b021e
...@@ -15,6 +15,16 @@ object LocalData { ...@@ -15,6 +15,16 @@ object LocalData {
SPUtils.getInstance().clear() SPUtils.getInstance().clear()
} }
@JvmStatic
fun saveToken(token:String) {
SPUtils.getInstance().put("token",token)
}
@JvmStatic
fun getToken() :String{
return SPUtils.getInstance().getString("token")
}
/** /**
* 存储用户信息 * 存储用户信息
*/ */
......
...@@ -30,6 +30,7 @@ import me.goldze.mvvmhabit.binding.command.BindingAction; ...@@ -30,6 +30,7 @@ import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand; import me.goldze.mvvmhabit.binding.command.BindingCommand;
import me.goldze.mvvmhabit.http.ApiDisposableObserver; import me.goldze.mvvmhabit.http.ApiDisposableObserver;
import me.goldze.mvvmhabit.utils.RxUtils; import me.goldze.mvvmhabit.utils.RxUtils;
import me.goldze.mvvmhabit.utils.StringUtils;
import me.goldze.mvvmhabit.utils.ToastUtils; import me.goldze.mvvmhabit.utils.ToastUtils;
public class LoginViewModel extends BaseViewModel<LoginRequest> { public class LoginViewModel extends BaseViewModel<LoginRequest> {
...@@ -44,6 +45,16 @@ public class LoginViewModel extends BaseViewModel<LoginRequest> { ...@@ -44,6 +45,16 @@ public class LoginViewModel extends BaseViewModel<LoginRequest> {
super(application, model); super(application, model);
} }
@Override
public void onCreate() {
super.onCreate();
String token = LocalData.getToken();
if (!StringUtils.isEmpty(token)) {
Interceptor_TOKEN = token;
getuserInfo();
}
}
//跳转开店页面 //跳转开店页面
public BindingCommand goMerchantEnter = new BindingCommand(new BindingAction() { public BindingCommand goMerchantEnter = new BindingCommand(new BindingAction() {
@Override @Override
...@@ -162,7 +173,7 @@ public class LoginViewModel extends BaseViewModel<LoginRequest> { ...@@ -162,7 +173,7 @@ public class LoginViewModel extends BaseViewModel<LoginRequest> {
}).subscribe(new ApiDisposableObserver<UserInfoBean>() { }).subscribe(new ApiDisposableObserver<UserInfoBean>() {
@Override @Override
public void onSuccess(UserInfoBean resultBean) { public void onSuccess(UserInfoBean resultBean) {
LocalData.saveToken(Interceptor_TOKEN);
//将用户信息存储到本地 //将用户信息存储到本地
LocalData.saveUser(resultBean.getUser()); LocalData.saveUser(resultBean.getUser());
dismissDialog(); dismissDialog();
......
...@@ -118,7 +118,7 @@ public class SettingsViewModel extends BaseViewModel<SettingsRequest> { ...@@ -118,7 +118,7 @@ public class SettingsViewModel extends BaseViewModel<SettingsRequest> {
public BindingCommand clearCache = new BindingCommand(new BindingAction() { public BindingCommand clearCache = new BindingCommand(new BindingAction() {
@Override @Override
public void call() { public void call() {
ToastUtils.showShort("清理完成"); ToastUtils.showShort("清除缓存成功");
} }
}); });
//跳转开店页面 //跳转开店页面
......
...@@ -188,14 +188,12 @@ ...@@ -188,14 +188,12 @@
android:textColor="#FF222222" android:textColor="#FF222222"
android:text="清除缓存"/> android:text="清除缓存"/>
<TextView <ImageView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:textSize="16sp" android:src="@mipmap/home_icon_r_jiantou"/>
android:textColor="#FF757575"
android:text="0.0M"/>
</RelativeLayout> </RelativeLayout>
<View <View
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment