init
This commit is contained in:
@@ -0,0 +1,365 @@
|
||||
<template>
|
||||
<s-pages title="AI店铺" :goLeft="false" @onClickLeft="onClickLeft">
|
||||
<view class="p-x-32 h100 flex-column">
|
||||
<view class="search flex-center m-t-48 m-b-56">
|
||||
<view class="searchLeft flex1 flex-center p-l-40 p-r-40">
|
||||
<uni-icons class="m-r-20" type="search" color="#8F8F8F" size="" />
|
||||
<uni-easyinput
|
||||
class="flex1"
|
||||
v-model="searchText"
|
||||
type="text"
|
||||
placeholder="请搜索想要的商品"
|
||||
:inputBorder="false"
|
||||
@blur="search"
|
||||
@clear="clearSearch"
|
||||
placeholderStyle="color: #D3D3D3;font-size: 28rpx;"
|
||||
:styles="{ color: '', fontSize: '28rpx' }"
|
||||
/>
|
||||
</view>
|
||||
<view class="m-l-24" @click="search">搜索</view>
|
||||
</view>
|
||||
<view class="flex1">
|
||||
<card_pages
|
||||
ref="pageCommodity"
|
||||
:navList="nav"
|
||||
:currentTab="index"
|
||||
@upCallback="getData"
|
||||
:height="height + 'px'"
|
||||
:oneShow="true"
|
||||
>
|
||||
<template #nav>
|
||||
<view class="flex-center ju-flex-start">
|
||||
<view
|
||||
v-for="(tab, i) in nav"
|
||||
:key="tab.id"
|
||||
class="m-r-32 navItem flex-center flex-column size28 line32 c28"
|
||||
:class="{ active: index == i, c29: index == i }"
|
||||
@click="navChange(i)"
|
||||
>
|
||||
<view class="">
|
||||
{{ tab.name }}
|
||||
</view>
|
||||
<view class="navIcon p-b-10">
|
||||
<image class="w100" :src="$ygUrl + 'ai_index_current.png'" mode="widthFix" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="m-b-20" v-if="timeRound.length && index === 0">
|
||||
<scroll-view scroll-x class="time-scroll">
|
||||
<view class="flex">
|
||||
<view
|
||||
v-for="(item, i) in timeRound"
|
||||
:key="i"
|
||||
class="timeNav m-r-30"
|
||||
:class="{ activeTime: selectedTimeId === item.id }"
|
||||
@click="changeTimeRound(item, i)"
|
||||
>
|
||||
{{ item.name }}
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
<template #content>
|
||||
<view class="p-t-16">
|
||||
<view class="m-b-24" v-for="(v, i) in dataList" :key="i">
|
||||
<aiOrder
|
||||
:data="v"
|
||||
@addCar="addCar"
|
||||
:source="index"
|
||||
@update="update"
|
||||
@shipment="shipment"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</card_pages>
|
||||
</view>
|
||||
</view>
|
||||
<view class="" v-if="payShow">
|
||||
<card_payment
|
||||
ref="paymentRef"
|
||||
@updataList="clearSearch"
|
||||
@updatePrice="updatePrice"
|
||||
:addShow="addShow"
|
||||
:minSalesCountShow="navName == '折扣区' ? true : false"
|
||||
/>
|
||||
</view>
|
||||
</s-pages>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted, watch, getCurrentInstance } from 'vue';
|
||||
import SpuApi from '@/sheep/api/product/spu';
|
||||
import CartApi from '@/sheep/api/trade/cart.js';
|
||||
import * as api from '@/sheep/api/ai/index';
|
||||
import aiOrder from '@/components/ai_order/ai_order';
|
||||
import card_payment from '@/components/card_payment/card_payment';
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
const { proxy } = getCurrentInstance();
|
||||
const searchText = ref('');
|
||||
const search = (text = '') => {
|
||||
pageCommodity.value.downCallback();
|
||||
};
|
||||
const clearSearch = () => {
|
||||
searchText.value = '';
|
||||
pageCommodity.value.downCallback();
|
||||
};
|
||||
const getCartList = async () => {
|
||||
let res = await api.getShopCartList({});
|
||||
if (res.code === 0) {
|
||||
if (res.data.length || addShow.value) {
|
||||
payShow.value = true;
|
||||
} else {
|
||||
payShow.value = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/* 选品广场时间轮次 */
|
||||
const timeRound = ref([]);
|
||||
const selectedTimeId = ref(null);
|
||||
let navName = ref('');
|
||||
function changeTimeRound(e, i) {
|
||||
navName.value = e.name;
|
||||
selectedTimeId.value = e?.id ?? null;
|
||||
if (pageCommodity.value) {
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
/* */
|
||||
onShow(() => {
|
||||
getSpuTimeList();
|
||||
getCartList();
|
||||
|
||||
// if(paymentRef.value){
|
||||
// paymentRef.value.getCartList()
|
||||
// }
|
||||
});
|
||||
const update = () => {
|
||||
if (pageCommodity.value) {
|
||||
pageCommodity.value.downCallback();
|
||||
}
|
||||
};
|
||||
// 购物车数据
|
||||
let carArr = ref([]);
|
||||
let height = ref(0);
|
||||
let system = uni.getSystemInfoSync();
|
||||
let h =
|
||||
system.windowHeight -
|
||||
system.statusBarHeight -
|
||||
uni.upx2px(88) -
|
||||
uni.upx2px(76) -
|
||||
uni.upx2px(48) -
|
||||
uni.upx2px(67) -
|
||||
uni.upx2px(70) +
|
||||
uni.upx2px(8);
|
||||
let index = ref(0);
|
||||
let price = ref(0);
|
||||
let payShow = ref(false);
|
||||
let addShow = ref(false);
|
||||
watch(
|
||||
() => [payShow.value],
|
||||
() => {
|
||||
if (payShow.value) {
|
||||
height.value = h - uni.upx2px(128);
|
||||
} else {
|
||||
height.value = h;
|
||||
}
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
deep: true,
|
||||
},
|
||||
);
|
||||
// watch(
|
||||
// () => [carArr.value, index.value,price.value],
|
||||
// () => {
|
||||
// if (carArr.value.length && !index.value && price.value > 0) {
|
||||
// payShow.value = true
|
||||
// height.value = h - uni.upx2px(128);
|
||||
// } else {
|
||||
// payShow.value = false
|
||||
// height.value = h;
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// immediate: true,
|
||||
// deep: true,
|
||||
// },
|
||||
// );
|
||||
let nav = ref([
|
||||
{
|
||||
name: '选品广场',
|
||||
id: 1,
|
||||
},
|
||||
{
|
||||
name: '我的店铺',
|
||||
id: 2,
|
||||
},
|
||||
]);
|
||||
let pageCommodity = ref(null);
|
||||
let 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,
|
||||
});
|
||||
}
|
||||
|
||||
// CartApi.getCartList()
|
||||
if (res.code !== 0) {
|
||||
pageCommodity.value.getState(false);
|
||||
return;
|
||||
}
|
||||
let curPageData = []; // 当前页数据
|
||||
if (index.value) {
|
||||
let list = res.data.list;
|
||||
let arr = [];
|
||||
if (list.length) {
|
||||
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);
|
||||
console.log(dataList.value);
|
||||
pageCommodity.value.getState(true, curPageData.length);
|
||||
};
|
||||
let paymentRef = ref(null);
|
||||
const addCar = (data) => {
|
||||
payShow.value = true;
|
||||
addShow.value = true;
|
||||
setTimeout(() => {
|
||||
if (paymentRef.value) {
|
||||
paymentRef.value.addCar(data);
|
||||
}
|
||||
}, 500);
|
||||
};
|
||||
const navChange = (i) => {
|
||||
index.value = i;
|
||||
dataList.value = [];
|
||||
if (pageCommodity.value) {
|
||||
pageCommodity.value.downCallback();
|
||||
}
|
||||
if (index.value) {
|
||||
payShow.value = false;
|
||||
} else {
|
||||
payShow.value = true;
|
||||
}
|
||||
};
|
||||
const onClickLeft = () => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/AI/member',
|
||||
});
|
||||
};
|
||||
const updatePrice = (val) => {
|
||||
addShow.value = val;
|
||||
getCartList();
|
||||
};
|
||||
//延迟/立即发货
|
||||
function shipment(e) {
|
||||
pageCommodity.value.downCallback();
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.time-scroll {
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.timeNav {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.searchLeft {
|
||||
background: #fff;
|
||||
height: 72rpx;
|
||||
border-radius: 36rpx;
|
||||
}
|
||||
|
||||
.navItem {
|
||||
.navIcon {
|
||||
opacity: 0;
|
||||
width: 39rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.active {
|
||||
font-size: 32rpx !important;
|
||||
|
||||
.navIcon {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.c28 {
|
||||
color: #000 !important;
|
||||
}
|
||||
|
||||
.c29 {
|
||||
color: #fb4d32 !important;
|
||||
}
|
||||
|
||||
.activeTime {
|
||||
color: #fb4d32;
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user