feat: ai店铺添加柱状图

This commit is contained in:
2026-06-25 11:10:18 +08:00
parent c8eb96b64c
commit a7f80af1de
7 changed files with 329 additions and 120 deletions
+6 -1
View File
@@ -36,4 +36,9 @@
## [1.5.0] - 2026-06-24 ## [1.5.0] - 2026-06-24
### 新增 ### 新增
- 添加收支明细页面 - 添加收支明细页面
- 我的店铺文案展示当前用户名称 - 我的店铺文案展示当前用户名称
## [1.5.1] - 2026-06-24
### 新增
- 修改我的店铺展示
- ai店铺-列表记录添加分页
+21 -7
View File
@@ -1,14 +1,15 @@
<template> <template>
<l-echart ref="chartRef"></l-echart> <l-echart ref="chartRef" class="chart"></l-echart>
</template> </template>
<script setup lang="ts"> <script setup>
import { onMounted, ref, onBeforeUnmount, nextTick, watch } from 'vue'; import { onMounted, ref, onBeforeUnmount, nextTick, watch } from 'vue';
import * as echarts from 'echarts'; import * as echarts from 'echarts';
const chartRef = ref(null) const chartRef = ref(null)
const myChart = ref(null) const myChart = ref(null)
let hasSetOption = false
const props = defineProps({ const props = defineProps({
options: { options: {
@@ -21,14 +22,19 @@
const initChart = async () => { const initChart = async () => {
if (!chartRef.value) return if (!chartRef.value) return
// 初始化echart if (!myChart.value) {
myChart.value = await chartRef.value.init(echarts) myChart.value = await chartRef.value.init(echarts)
}
// 默认获取容器尺寸 // 默认获取容器尺寸
myChart.value.resize(); myChart.value.resize();
// 设置true清空echart缓存 if (!hasSetOption) {
myChart.value?.setOption(props.options, true); myChart.value?.setOption(props.options, true);
hasSetOption = true
return
}
myChart.value?.setOption(props.options);
} }
@@ -55,6 +61,14 @@
onBeforeUnmount(() => { onBeforeUnmount(() => {
if (myChart.value) { if (myChart.value) {
echarts.dispose(myChart.value); echarts.dispose(myChart.value);
myChart.value = null;
} }
}); });
</script> </script>
<style scoped>
.chart {
width: 100%;
height: 100%;
}
</style>
+14 -1
View File
@@ -48,7 +48,8 @@
</view> </view>
</view> </view>
</view> </view>
<view class="flex-row ju-flex-end" v-if="props.index != 5"> <view class="discount-row flex-between" v-if="props.index != 5">
<view class="size24 c_999">{{ formatCreateTime(props.data.createTime) }}</view>
<view class="size24 c32">已优惠¥{{ fen2yuan(props.data.randomDiscountPrice) }}</view> <view class="size24 c32">已优惠¥{{ fen2yuan(props.data.randomDiscountPrice) }}</view>
</view> </view>
<view class="flex-row ju-flex-end" v-if="props.index != 5"> <view class="flex-row ju-flex-end" v-if="props.index != 5">
@@ -91,6 +92,7 @@
import card_orderBan from '@/components/card_orderBan/card_orderBan.vue'; import card_orderBan from '@/components/card_orderBan/card_orderBan.vue';
import AiOrderActionBar from '@/components/orderItem/AiOrderActionBar.vue'; import AiOrderActionBar from '@/components/orderItem/AiOrderActionBar.vue';
import AfterSaleApi from '@/sheep/api/trade/afterSale'; import AfterSaleApi from '@/sheep/api/trade/afterSale';
import sheep from '@/sheep';
import { import {
aiDelayedShipment, aiDelayedShipment,
aiPendingShipment, aiPendingShipment,
@@ -118,6 +120,13 @@
const onCopy = (no) => { const onCopy = (no) => {
proxy.$sheep.$helper.copyText(no); proxy.$sheep.$helper.copyText(no);
}; };
const formatCreateTime = (value) => {
if (!value) return '';
const s = sheep?.$helper?.timeFormat
? sheep.$helper.timeFormat(value, 'yyyy-mm-dd hh:MM:ss')
: String(value);
return s || '';
};
const onApply = () => { const onApply = () => {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
@@ -254,6 +263,10 @@
margin-bottom: 32rpx; margin-bottom: 32rpx;
} }
.discount-row {
margin-top: 8rpx;
}
.price { .price {
color: #ee0a24; color: #ee0a24;
font-size: 24rpx; font-size: 24rpx;
+2 -2
View File
@@ -2,8 +2,8 @@
"name" : "优购商城", "name" : "优购商城",
"appid" : "__UNI__8B19741", "appid" : "__UNI__8B19741",
"description" : "", "description" : "",
"versionName" : "1.4.9", "versionName" : "1.5.0",
"versionCode" : 149, "versionCode" : 150,
"transformPx" : false, "transformPx" : false,
"app-plus" : { "app-plus" : {
"privacy" : { "privacy" : {
+2 -2
View File
@@ -51,10 +51,10 @@
<span class="c_FF2D2D">*</span> <span class="c_FF2D2D">*</span>
{{ `提现时间为${config.brokerageWithdrawTime}` }} {{ `提现时间为${config.brokerageWithdrawTime}` }}
</view> </view>
<view> <!-- <view>
<span class="c_FF2D2D">*</span> <span class="c_FF2D2D">*</span>
一天(24小时)内只可提现1次 一天(24小时)内只可提现1次
</view> </view> -->
</view> </view>
</view> </view>
<view class="submit-btn" @click="onSubmit">提现</view> <view class="submit-btn" @click="onSubmit">提现</view>
+168 -107
View File
@@ -39,42 +39,14 @@
<image class="search-icon-white" src="/static/icon/search.svg" mode="aspectFit" /> <image class="search-icon-white" src="/static/icon/search.svg" mode="aspectFit" />
</view> </view>
</view> </view>
<view class="notice-card" v-if="mesArr.length && index === 0"> <view class="bar-rank-card" v-if="index === 0">
<view class="notice-marquee-viewport"> <scroll-view class="bar-scroll" scroll-x :show-scrollbar="false" enhanced>
<view <view class="bar-scroll__inner" :style="{ width: barChartWidth }">
class="notice-marquee-track" <card_echart :options="barChartOptions" />
:class="{ 'is-scroll': mesArr.length > 1 }"
:style="mesArr.length > 1 ? { '--marquee-duration': marqueeDuration } : {}"
>
<view class="notice-marquee-content">
<view
v-for="(line, i) in mesArr"
:key="line.id || i"
class="notice-item notice-marquee-item flex-center h100"
>
<view class="notice-icon flex-center shrink">
<uni-icons type="person-filled" color="#2556EC" size="16" />
</view>
<view class="notice-text lineOne" v-html="line.messageContent"></view>
</view>
</view>
<view class="notice-marquee-content" v-if="mesArr.length > 1" aria-hidden="true">
<view
v-for="(line, i) in mesArr"
:key="`dup-${line.id || i}`"
class="notice-item notice-marquee-item flex-center h100"
>
<view class="notice-icon flex-center shrink">
<uni-icons type="person-filled" color="#2556EC" size="16" />
</view>
<view class="notice-text lineOne" v-html="line.messageContent"></view>
</view>
</view>
</view> </view>
</view> </scroll-view>
</view> </view>
<!-- <view class="m-t-16 m-b-8" v-if="timeRound.length && index === 0">
<view class="m-t-16 m-b-8" v-if="timeRound.length && index === 0">
<scroll-view scroll-x class="time-scroll"> <scroll-view scroll-x class="time-scroll">
<view class="flex"> <view class="flex">
<view <view
@@ -88,7 +60,7 @@
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
</view> </view> -->
<view style="padding: 80rpx 0 120rpx" v-if="index === 1"> <view style="padding: 80rpx 0 120rpx" v-if="index === 1">
<view style="position: relative"> <view style="position: relative">
<view class="shop-summary-card"> <view class="shop-summary-card">
@@ -168,10 +140,11 @@
</template> </template>
<script setup> <script setup>
import { ref, watch, computed } from 'vue'; import { ref, watch, computed, nextTick } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app'; import { onLoad, onShow, onHide, onUnload } from '@dcloudio/uni-app';
import sheep from '@/sheep'; import sheep from '@/sheep';
import * as api from '@/sheep/api/ai/index'; import * as api from '@/sheep/api/ai/index';
import card_echart from '@/components/card_echart/card_echart.vue';
import card_pages from '@/components/card_pages/card_pages'; import card_pages from '@/components/card_pages/card_pages';
import card_payment from '@/components/card_payment/card_payment'; import card_payment from '@/components/card_payment/card_payment';
import aistore_tab1 from './components/aistore_tab1.vue'; import aistore_tab1 from './components/aistore_tab1.vue';
@@ -215,11 +188,120 @@
const timeRound = ref([]); const timeRound = ref([]);
const selectedTimeId = ref(null); const selectedTimeId = ref(null);
const navName = ref(''); const navName = ref('');
const mesArr = ref([]); const barRankList = ref([
const marqueeDuration = computed(() => { { id: 1, value: 88, avatar: '/static/head_null.png', color: '#FF6B6B' },
const n = Array.isArray(mesArr.value) ? mesArr.value.length : 0; { id: 2, value: 52, avatar: '/static/head_null.png', color: '#FFB020' },
const seconds = Math.max(14, n * 2); { id: 3, value: 120, avatar: '/static/head_null.png', color: '#2ED573' },
return `${seconds}s`; { id: 4, value: 76, avatar: '/static/head_null.png', color: '#1E90FF' },
{ id: 5, value: 76, avatar: '/static/head_null.png', color: '#A66BFF' },
{ id: 6, value: 66, avatar: '/static/head_null.png', color: '#A66BFF' },
{ id: 7, value: 16, avatar: '/static/head_null.png', color: '#A66BFF' },
{ id: 8, value: 86, avatar: '/static/head_null.png', color: '#A66BFF' },
]);
const barRankDisplayList = ref(barRankList.value.map((it) => ({ ...it })));
const barChartAnimatedOnce = ref(false);
let barIntroTimer = null;
const barChartWidth = computed(() => {
const list = Array.isArray(barRankList.value) ? barRankList.value : [];
if (list.length <= 6) return '100%';
return `${list.length * 120}rpx`;
});
const resetBarDisplay = () => {
barRankDisplayList.value = barRankList.value.map((it) => ({ ...it }));
};
const startBarIntroAnimation = async () => {
if (barChartAnimatedOnce.value) return;
if (barIntroTimer) {
clearTimeout(barIntroTimer);
barIntroTimer = null;
}
barRankDisplayList.value = barRankList.value.map((it) => ({ ...it, value: 0 }));
await nextTick();
barIntroTimer = setTimeout(() => {
resetBarDisplay();
barChartAnimatedOnce.value = true;
barIntroTimer = null;
}, 80);
};
const barChartOptions = computed(() => {
const list = Array.isArray(barRankDisplayList.value) ? barRankDisplayList.value : [];
const xData = list.map((_, i) => `Top${i + 1}`);
const barData = list.map((it) => ({
name: String(it?.id ?? ''),
value: Number(it?.value) || 0,
itemStyle: {
color: it?.color || '#3d5efb',
borderRadius: [0, 0, 0, 0],
},
}));
const avatarData = list.map((it) => ({
name: String(it?.id ?? ''),
value: Number(it?.value) || 0,
symbol: `image://${it?.avatar || '/static/head_null.png'}`,
}));
return {
animation: true,
animationDuration: 900,
animationEasing: 'cubicOut',
animationDurationUpdate: 900,
animationEasingUpdate: 'cubicOut',
grid: { left: 0, right: 0, top: 46, bottom: 22, containLabel: false },
xAxis: {
type: 'category',
data: xData,
axisLine: {
show: true,
lineStyle: {
color: 'rgba(255,255,255,0.45)',
width: 1,
},
},
axisTick: { show: false },
axisLabel: {
show: true,
color: 'rgba(255,255,255,0.85)',
fontSize: 10,
margin: 10,
},
},
yAxis: { type: 'value', show: false, min: 0 },
series: [
{
id: 'bars',
type: 'bar',
data: barData,
barWidth: '42%',
barCategoryGap: '42%',
universalTransition: true,
label: {
show: true,
position: 'inside',
color: '#ffffff',
fontSize: 12,
fontWeight: 700,
formatter: (p) => {
const v = Number(p?.value) || 0;
return v ? String(v) : '';
},
},
animationDelay: (idx) => idx * 140,
animationDelayUpdate: (idx) => idx * 140,
},
{
id: 'avatars',
type: 'pictorialBar',
data: avatarData,
symbolSize: [28, 28],
symbolPosition: 'end',
symbolOffset: [0, -34],
z: 10,
universalTransition: true,
animationDelay: (idx) => idx * 140,
animationDelayUpdate: (idx) => idx * 140,
},
],
};
}); });
function changeTimeRound(e) { function changeTimeRound(e) {
@@ -245,11 +327,6 @@
} }
}; };
const getMessageList = async () => {
const res = await api.getMessageList({ pageNo: 1, pageSize: 10 }).catch(() => ({ code: -1 }));
mesArr.value = res?.code === 0 ? res?.data || [] : [];
};
onLoad((options) => { onLoad((options) => {
const tab = Number(options?.tab); const tab = Number(options?.tab);
if (tab === 1) { if (tab === 1) {
@@ -323,7 +400,27 @@
} }
getSpuTimeList(); getSpuTimeList();
getCartList(); getCartList();
getMessageList(); if (index.value === 0) {
startBarIntroAnimation();
} else {
resetBarDisplay();
}
});
onHide(() => {
if (barIntroTimer) {
clearTimeout(barIntroTimer);
barIntroTimer = null;
}
resetBarDisplay();
});
onUnload(() => {
if (barIntroTimer) {
clearTimeout(barIntroTimer);
barIntroTimer = null;
}
resetBarDisplay();
}); });
const update = () => { const update = () => {
@@ -345,6 +442,21 @@
const height = ref(`${baseHeight}px`); const height = ref(`${baseHeight}px`);
const hasPaymentBar = ref(false); const hasPaymentBar = ref(false);
watch(
() => index.value,
(val) => {
if (val === 0) {
startBarIntroAnimation();
return;
}
if (barIntroTimer) {
clearTimeout(barIntroTimer);
barIntroTimer = null;
}
resetBarDisplay();
},
);
watch( watch(
() => hasPaymentBar.value, () => hasPaymentBar.value,
() => { () => {
@@ -554,70 +666,19 @@
filter: brightness(0) invert(1); filter: brightness(0) invert(1);
} }
.notice-card { .bar-rank-card {
margin-top: 18rpx; margin-top: 18rpx;
padding: 20rpx 40rpx; padding: 18rpx 24rpx 22rpx;
height: 300rpx;
} }
.notice-item { .bar-scroll {
height: 50rpx; width: 100%;
padding: 0 20rpx; height: 100%;
border-radius: 999rpx;
background: rgba(255, 255, 255, 0.95);
} }
.notice-icon { .bar-scroll__inner {
width: 34rpx; height: 100%;
height: 34rpx;
border-radius: 50%;
background: rgba(37, 86, 236, 0.12);
margin-right: 16rpx;
}
.notice-text {
// flex: 1;
width: 300rpx;
font-size: 22rpx;
color: #111111;
line-height: 50rpx;
}
.notice-marquee-viewport {
overflow: hidden;
height: 50rpx;
display: flex;
align-items: center;
border-radius: 30rpx;
}
.notice-marquee-track {
display: inline-flex;
align-items: center;
transform: translateX(0);
will-change: transform;
&.is-scroll {
animation: notice-marquee-move var(--marquee-duration, 16s) linear infinite;
}
}
.notice-marquee-content {
display: inline-flex;
align-items: center;
flex-shrink: 0;
}
.notice-marquee-item {
flex-shrink: 0;
margin-right: 20rpx;
}
@keyframes notice-marquee-move {
0% {
transform: translateX(0);
}
100% {
transform: translateX(-50%);
}
} }
.time-scroll { .time-scroll {
+116
View File
@@ -31,6 +31,41 @@
</view> </view>
<view class="pages"> <view class="pages">
<!-- <s-custom-navbarIndex /> --> <!-- <s-custom-navbarIndex /> -->
<view class="notice-card" v-if="mesArr.length">
<view class="notice-marquee-viewport">
<view
class="notice-marquee-track"
:class="{ 'is-scroll': mesArr.length > 1 }"
:style="mesArr.length > 1 ? { '--marquee-duration': marqueeDuration } : {}"
>
<view class="notice-marquee-content">
<view
v-for="(line, i) in mesArr"
:key="line.id || i"
class="notice-item notice-marquee-item flex-center h100"
>
<view class="notice-icon flex-center shrink">
<uni-icons type="person-filled" color="#2556EC" size="16" />
</view>
<view class="notice-text lineOne" v-html="line.messageContent"></view>
</view>
</view>
<view class="notice-marquee-content" v-if="mesArr.length > 1" aria-hidden="true">
<view
v-for="(line, i) in mesArr"
:key="`dup-${line.id || i}`"
class="notice-item notice-marquee-item flex-center h100"
>
<view class="notice-icon flex-center shrink">
<uni-icons type="person-filled" color="#2556EC" size="16" />
</view>
<view class="notice-text lineOne" v-html="line.messageContent"></view>
</view>
</view>
</view>
</view>
</view>
<s-banner <s-banner
v-if="template?.components[0]?.property.items?.length" v-if="template?.components[0]?.property.items?.length"
:data="template.components[0].property" :data="template.components[0].property"
@@ -88,6 +123,7 @@
import sheep from '@/sheep'; import sheep from '@/sheep';
import $share from '@/sheep/platform/share'; import $share from '@/sheep/platform/share';
import * as api from '@/sheep/api/index/index'; import * as api from '@/sheep/api/index/index';
import * as aiApi from '@/sheep/api/ai/index';
const HOME_DEFAULT_TAB_STORAGE_KEY = 'home.goods.defaultTabName'; const HOME_DEFAULT_TAB_STORAGE_KEY = 'home.goods.defaultTabName';
const defaultTabName = ref(''); const defaultTabName = ref('');
let template = ref({ let template = ref({
@@ -204,6 +240,19 @@
} }
}); });
}; };
const mesArr = ref([]);
const marqueeDuration = computed(() => {
const n = Array.isArray(mesArr.value) ? mesArr.value.length : 0;
const seconds = Math.max(14, n * 2);
return `${seconds}s`;
});
const getMessageList = async () => {
const res = await aiApi.getMessageList({ pageNo: 1, pageSize: 10 }).catch(() => ({ code: -1 }));
mesArr.value = res?.code === 0 ? res?.data || [] : [];
};
const getData = () => { const getData = () => {
// banner // banner
getBanner(); getBanner();
@@ -211,6 +260,7 @@
getproducttaglist(); getproducttaglist();
getnotification(); getnotification();
getappbanner(); getappbanner();
getMessageList();
}; };
onLoad((options) => { onLoad((options) => {
getData(); getData();
@@ -317,6 +367,72 @@
height: 52rpx; height: 52rpx;
} }
.notice-card {
margin-top: 18rpx;
margin-bottom: 18rpx;
padding: 20rpx 0;
}
.notice-item {
height: 50rpx;
padding: 0 20rpx;
border-radius: 999rpx;
background: rgba(242, 242, 242, 0.95);
}
.notice-icon {
width: 34rpx;
height: 34rpx;
border-radius: 50%;
background: rgba(37, 86, 236, 0.12);
margin-right: 16rpx;
}
.notice-text {
width: 300rpx;
font-size: 22rpx;
color: #111111;
line-height: 50rpx;
}
.notice-marquee-viewport {
overflow: hidden;
height: 50rpx;
display: flex;
align-items: center;
border-radius: 30rpx;
}
.notice-marquee-track {
display: inline-flex;
align-items: center;
transform: translateX(0);
will-change: transform;
&.is-scroll {
animation: notice-marquee-move var(--marquee-duration, 16s) linear infinite;
}
}
.notice-marquee-content {
display: inline-flex;
align-items: center;
flex-shrink: 0;
}
.notice-marquee-item {
flex-shrink: 0;
margin-right: 20rpx;
}
@keyframes notice-marquee-move {
0% {
transform: translateX(0);
}
100% {
transform: translateX(-50%);
}
}
.ai-store-entry { .ai-store-entry {
padding: 24rpx 28rpx; padding: 24rpx 28rpx;
margin-bottom: 22rpx; margin-bottom: 22rpx;