feat: 添加修改头像入口、AI订单记录展示 状态

This commit is contained in:
2026-06-15 13:20:41 +08:00
parent f440b6c32b
commit 577c022ac0
2 changed files with 85 additions and 11 deletions
+31 -8
View File
@@ -12,7 +12,7 @@
<view class="record-card" v-for="(item, i) in recordList" :key="item.id || i"> <view class="record-card" v-for="(item, i) in recordList" :key="item.id || i">
<view class="record-head flex-between"> <view class="record-head flex-between">
<view class="record-title lineOne">{{ item.title }}</view> <view class="record-title lineOne">{{ item.title }}</view>
<!-- <view class="record-status">{{ item.statusText }}</view> --> <view class="record-status" :class="`status-${item.status}`">{{ item.statusText }}</view>
</view> </view>
<view class="record-progress"> <view class="record-progress">
@@ -44,7 +44,6 @@
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'; import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app';
import sheep from '@/sheep'; import sheep from '@/sheep';
import { getAiShopPage } from '@/sheep/api/ai'; import { getAiShopPage } from '@/sheep/api/ai';
import { formatOrderStatus } from '@/sheep/hooks/useGoods';
const skuId = ref(''); const skuId = ref('');
const cover = ref(''); const cover = ref('');
@@ -72,16 +71,19 @@
fetchList(false); fetchList(false);
}); });
const formatMoney = (value) => { const formatPercent = (value) => {
const num = Number(value); const num = Number(value);
if (!Number.isFinite(num)) return '0.00'; if (!Number.isFinite(num)) return '0.00';
return num.toFixed(2); return num.toFixed(2);
}; };
const formatPercent = (value) => { const formatRecordStatus = (status) => {
const num = Number(value); const map = {
if (!Number.isFinite(num)) return '0.00'; 1: '已上架',
return num.toFixed(2); 2: '进行中',
3: '已完成',
};
return map[Number(status)] || '';
}; };
const mapOrderToRecord = (order) => { const mapOrderToRecord = (order) => {
@@ -89,7 +91,8 @@
const firstItem = items[0] || {}; const firstItem = items[0] || {};
const titleText = firstItem?.spuName || order?.no || '-'; const titleText = firstItem?.spuName || order?.no || '-';
const qty = Number(firstItem?.count ?? 0) || 0; const qty = Number(firstItem?.count ?? 0) || 0;
const statusText = formatOrderStatus(order || {}); const status = Number(firstItem?.status ?? 0) || 0;
const statusText = formatRecordStatus(status);
const sumItemTotalPrice = items.reduce((acc, cur) => acc + (Number(cur?.totalPrice) || 0), 0); const sumItemTotalPrice = items.reduce((acc, cur) => acc + (Number(cur?.totalPrice) || 0), 0);
const sumItemTotalRevenue = items.reduce((acc, cur) => acc + (Number(cur?.totalRevenue) || 0), 0); const sumItemTotalRevenue = items.reduce((acc, cur) => acc + (Number(cur?.totalRevenue) || 0), 0);
const totalPrice = sumItemTotalPrice || (Number(order?.totalPrice ?? 0) || 0); const totalPrice = sumItemTotalPrice || (Number(order?.totalPrice ?? 0) || 0);
@@ -106,6 +109,7 @@
return { return {
id: order?.id, id: order?.id,
title: titleText, title: titleText,
status,
statusText, statusText,
progress, progress,
qty, qty,
@@ -219,7 +223,26 @@
.record-status { .record-status {
flex-shrink: 0; flex-shrink: 0;
font-size: 24rpx; font-size: 24rpx;
padding: 8rpx 16rpx;
border-radius: 999rpx;
line-height: 1;
color: #8a8a8a; color: #8a8a8a;
// background: #f3f4f6;
}
.status-1 {
color: #2563eb;
background: rgba(37, 99, 235, 0.1);
}
.status-2 {
color: #f97316;
background: rgba(249, 115, 22, 0.12);
}
.status-3 {
color: #16a34a;
background: rgba(22, 163, 74, 0.12);
} }
.record-progress { .record-progress {
+54 -3
View File
@@ -5,7 +5,7 @@
<view class="con" :style="{ paddingTop: paddingTop + 'px' }"> <view class="con" :style="{ paddingTop: paddingTop + 'px' }">
<view class="con_top flex-center ju-flex-start"> <view class="con_top flex-center ju-flex-start">
<view class="head_info"> <view class="head_info">
<view class="head"> <view class="head head-upload-entry" @click="openAvatarCrop">
<image v-if="dataInfo?.avatar" :src="dataInfo?.avatar" mode="scaleToFill" /> <image v-if="dataInfo?.avatar" :src="dataInfo?.avatar" mode="scaleToFill" />
<image v-else :src="`${$url}home/head.png`" mode="scaleToFill" /> <image v-else :src="`${$url}home/head.png`" mode="scaleToFill" />
</view> </view>
@@ -120,6 +120,7 @@
import { ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick, computed } from 'vue'; import { ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick, computed } from 'vue';
import { onShow } from '@dcloudio/uni-app'; import { onShow } from '@dcloudio/uni-app';
import { getWallet } from '@/sheep/api/home/pay'; import { getWallet } from '@/sheep/api/home/pay';
import UserApi from '@/sheep/api/member/user';
import OrderApi from '@/sheep/api/trade/order'; import OrderApi from '@/sheep/api/trade/order';
let { proxy } = getCurrentInstance(); let { proxy } = getCurrentInstance();
@@ -279,6 +280,52 @@
}); });
} }
}; };
const updateAvatar = async (avatar) => {
if (!avatar) return;
const res = await UserApi.updateUser({
...dataInfo.value,
avatar,
});
if (res.code !== 0) {
uni.showToast({
title: '头像更新失败',
icon: 'none',
});
return;
}
dataInfo.value.avatar = avatar;
getData();
};
const openAvatarCrop = () => {
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
success: (res) => {
const filePath = res?.tempFilePaths?.[0] || '';
const size = res?.tempFiles?.[0]?.size;
if (typeof size === 'number' && size > 1048576) {
uni.showToast({
title: '上传图片大小不能超过1MB',
icon: 'none',
});
return;
}
if (!filePath) return;
uni.navigateTo({
url: `/pages/public/avatarCrop?src=${encodeURIComponent(filePath)}`,
success: (navRes) => {
const eventChannel = navRes?.eventChannel;
if (!eventChannel) return;
eventChannel.on('success', ({ url }) => {
if (!url) return;
updateAvatar(url);
});
},
});
},
fail: () => {},
});
};
const getData = () => { const getData = () => {
sheep sheep
.$store('user') .$store('user')
@@ -310,8 +357,7 @@
}); });
}; };
onShow(async () => { onShow(async () => {
let res = await getData(); getData();
getNumData(); getNumData();
}); });
</script> </script>
@@ -358,6 +404,7 @@
height: 130rpx; height: 130rpx;
border-radius: 50%; border-radius: 50%;
overflow: hidden; overflow: hidden;
position: relative;
image { image {
width: 100%; width: 100%;
@@ -365,6 +412,10 @@
} }
} }
.head-upload-entry {
box-shadow: 0 10rpx 24rpx rgba(0, 0, 0, 0.12);
}
.con_info { .con_info {
margin-left: 24rpx; margin-left: 24rpx;
display: flex; display: flex;