This commit is contained in:
2025-12-09 18:38:26 +08:00
parent 086845dd16
commit 88d7530568
9 changed files with 67 additions and 42 deletions
@@ -175,7 +175,7 @@ class PayResultFragment : BaseFragment<FragmentPayResultBinding>() {
}
private fun loadUserInfo(item: MemberInfo) {
binding.ivHeadPic.load(R.mipmap.ic_launcher)
binding.ivHeadPic.load(item.faceUrl?.ifBlank { R.drawable.ic_avatar_default })
binding.tvUserName.text = item.name
val phone = item.phone ?: ""
@@ -40,6 +40,8 @@ data class MemberInfo(
val phone: String?,
//姓名
val name: String?,
//头像
val faceUrl: String?,
//充值余额
val topUpBalance: Double?,
//赠送余额
@@ -92,7 +94,7 @@ data class UserNutrition(
//肉蛋超量
val meatEggsExcess: String?=null,
)
//{"code":"00000","data":"{\"orderType\":0,\"orderPayFrom\":2,\"payType\":\"1\",\"paySuc\":0,\"totalFee\":0.01,\"orderCode\":\"1998193614899372032\",\"message\":\"支付成功\",\"payCode\":\"1998193614899372032508227\"}","msg":"成功","total":0}
data class PayResult(
val paySuc: String? = null
)
@@ -41,12 +41,13 @@ data class FoodInfo(
val meatEggs:Double? = null,
//推荐能量
val recommendCalorie: Double? = null,
//图片
var foodImg: String? = "",
//-----------------------------------
var score: Int = 0,
var isChecked: Boolean = false,
var photoUri: Uri? = null,
var foodImg: String? = "",
// @SerializedName("foodTypeAndRealIntakeVoList")
// val foodTypeAndRealIntakeVoList: List<FoodTypeAndRealIntakeVo>? = listOf(),
@@ -129,7 +129,7 @@ class ScanQrCodePayPresentation(
}
private fun loadUserInfo(item: MemberInfo) {
binding.ivHeadPic.load(R.mipmap.ic_launcher)
binding.ivHeadPic.load(item.faceUrl?.ifBlank { R.drawable.ic_avatar_default })
binding.tvUserName.text = item.name
val phone = item.phone ?: ""
@@ -98,8 +98,12 @@ class UserViewModel : BaseViewModel() {
SPUtil.getInstance().put(GlobalKey.KEY_FIRST_RUN, true)
withContext(Dispatchers.Default) {
val list: List<UserFaceModel> = response.data ?: emptyList()
val item = list.firstOrNull { it.userId == "1951105919342936066" }
Timber.tag(TAG).d("getUserFaceCache userId = ${item?.userId}")
if (list.isEmpty()) {
ToastUtils.showToast("查询人脸数据为空")
return@withContext
}
// val item = list.firstOrNull { it.userId == "1951105919342936066" }
// Timber.tag(TAG).d("getUserFaceCache userId = ${item?.userId}")
val faceEntity = list.map {
FaceEntity(it.userId, null, Base64.decode(it.faceFeatureStr))
}
@@ -384,7 +388,14 @@ class UserViewModel : BaseViewModel() {
Timber.tag(TAG).d("queryOrderState")
val response = repository.queryOrderState(orderNo = orderId)
if (parseResponse(response)) {
val orderState = response.data == "1"
val respData = response.data as? String
?: if (response.data is Any) {
GsonUtils.toJson(response.data)
} else {
""
}
val payResult = GsonUtils.fromJson(respData, PayResult::class.java)
val orderState = payResult?.paySuc == "1"
block(orderState)
} else {
block(false)
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

@@ -27,7 +27,7 @@
android:id="@+id/ivHeadPic"
android:layout_width="120dp"
android:layout_height="120dp"
android:src="@mipmap/ic_launcher"
android:src="@drawable/ic_avatar_default"
app:shapeAppearance="@style/CircleStyle"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@@ -121,7 +121,7 @@
android:id="@+id/ivHeadPic"
android:layout_width="84dp"
android:layout_height="84dp"
tools:src="@mipmap/ic_launcher"
android:src="@drawable/ic_avatar_default"
android:layout_marginTop="28dp"
app:shapeAppearance="@style/CircleStyle"
app:layout_constraintStart_toStartOf="parent"
@@ -2,6 +2,8 @@ package com.sw.plate.utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
@@ -30,18 +32,23 @@ public class ToastUtils {
* @param text the text
*/
public static void showToast(String text) {
Context context = App.getContext();
if (toast == null) {
View view = LayoutInflater.from(context).inflate(R.layout.toast_bg, null);
textCenterView = view.findViewById(R.id.toast_tv);
toast = new Toast(context);
toast.setGravity(Gravity.CENTER, 0, 20);
toast.setDuration(Toast.LENGTH_SHORT);
toast.setView(view);
}
runOnMainThread(()->{
Context context = App.getContext();
if (toast == null) {
View view = LayoutInflater.from(context).inflate(R.layout.toast_bg, null);
textCenterView = view.findViewById(R.id.toast_tv);
toast = new Toast(context);
toast.setGravity(Gravity.CENTER, 0, 20);
toast.setDuration(Toast.LENGTH_SHORT);
toast.setView(view);
}
textCenterView.setText(text);
toast.show();
});
}
textCenterView.setText(text);
toast.show();
public static void runOnMainThread(Runnable runnable) {
new Handler(Looper.getMainLooper()).post(runnable);
}
/**
@@ -50,32 +57,36 @@ public class ToastUtils {
* @param text the text
*/
public static void showToast(String text, int duration) {
Context context = App.getContext();
if (toast == null) {
View view = LayoutInflater.from(context).inflate(R.layout.toast_bg, null);
textCenterView = view.findViewById(R.id.toast_tv);
toast = new Toast(context);
toast.setGravity(Gravity.CENTER, 0, 20);
toast.setView(view);
}
runOnMainThread(()-> {
Context context = App.getContext();
if (toast == null) {
View view = LayoutInflater.from(context).inflate(R.layout.toast_bg, null);
textCenterView = view.findViewById(R.id.toast_tv);
toast = new Toast(context);
toast.setGravity(Gravity.CENTER, 0, 20);
toast.setView(view);
}
textCenterView.setText(text);
toast.setDuration(duration);
toast.show();
textCenterView.setText(text);
toast.setDuration(duration);
toast.show();
});
}
public static void showLongToast(String text) {
Context context = App.getContext();
if (toast == null) {
View view = LayoutInflater.from(context).inflate(R.layout.toast_bg, null);
textCenterView = view.findViewById(R.id.toast_tv);
toast = new Toast(context);
toast.setGravity(Gravity.TOP, 0, 20);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(view);
}
textCenterView.setText(text);
showMyToast(toast, 1000000 * 30);
runOnMainThread(()-> {
Context context = App.getContext();
if (toast == null) {
View view = LayoutInflater.from(context).inflate(R.layout.toast_bg, null);
textCenterView = view.findViewById(R.id.toast_tv);
toast = new Toast(context);
toast.setGravity(Gravity.TOP, 0, 20);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(view);
}
textCenterView.setText(text);
showMyToast(toast, 1000000 * 30);
});
}