新增套餐推广

This commit is contained in:
gyq
2025-12-20 09:12:07 +08:00
parent 8826b206df
commit e8e474d971
15 changed files with 1584 additions and 441 deletions

View File

@@ -8,9 +8,14 @@
<text class="t">可用门店</text>
</view>
<view class="info">
<view class="ipt">
<view class="ipt" v-if="isMainShop()">
<my-shop-select-w v-model:useType="form.useShopType" v-model:selShops="form.useShops"></my-shop-select-w>
</view>
<view class="ipt" v-else>
<u-radio-group v-model="form.useShopType">
<u-radio label="仅本店" name="only"></u-radio>
</u-radio-group>
</view>
</view>
</view>
</u-form-item>
@@ -20,6 +25,7 @@
<view class="switch-wrap">
<view class="top">
<text class="t">商品名称</text>
<text class="t2" @click="toSelectGoodS">导入已有商品</text>
</view>
<view class="info">
<view class="ipt">
@@ -147,9 +153,10 @@
<script setup>
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { filterNumberInput } from '@/utils/index.js';
import { addGbWare, updateGbWareById } from '@/http/api/ware.js';
import { isMainShop } from '@/store/account.js';
const type = ref('add'); // add添加商品 editor编辑商品
const formRef = ref(null);
@@ -283,6 +290,13 @@ const rules = ref({
]
});
// 跳转去选择商品
function toSelectGoodS() {
uni.navigateTo({
url: '/pageMarket/groupGoods/selectGoods'
});
}
const limitBuyNumFalseNum = -10086;
function limitBuyNumSwitchChange(e) {
if (e) {
@@ -347,6 +361,8 @@ function submitHandle() {
if (form.value.wareCommentImgs.length) {
data.wareCommentImgs = form.value.wareCommentImgs.join(',');
} else {
data.wareCommentImgs = '';
}
if (form.value.id) {
@@ -406,7 +422,22 @@ function getLocalGoods() {
}
}
// 从本地获取已选择的拼团商品
function getLocalGroupProduct() {
let groupGoods = uni.getStorageSync('groupProduct');
if (groupGoods && groupGoods.coverImg) {
form.value.wareName = groupGoods.name;
form.value.wareImgs = [groupGoods.coverImg];
form.value.originalPrice = groupGoods.price;
}
}
onShow(() => {
getLocalGroupProduct();
});
onLoad((options) => {
uni.setStorageSync('groupProduct', '');
if (options.type && options.type == 'editor') {
type.value = options.type;
uni.setNavigationBarTitle({
@@ -456,6 +487,10 @@ page {
font-size: 24upx;
color: #666;
}
.t2 {
font-size: 28upx;
color: #3c9cff;
}
}
.info {
padding-top: 16upx;

View File

@@ -8,8 +8,8 @@
shape="circle"
clearable
v-model="queryForm.wareName"
@confirm="getGbWarePageAjax(1)"
@clear="getGbWarePageAjax(1)"
@confirm="resetGetList()"
@clear="resetGetList()"
></u-input>
</view>
<div class="ipt" @click="showStatusSheet = true">
@@ -31,7 +31,7 @@
<text class="t1">原价{{ item.originalPrice }}</text>
<text class="t1">拼团价{{ item.groupPrice }}</text>
</view>
<view class="status">
<view class="status" v-if="item.shopId == shopInfo.id">
<view class="row">
<u-switch v-model="item.onlineStatus" :active-value="1" :inactive-value="0" @change="onlineStatusChange($event, item)"></u-switch>
</view>
@@ -41,7 +41,7 @@
</text>
</view>
</view>
<view class="footer-wrap">
<view class="footer-wrap" v-if="item.shopId == shopInfo.id">
<template v-if="!item.onlineStatus">
<view class="btn">
<u-button shape="circle" @click="delHandle(item)">删除</u-button>
@@ -77,6 +77,7 @@
<script setup>
import { onMounted, reactive, ref } from 'vue';
import { getGbWarePage, editOnlineStatus, deleteGbWare } from '@/http/api/ware.js';
const shopInfo = ref('');
const props = defineProps({
top: {
@@ -96,7 +97,7 @@ const queryForm = reactive({
function sheetConfirm(e) {
queryForm.onlineStatusLabel = e.name;
queryForm.onlineStatus = e.value;
getGbWarePageAjax(1);
resetGetList();
}
const listData = reactive({
@@ -158,11 +159,17 @@ function editorHandle(item) {
});
}
// 重置列表请求
function resetGetList() {
listData.page = 1;
getGbWarePageAjax();
}
// 拼团商品-列表
async function getGbWarePageAjax(page = listData.page, isPull = false) {
async function getGbWarePageAjax() {
try {
const res = await getGbWarePage({
page: page,
page: listData.page,
size: listData.size,
...queryForm
});
@@ -179,24 +186,19 @@ async function getGbWarePageAjax(page = listData.page, isPull = false) {
} catch (error) {
console.log(error);
}
if (isPull) {
setTimeout(() => {
uni.showToast({
title: '刷新成功',
icon: 'none'
});
uni.stopPullDownRefresh();
}, 300);
}
setTimeout(() => {
uni.stopPullDownRefresh();
}, 300);
}
defineExpose({
reachBottom,
getGbWarePageAjax
resetGetList
});
onMounted(() => {
getGbWarePageAjax();
shopInfo.value = uni.getStorageSync('shopInfo');
resetGetList();
});
</script>

View File

@@ -9,8 +9,8 @@
shape="circle"
clearable
v-model="queryForm.orderNo"
@confirm="gbOrderPageAjax(1)"
@clear="gbOrderPageAjax(1)"
@confirm="resetGetList(1)"
@clear="resetGetList(1)"
></u-input>
</view>
<div class="ipt" @click="dateRef.open()">
@@ -128,7 +128,7 @@ function dateConfirmHandle(e) {
queryForm.orderStartTime = e.start;
queryForm.orderEndTime = e.end;
time.value = e.text;
gbOrderPageAjax(1);
resetGetList();
}
const statusActive = ref(0);
@@ -199,7 +199,7 @@ function tabChange(index) {
statusActive.value = index;
listData.page = 1;
queryForm.status = tabs.value[index].value;
gbOrderPageAjax();
resetGetList();
}
const listData = reactive({
@@ -239,7 +239,7 @@ function refundHandle(item) {
icon: 'none'
});
}, 100);
goodsRecordPageAjax(1);
resetGetList();
}
} catch (error) {
uni.hideLoading();
@@ -281,7 +281,7 @@ async function returnCostConfirmHandle() {
icon: 'none'
});
}, 100);
gbOrderPageAjax(1);
resetGetList();
} catch (error) {
console.log(error);
}
@@ -294,33 +294,40 @@ async function checkoutHandle(item) {
title: '注意',
content: '确认要核销吗?',
success: async (res) => {
try {
uni.showLoading({
title: '核销中...',
mask: true
});
await checkout(item.verifyCode);
setTimeout(() => {
uni.showToast({
title: '已核销',
icon: 'none'
if (res.confirm) {
try {
uni.showLoading({
title: '核销中...',
mask: true
});
}, 100);
item.status = '已核销';
item.verifyTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
} catch (error) {
console.log(error);
await checkout(item.verifyCode);
setTimeout(() => {
uni.showToast({
title: '已核销',
icon: 'none'
});
}, 100);
resetGetList();
} catch (error) {
console.log(error);
}
uni.hideLoading();
}
uni.hideLoading();
}
});
}
// 重置列表请求
function resetGetList() {
listData.page = 1;
gbOrderPageAjax();
}
// 获取拼团商品:订单列表
async function gbOrderPageAjax(page = listData.page, isPull = false) {
async function gbOrderPageAjax() {
try {
const res = await gbOrderPage({
page: page,
page: listData.page,
size: listData.size,
...queryForm
});
@@ -345,11 +352,11 @@ async function gbOrderPageAjax(page = listData.page, isPull = false) {
defineExpose({
reachBottom,
gbOrderPageAjax
resetGetList
});
onMounted(() => {
gbOrderPageAjax();
resetGetList();
});
</script>

View File

@@ -32,6 +32,7 @@ import goodsList from './components/goodsList.vue';
import orderList from './components/orderList.vue';
import { upShopConfig } from '@/http/api/ware.js';
import { getShopInfo } from '@/http/api/shop.js';
import { isMainShop } from '@/store/account.js';
const goodsListRef = ref(null);
const orderListRef = ref(null);
@@ -67,7 +68,23 @@ const form = ref({
watch(
() => form.value.onlineStatus,
(newValue, oldValue) => {
upShopConfigAjax();
if (loading.value == false) {
if (newValue == 0) {
uni.showModal({
title: '注意',
content: '关闭拼团商品所有未支付的订单都将自动取消,是否确定关闭?',
success: (res) => {
if (res.confirm) {
upShopConfigAjax();
} else {
form.value.onlineStatus = 1;
}
}
});
} else {
upShopConfigAjax();
}
}
}
);
@@ -79,6 +96,9 @@ async function upShopConfigAjax() {
mask: true
});
const res = await upShopConfig(form.value);
if (tabsActive.value == 0) {
goodsListRef.value?.resetGetList();
}
} catch (error) {
console.log(error);
}
@@ -89,10 +109,10 @@ async function upShopConfigAjax() {
onPullDownRefresh(() => {
switch (tabsActive.value) {
case 0:
goodsListRef.value?.getGbWarePageAjax(1, true);
goodsListRef.value?.resetGetList();
break;
case 1:
orderListRef.value?.getGbWarePageAjax(1, true);
orderListRef.value?.resetGetList();
break;
default:
break;
@@ -114,20 +134,25 @@ onReachBottom(() => {
});
// 获取配置信息
const loading = ref(true);
async function getShopInfoAjax() {
try {
loading.value = true;
const res = await getShopInfo();
form.value.onlineStatus = res.isGroupBuy;
} catch (error) {
console.log(error);
}
setTimeout(() => {
loading.value = false;
}, 500);
}
// 页面显示
onShow(() => {
switch (tabsActive.value) {
case 0:
goodsListRef.value?.getGbWarePageAjax(1);
goodsListRef.value?.resetGetList();
break;
case 1:
break;

View File

@@ -0,0 +1,95 @@
<template>
<view class="list">
<view class="item" v-for="item in list" :key="item.id" @click="selectGoods(item)">
<image class="cover" :src="item.coverImg" mode="aspectFill"></image>
<view class="info">
<text class="name">{{ item.name }}</text>
<text class="price">{{ returnPrice(item.skuList) }}</text>
</view>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { getProductList } from '@/http/api/product.js';
// 商品列表
const list = ref([]);
// 选择商品
function selectGoods(item) {
uni.setStorageSync('groupProduct', {
coverImg: item.coverImg,
name: item.name,
price: returnPrice(item.skuList)
});
uni.navigateBack();
}
// 返回规格最高价
function returnPrice(skuList) {
return Math.max(...skuList.map((item) => item.salePrice));
}
// 获取商品列表
async function getProductListAjax() {
try {
uni.showLoading({
title: '加载中...',
mask: true
});
const res = await getProductList();
list.value = res;
} catch (error) {
console.log(error);
}
uni.hideLoading();
}
onLoad(() => {
getProductListAjax();
});
</script>
<style>
page {
background-color: #f8f8f8;
}
</style>
<style scoped lang="scss">
.list {
padding: 28upx;
.item {
padding: 28upx;
background-color: #fff;
border-radius: 20upx;
display: flex;
&:not(:first-child) {
margin-top: 28upx;
}
.cover {
$size: 120upx;
width: $size;
height: $size;
border-radius: 16upx;
}
.info {
flex: 1;
display: flex;
flex-direction: column;
gap: 12upx;
padding-left: 28upx;
.name {
font-size: 32upx;
color: #333;
}
.price {
font-size: 32upx;
color: red;
}
}
}
}
</style>