细节优化

This commit is contained in:
kron
2025-07-30 10:25:58 +08:00
parent 1e4ce52a93
commit d7306db2dd
5 changed files with 40 additions and 7 deletions

View File

@@ -59,7 +59,7 @@ const onPractiseLoading = async (page) => {
<Container title="我的成长脚印" overflow="hidden">
<view class="tabs">
<view
v-for="(rankType, index) in ['排位赛', '好友约战', '箭馆练习']"
v-for="(rankType, index) in ['排位赛', '好友约战', '个人练习']"
:key="index"
:style="{
color: index === selectedIndex ? '#000' : '#fff',

View File

@@ -1,9 +1,9 @@
<script setup>
import { ref, onMounted } from "vue";
import { ref, onMounted, onUnmounted } from "vue";
import Container from "@/components/Container.vue";
import SButton from "@/components/SButton.vue";
import { payOrderAPI, cancelOrderListAPI, getHomeData } from "@/apis";
import { orderStatusNames, getStatusColor } from "@/constants";
import { orderStatusNames, getStatusColor, MESSAGETYPES } from "@/constants";
import useStore from "@/store";
const store = useStore();
const { updateUser } = store;
@@ -11,9 +11,27 @@ const { updateUser } = store;
const data = ref({});
const loading = ref(false);
async function onReceiveMessage(messages = []) {
messages.forEach((msg) => {
if (
msg.constructor === MESSAGETYPES.PaySuccess &&
data.value.orderId === msg.orderID
) {
data.value.orderStatus = 4;
data.value.paymentTime = msg.payTime;
uni.setStorageSync("order", data.value);
}
});
}
onMounted(() => {
const order = uni.getStorageSync("order");
data.value = order || {};
uni.$on("socket-inbox", onReceiveMessage);
});
onUnmounted(() => {
uni.$off("socket-inbox", onReceiveMessage);
});
const goPay = async () => {
@@ -46,6 +64,7 @@ const goPay = async () => {
const cancelOrder = async () => {
const result = await cancelOrderListAPI(data.value.orderId);
data.value = result;
uni.setStorageSync("order", result);
};
</script>

View File

@@ -1,5 +1,6 @@
<script setup>
import { ref } from "vue";
import { ref, onMounted } from "vue";
import { onShow } from "@dcloudio/uni-app";
import Container from "@/components/Container.vue";
import ScrollList from "@/components/ScrollList.vue";
import { getOrderListAPI } from "@/apis";
@@ -27,6 +28,19 @@ const onLoading = async (page) => {
}
return result.length;
};
onMounted(() => {
uni.removeStorageSync("order");
});
onShow(() => {
const order = uni.getStorageSync("order");
list.value.forEach((item, index) => {
if (item.orderId === order.orderId) {
list.value[index] = order;
}
});
});
</script>
<template>