diff --git a/pages/index/listRecord.vue b/pages/index/listRecord.vue index 98afaed..ebde73b 100644 --- a/pages/index/listRecord.vue +++ b/pages/index/listRecord.vue @@ -12,7 +12,7 @@ {{ item.title }} - + {{ item.statusText }} @@ -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 { diff --git a/pages/index/user.vue b/pages/index/user.vue index 88d62fb..b4583ca 100644 --- a/pages/index/user.vue +++ b/pages/index/user.vue @@ -5,7 +5,7 @@ - + @@ -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(); }); @@ -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;