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-head flex-between">
<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 class="record-progress">
@@ -44,7 +44,6 @@
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app';
import sheep from '@/sheep';
import { getAiShopPage } from '@/sheep/api/ai';
import { formatOrderStatus } from '@/sheep/hooks/useGoods';
const skuId = ref('');
const cover = ref('');
@@ -72,16 +71,19 @@
fetchList(false);
});
const formatMoney = (value) => {
const formatPercent = (value) => {
const num = Number(value);
if (!Number.isFinite(num)) return '0.00';
return num.toFixed(2);
};
const formatPercent = (value) => {
const num = Number(value);
if (!Number.isFinite(num)) return '0.00';
return num.toFixed(2);
const formatRecordStatus = (status) => {
const map = {
1: '已上架',
2: '进行中',
3: '已完成',
};
return map[Number(status)] || '';
};
const mapOrderToRecord = (order) => {
@@ -89,7 +91,8 @@
const firstItem = items[0] || {};
const titleText = firstItem?.spuName || order?.no || '-';
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 sumItemTotalRevenue = items.reduce((acc, cur) => acc + (Number(cur?.totalRevenue) || 0), 0);
const totalPrice = sumItemTotalPrice || (Number(order?.totalPrice ?? 0) || 0);
@@ -106,6 +109,7 @@
return {
id: order?.id,
title: titleText,
status,
statusText,
progress,
qty,
@@ -219,7 +223,26 @@
.record-status {
flex-shrink: 0;
font-size: 24rpx;
padding: 8rpx 16rpx;
border-radius: 999rpx;
line-height: 1;
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 {
+54 -3
View File
@@ -5,7 +5,7 @@
<view class="con" :style="{ paddingTop: paddingTop + 'px' }">
<view class="con_top flex-center ju-flex-start">
<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-else :src="`${$url}home/head.png`" mode="scaleToFill" />
</view>
@@ -120,6 +120,7 @@
import { ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick, computed } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import { getWallet } from '@/sheep/api/home/pay';
import UserApi from '@/sheep/api/member/user';
import OrderApi from '@/sheep/api/trade/order';
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 = () => {
sheep
.$store('user')
@@ -310,8 +357,7 @@
});
};
onShow(async () => {
let res = await getData();
getData();
getNumData();
});
</script>
@@ -358,6 +404,7 @@
height: 130rpx;
border-radius: 50%;
overflow: hidden;
position: relative;
image {
width: 100%;
@@ -365,6 +412,10 @@
}
}
.head-upload-entry {
box-shadow: 0 10rpx 24rpx rgba(0, 0, 0, 0.12);
}
.con_info {
margin-left: 24rpx;
display: flex;