提交10
This commit is contained in:
parent
b97dee2ccc
commit
97526598ea
|
@ -6,6 +6,7 @@ import com.example.myapplication.dao.ShouyeshuiguoResult;
|
|||
import com.example.myapplication.dao.UserInformationResult;
|
||||
import com.example.myapplication.dao.UserInformationResult2;
|
||||
import com.example.myapplication.dao.TwodimensionResult;
|
||||
import com.example.myapplication.dao.VipdataResult;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -33,4 +34,7 @@ public interface Api {
|
|||
@GET("system/goodsinformation/list")
|
||||
Call<GoodsinformationResult> getGoodsinformation(@Header("Authorization") String token);
|
||||
|
||||
@GET("system/vip/list")
|
||||
Call<VipdataResult> getVipdata(@Header("Authorization") String token);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,9 +2,12 @@ package com.example.myapplication;
|
|||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -25,7 +28,6 @@ import retrofit2.Callback;
|
|||
import retrofit2.Response;
|
||||
|
||||
public class MineFragment extends Fragment {
|
||||
|
||||
private HomeFragment.MyAdapter myAdapter;
|
||||
private List<UserInformationResult2.DataBean> list;
|
||||
|
||||
|
@ -133,6 +135,15 @@ public class MineFragment extends Fragment {
|
|||
Glide.with(getContext()).load(avatarUrl).into(imageView);
|
||||
}
|
||||
|
||||
|
||||
// 保存 nickName 和 avatar 到 SharedPreferences
|
||||
SharedPreferences userSharedPreferences = getActivity().getSharedPreferences("UserInformation", MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = userSharedPreferences.edit();
|
||||
editor.putString("nickName", user.nickName);
|
||||
editor.putString("avatar", avatarUrl);
|
||||
editor.apply();
|
||||
|
||||
|
||||
} else if (userInformationResult.code == 401) {
|
||||
Log.e("MineFragment", "Unauthorized access");
|
||||
} else {
|
||||
|
|
|
@ -1,18 +1,114 @@
|
|||
package com.example.myapplication;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.example.myapplication.Utils.RetrofitUtils;
|
||||
import com.example.myapplication.dao.UserInformationResult2;
|
||||
import com.example.myapplication.dao.VipdataResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class VipFragment extends Fragment {
|
||||
|
||||
private TextView textView37;
|
||||
private ImageView imageView5;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_vip, container, false);
|
||||
View view = inflater.inflate(R.layout.fragment_vip, container, false);
|
||||
|
||||
// 初始化其他TextView
|
||||
TextView textView24 = view.findViewById(R.id.textView24);
|
||||
TextView textView25 = view.findViewById(R.id.textView25);
|
||||
TextView textView26 = view.findViewById(R.id.textView26);
|
||||
TextView textView27 = view.findViewById(R.id.textView27);
|
||||
TextView textView28 = view.findViewById(R.id.textView28);
|
||||
TextView textView29 = view.findViewById(R.id.textView29);
|
||||
TextView textView30 = view.findViewById(R.id.textView30);
|
||||
TextView textView31 = view.findViewById(R.id.textView31);
|
||||
TextView textView32 = view.findViewById(R.id.textView32);
|
||||
TextView textView33 = view.findViewById(R.id.textView33);
|
||||
|
||||
// 初始化 textView37 和 imageView5
|
||||
textView37 = view.findViewById(R.id.textView37);
|
||||
imageView5 = view.findViewById(R.id.imageView5);
|
||||
|
||||
|
||||
// 从 SharedPreferences 读取数据
|
||||
SharedPreferences userSharedPreferences = getActivity().getSharedPreferences("UserInformation", MODE_PRIVATE);
|
||||
String nickName = userSharedPreferences.getString("nickName", "");
|
||||
String avatarUrl = userSharedPreferences.getString("avatar", "");
|
||||
|
||||
// 设置数据到 UI 组件
|
||||
textView37.setText(nickName);
|
||||
if (!avatarUrl.isEmpty()) {
|
||||
Glide.with(this).load(avatarUrl).into(imageView5);
|
||||
}
|
||||
|
||||
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("data", MODE_PRIVATE);
|
||||
String token = sharedPreferences.getString("token", "");
|
||||
Call<VipdataResult> vipdataResultCall =
|
||||
RetrofitUtils.getRetrofit("http://192.168.56.115:8080/").create(Api.class).getVipdata("Bearer " + token);
|
||||
vipdataResultCall.enqueue(new Callback<VipdataResult>() {
|
||||
@Override
|
||||
public void onResponse(Call<VipdataResult> call, Response<VipdataResult> response) {
|
||||
VipdataResult vipdataResult = response.body();
|
||||
if (vipdataResult != null) {
|
||||
if (vipdataResult.code == 200) {
|
||||
// 清空原有数据
|
||||
for (VipdataResult.RowsBean rowsBean : vipdataResult.rows) {
|
||||
// 将新数据添加到列表中
|
||||
textView24.setText(String.valueOf(rowsBean.totalallpeople));
|
||||
textView25.setText(String.valueOf(rowsBean.zhixituanzhang));
|
||||
textView26.setText(String.valueOf(rowsBean.xinzengtuanzhang));
|
||||
textView27.setText(String.valueOf(rowsBean.xinzengyonghu));
|
||||
textView28.setText(String.valueOf(rowsBean.dingdanzongshu));
|
||||
textView29.setText(String.valueOf(rowsBean.jinridingdan));
|
||||
textView30.setText(String.valueOf(rowsBean.shouhoudingdan));
|
||||
textView31.setText(String.valueOf(rowsBean.allshouyi));
|
||||
textView32.setText(String.valueOf(rowsBean.todayyongjin));
|
||||
textView33.setText(String.valueOf(rowsBean.todaylaxin));
|
||||
}
|
||||
} else if (vipdataResult.code == 401) {
|
||||
// 处理未授权的情况,例如提示用户登录
|
||||
Log.e("VipFragment", "Unauthorized access");
|
||||
} else {
|
||||
// 处理其他错误情况
|
||||
Log.e("VipFragment", "Error code: " + vipdataResult.code);
|
||||
}
|
||||
} else {
|
||||
// 处理响应为空的情况
|
||||
Log.e("VipFragment", "Response body is null");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<VipdataResult> call, Throwable t) {
|
||||
// 处理网络错误或其他异常
|
||||
t.printStackTrace();
|
||||
Log.e("VipFragment", "Network error: " + t.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
package com.example.myapplication.dao;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class VipdataResult {
|
||||
|
||||
@SerializedName("total")
|
||||
public Integer total;
|
||||
@SerializedName("rows")
|
||||
public List<RowsBean> rows;
|
||||
@SerializedName("code")
|
||||
public Integer code;
|
||||
@SerializedName("msg")
|
||||
public String msg;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class RowsBean {
|
||||
@SerializedName("createBy")
|
||||
public Object createBy;
|
||||
@SerializedName("createTime")
|
||||
public Object createTime;
|
||||
@SerializedName("updateBy")
|
||||
public Object updateBy;
|
||||
@SerializedName("updateTime")
|
||||
public Object updateTime;
|
||||
@SerializedName("remark")
|
||||
public Object remark;
|
||||
@SerializedName("id")
|
||||
public Integer id;
|
||||
@SerializedName("totalallpeople")
|
||||
public Integer totalallpeople;
|
||||
@SerializedName("zhixituanzhang")
|
||||
public Integer zhixituanzhang;
|
||||
@SerializedName("xinzengtuanzhang")
|
||||
public Integer xinzengtuanzhang;
|
||||
@SerializedName("xinzengyonghu")
|
||||
public Integer xinzengyonghu;
|
||||
@SerializedName("dingdanzongshu")
|
||||
public Integer dingdanzongshu;
|
||||
@SerializedName("jinridingdan")
|
||||
public Integer jinridingdan;
|
||||
@SerializedName("shouhoudingdan")
|
||||
public Integer shouhoudingdan;
|
||||
@SerializedName("allshouyi")
|
||||
public Integer allshouyi;
|
||||
@SerializedName("todayyongjin")
|
||||
public Integer todayyongjin;
|
||||
@SerializedName("todaylaxin")
|
||||
public Integer todaylaxin;
|
||||
@SerializedName("twodimensionid")
|
||||
public Integer twodimensionid;
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ import androidx.fragment.app.Fragment;
|
|||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
public class yindaoActivity extends AppCompatActivity {
|
||||
public class yindaoActivity extends AppCompatActivity {
|
||||
|
||||
private HomeFragment homeFragment;
|
||||
private FindFragment findFragment;
|
||||
|
@ -94,4 +94,5 @@ public class yindaoActivity extends AppCompatActivity {
|
|||
button.setSelected(button == selectedButton);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@
|
|||
android:layout_width="99dp"
|
||||
android:layout_height="29dp"
|
||||
android:gravity="center"
|
||||
android:text="39"
|
||||
android:text="DFSWA2"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="18dp"
|
||||
android:textStyle="bold"
|
||||
|
|
Loading…
Reference in New Issue