Files
kangyuan-mobile/pages/index/aiStore.vue
T
2026-06-02 10:15:26 +08:00

565 lines
14 KiB
Vue

<template>
<s-pages title="AI店铺" :pink_bg="false" navPreset="blue" tabbar="/pages/index/aiStore" :showLeftButton="false">
<view class="ai-store-page h100 flex-column">
<view class="top-area">
<view class="tab-header">
<view
v-for="(tab, i) in nav"
:key="tab.id"
class="tab-item"
:class="{ active: index === i }"
@click="navChange(i)"
>
{{ tab.name }}
</view>
<view class="tab-line" :style="{ left: index === 0 ? '25%' : '75%' }"></view>
</view>
<view class="search-wrap flex-center" v-if="index === 0">
<view class="search-input flex1 flex-center">
<uni-icons class="m-r-16" type="search" color="#9AA7C7" size="18" />
<uni-easyinput
class="flex1"
v-model="searchText"
type="text"
placeholder="搜索想要的商品"
:inputBorder="false"
:styles="{ color: '#333', fontSize: '28rpx' }"
placeholderStyle="color:#9AA7C7;font-size:28rpx;"
@blur="search"
@clear="clearSearch"
/>
</view>
<view class="search-btn flex-center" @click="search">
<uni-icons type="search" color="#FFFFFF" size="18" />
</view>
</view>
<view class="notice-card" v-if="mesArr.length && index === 0">
<maoScroll
:data="mesArr"
:lineHeight="60"
:animation="1000"
:animationScroll="800"
:showNum="3"
:mt="12"
>
<template #default="{ line }">
<view class="notice-item flex-center h100">
<view class="flex-center">
<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>
</template>
</maoScroll>
</view>
<view class="m-t-16 m-b-8" v-if="timeRound.length && index === 0">
<scroll-view scroll-x class="time-scroll">
<view class="flex">
<view
v-for="(item, i) in timeRound"
:key="item.id || i"
class="timeNav m-r-20"
:class="{ activeTime: selectedTimeId === item.id }"
@click="changeTimeRound(item, i)"
>
{{ item.name }}
</view>
</view>
</scroll-view>
</view>
<view style="padding: 120rpx 0" v-if="index === 1&&false">
<view style="position: relative">
<view class="shop-summary-card">
<view class="shop-summary-top flex-row">
<view class="shop-summary-icon-wrap shrink flex-center">
<image class="shop-summary-icon" src="/static/index/shop1.png" mode="aspectFit" />
</view>
<view class="shop-summary-info flex1">
<view class="shop-summary-title">{{ shopSummary.title }}</view>
<view class="shop-summary-id">ID:{{ shopSummary.id }}</view>
</view>
</view>
<view class="shop-summary-bottom" v-if="index === 1">
<view class="shop-summary-metrics flex-center">
<view class="metric flex1">
<view class="metric-label">总收益</view>
<view class="metric-value">{{ formatAmount(shopSummary.totalEarnings) }}</view>
</view>
<view class="metric-divider"></view>
<view class="metric flex1">
<view class="metric-label">店铺数量</view>
<view class="metric-value">{{ shopSummary.shopCount }}</view>
</view>
<view class="metric-divider"></view>
<view class="metric flex1">
<view class="metric-label">店铺等级</view>
<view class="metric-value">{{ shopSummary.level }}</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
<!-- :style="{ marginTop: index === 1 ? '150rpx' : '0' }" -->
<view class="list-wrap flex1" >
<card_pages
ref="pageCommodity"
:navList="nav"
:currentTab="index"
@upCallback="getData"
:height="height"
:oneShow="true"
>
<template #content>
<aistore_tab1
v-if="index === 0"
:list="dataList"
@addCar="addCar"
@update="update"
@shipment="shipment"
/>
<aistore_tab2
v-if="index === 1"
:list="dataList"
:source="index"
@addCar="addCar"
@update="update"
@shipment="shipment"
/>
</template>
</card_pages>
</view>
</view>
<view v-if="payShow">
<card_payment
ref="paymentRef"
@updataList="clearSearch"
@updatePrice="updatePrice"
:addShow="addShow"
:minSalesCountShow="navName === '折扣区'"
:bottomOffset="tabbarBottomOffset"
/>
</view>
</s-pages>
</template>
<script setup>
import { ref, watch } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import * as api from '@/sheep/api/ai/index';
import card_pages from '@/components/card_pages/card_pages';
import card_payment from '@/components/card_payment/card_payment';
import maoScroll from '@/components/mao-scroll/mao-scroll';
import aistore_tab1 from './components/aistore_tab1.vue';
import aistore_tab2 from './components/aistore_tab2.vue';
const searchText = ref('');
const search = () => {
pageCommodity.value?.downCallback();
};
const clearSearch = () => {
searchText.value = '';
pageCommodity.value?.downCallback();
};
const timeRound = ref([]);
const selectedTimeId = ref(null);
const navName = ref('');
const mesArr = ref([]);
function changeTimeRound(e) {
navName.value = e.name;
selectedTimeId.value = e?.id ?? null;
pageCommodity.value?.downCallback();
}
function getSpuTimeList() {
api.getSpuTimeList({}).then((res) => {
if (res.code === 0) {
timeRound.value = res.data || [];
selectedTimeId.value = timeRound.value?.[0]?.id ?? null;
navName.value = timeRound.value?.[0]?.name ?? '';
}
});
}
const getCartList = async () => {
const res = await api.getShopCartList({});
if (res.code === 0) {
payShow.value = Boolean(res.data.length || addShow.value);
}
};
const getMessageList = async () => {
const res = await api.getMessageList({ pageNo: 1, pageSize: 10 }).catch(() => ({ code: -1 }));
mesArr.value = res?.code === 0 ? res?.data || [] : [];
};
onShow(() => {
getSpuTimeList();
getCartList();
getMessageList();
});
const update = () => {
pageCommodity.value?.downCallback();
};
const system = uni.getSystemInfoSync();
const tabbarBottomOffset = uni.upx2px(100);
const paymentBarReserve = uni.upx2px(148);
const baseHeight =
system.windowHeight -
system.statusBarHeight -
uni.upx2px(88) -
uni.upx2px(76) -
uni.upx2px(48) -
uni.upx2px(20);
const index = ref(0);
const height = ref(`${baseHeight}px`);
const payShow = ref(false);
const addShow = ref(false);
watch(
() => payShow.value,
() => {
const extra = payShow.value ? paymentBarReserve : 0;
height.value = `${baseHeight - extra}px`;
},
{ immediate: true },
);
const nav = ref([
{ name: '选品广场', id: 1 },
{ name: '我的店铺', id: 2 },
]);
const pageCommodity = ref(null);
const dataList = ref([]);
const getData = async (mescroll) => {
if (mescroll?.dataObj?.index !== index.value) return;
let res = null;
if (index.value) {
res = await api.getOrderPage({
pageNo: mescroll?.num || 1,
pageSize: mescroll?.size || 10,
keyWord: searchText.value,
});
} else {
res = await api.getSpuPage({
pageNo: mescroll?.num || 1,
pageSize: mescroll?.size || 10,
keyWord: searchText.value,
timeId: selectedTimeId.value,
...mescroll.params,
});
}
if (res.code !== 0) {
pageCommodity.value?.getState(false);
return;
}
let curPageData = [];
if (index.value) {
const list = res.data.list || [];
const arr = [];
list.forEach((e) => {
e.items1 = JSON.parse(JSON.stringify(e.items));
if (e?.items?.length) {
e.items.forEach((item) => {
item.skuArr = item.items;
item.status = e.status;
item.id = item.spuId;
item.spuId = e.payOrderId;
item.shoppingPlazaId = e.roundTimeId;
item.items1 = e.items1;
arr.push(item);
});
}
});
if (arr.length) {
arr.forEach((e) => {
if (e.skuArr && e.skuArr.length) {
e.skuArr.forEach((item) => {
item.propertyText = '';
if (item?.properties) {
item.properties.forEach((e1) => {
item.propertyText += e1.valueName + ' ';
});
}
});
}
});
}
curPageData = arr;
} else {
curPageData = res.data?.list || [];
}
if (mescroll?.num === 1) dataList.value = [];
dataList.value = dataList.value.concat(curPageData);
pageCommodity.value?.getState(true, curPageData.length);
};
const paymentRef = ref(null);
const addCar = (data) => {
payShow.value = true;
addShow.value = true;
setTimeout(() => {
paymentRef.value?.addCar(data);
}, 500);
};
const navChange = (i) => {
index.value = i;
dataList.value = [];
pageCommodity.value?.downCallback();
payShow.value = !index.value;
};
const updatePrice = (val) => {
addShow.value = val;
getCartList();
};
function shipment() {
pageCommodity.value?.downCallback();
}
const shopSummary = ref({
title: '我的店铺',
id: '123726492',
totalEarnings: 26873.8,
shopCount: 12,
level: 'LV.3',
});
const formatAmount = (value) => {
const num = Number(value);
if (!Number.isFinite(num)) return '0.00';
const fixed = num.toFixed(2);
const [intPart, decPart] = fixed.split('.');
const withComma = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
return `${withComma}.${decPart}`;
};
</script>
<style lang="scss" scoped>
.ai-store-page {
min-height: 100vh;
}
.top-area {
padding: 24rpx 24rpx;
background: #2556ec;
border-radius: 0 0 30rpx 30rpx;
}
.tab-header {
position: relative;
display: flex;
justify-content: center;
margin-top: 12rpx;
}
.tab-item {
width: 50%;
text-align: center;
font-size: 34rpx;
line-height: 48rpx;
padding: 16rpx 0 22rpx;
color: rgba(255, 255, 255, 0.7);
&.active {
color: #ffffff;
font-weight: 700;
}
}
.tab-line {
position: absolute;
bottom: 6rpx;
width: 72rpx;
height: 6rpx;
background: #fff;
border-radius: 6rpx;
transform: translateX(-50%);
transition: left 0.25s ease;
}
.search-wrap {
margin-top: 22rpx;
padding: 0 10rpx;
}
.search-input {
height: 76rpx;
background: #ffffff;
border-radius: 40rpx;
padding: 0 28rpx;
}
.search-btn {
width: 76rpx;
height: 76rpx;
margin-left: 18rpx;
border-radius: 38rpx;
background: linear-gradient(to bottom right, #2c8cfa 0%, #3d5efb 100%);
}
.notice-card {
margin-top: 18rpx;
padding: 20rpx 40rpx;
}
.notice-item {
height: 50rpx;
padding: 0 24rpx;
border-radius: 999rpx;
background: rgba(255, 255, 255, 0.95);
}
.notice-icon {
width: 34rpx;
height: 34rpx;
border-radius: 50%;
background: rgba(37, 86, 236, 0.12);
margin-right: 16rpx;
}
.notice-text {
flex: 1;
font-size: 22rpx;
color: #111111;
line-height: 60rpx;
}
.time-scroll {
width: 100%;
white-space: nowrap;
}
.timeNav {
display: inline-flex;
align-items: center;
height: 56rpx;
padding: 0 22rpx;
border-radius: 28rpx;
font-size: 28rpx;
color: rgba(255, 255, 255, 0.85);
background: rgba(255, 255, 255, 0.15);
}
.activeTime {
color: #2556ec;
background: #ffffff;
font-weight: 700;
}
.list-wrap {
margin-top: 18rpx;
background: #f1f5ff;
border-radius: 30rpx 30rpx 0 0;
padding: 0 24rpx;
overflow: hidden;
}
:deep(.ai-button1) {
background: linear-gradient(to bottom right, #2c8cfa 0%, #3d5efb 100%) !important;
}
.shop-summary-card {
width: 94% !important;
border-radius: 26rpx;
overflow: hidden;
position: absolute;
top: -60rpx;
left: 3%;
width: 100%;
box-sizing: border-box;
box-shadow: 0 8rpx 22rpx rgba(38, 107, 246, 0.45);
background: linear-gradient(135deg, #2c8cfa 0%, #3d5efb 100%);
}
.shop-summary-top {
padding: 30rpx 28rpx;
// background: linear-gradient(135deg, #2c8cfa 0%, #3d5efb 100%);
}
.shop-summary-icon-wrap {
width: 88rpx;
height: 88rpx;
border-radius: 24rpx;
background: rgba(255, 255, 255, 0.2);
backdrop-filter: blur(8rpx);
margin-right: 20rpx;
}
.shop-summary-icon {
width: 54rpx;
height: 54rpx;
}
.shop-summary-title {
font-size: 34rpx;
font-weight: 700;
color: #ffffff;
line-height: 44rpx;
}
.shop-summary-id {
margin-top: 6rpx;
font-size: 24rpx;
color: rgba(255, 255, 255, 0.85);
line-height: 32rpx;
}
.shop-summary-bottom {
background: rgba(255, 255, 255, 0.96);
padding: 22rpx 18rpx;
border-radius: 30rpx 30rpx 0 0;
// position: relative;
}
.shop-summary-metrics {
align-items: stretch;
// position: absolute;
}
.metric {
text-align: center;
}
.metric-label {
font-size: 24rpx;
color: #2c63ff;
line-height: 34rpx;
}
.metric-value {
margin-top: 10rpx;
font-size: 40rpx;
font-weight: 800;
color: #111111;
line-height: 44rpx;
}
.metric-divider {
width: 1rpx;
background: rgba(155, 170, 199, 0.55);
margin: 12rpx 0;
}
</style>