增加购物车编辑数量功能

This commit is contained in:
2026-01-17 10:36:33 +08:00
parent 0990e08201
commit f090d59dc6
5 changed files with 403 additions and 323 deletions

View File

@@ -1,5 +1,5 @@
//当前环境 test,prod //当前环境 test,prod
export const ENV = 'test' export const ENV = 'prod'
export const ENV_BASE_URL = { export const ENV_BASE_URL = {
java: { java: {
prod: 'https://cashier.sxczgkj.com/', prod: 'https://cashier.sxczgkj.com/',
@@ -15,6 +15,7 @@ export const ENV_BASE_URL = {
} }
} }
/** /**
* @param {String} env 环境,测试或者正式 * @param {String} env 环境,测试或者正式
* @param {String} apiType 语言java或者php * @param {String} apiType 语言java或者php

View File

@@ -41,7 +41,7 @@
:key="index" :key="index"
> >
<view> <view>
<view class="up-line-1">{{ item.name }}</view> <view class="up-line-1" style="max-width: 240rpx;">{{ item.name }}</view>
<view class="u-m-t-10 u-font-24 color-666 up-line-1">{{ <view class="u-m-t-10 u-font-24 color-666 up-line-1">{{
item.specInfo || "" item.specInfo || ""
}}</view> }}</view>
@@ -62,7 +62,7 @@
mode="" mode=""
/> />
</view> </view>
<view class="u-m-l-30 u-m-r-30 color-333"> <view class="u-m-l-30 u-m-r-30 color-333" @tap="changeNumber(item)">
{{ item.number.toFixed(2) }} {{ item.number.toFixed(2) }}
</view> </view>
<view class="u-flex" @tap="updateNumber(true, index, item)"> <view class="u-flex" @tap="updateNumber(true, index, item)">
@@ -328,7 +328,11 @@ function setModalShow(key = "show", show = true, type = "", title = "") {
console.log(modal); console.log(modal);
} }
const edmits = defineEmits(["clear", "updateNumber"]); const edmits = defineEmits(["clear", "updateNumber","changeNumber"]);
function changeNumber(goods){
edmits('changeNumber',goods)
}
// mask // mask
let switchGoods = ref(false); let switchGoods = ref(false);

View File

@@ -1,11 +1,6 @@
<template> <template>
<view class="u-relative u-flex item"> <view class="u-relative u-flex item">
<up-image <up-image :src="data.coverImg" mode="aspectFill" :width="img.width" :height="img.height"></up-image>
:src="data.coverImg"
mode="aspectFill"
:width="img.width"
:height="img.height"
></up-image>
<view class="info u-flex u-row-between u-col-top u-flex-col"> <view class="info u-flex u-row-between u-col-top u-flex-col">
<view class="limit-discount" v-if="is_time_discount">限时折扣</view> <view class="limit-discount" v-if="is_time_discount">限时折扣</view>
@@ -15,10 +10,7 @@
</view> </view>
<view> <view>
<text class="u-font-32 font-bold u-m-t-16" v-if="is_time_discount"> {{ limitPrice }} </text> <text class="u-font-32 font-bold u-m-t-16" v-if="is_time_discount"> {{ limitPrice }} </text>
<text <text class="u-font-32 font-bold u-m-t-16" :class="[is_time_discount ? 'line-through' : '']">
class="u-font-32 font-bold u-m-t-16"
:class="[is_time_discount ? 'line-through' : '']"
>
{{ data.lowPrice }} {{ data.lowPrice }}
</text> </text>
</view> </view>
@@ -29,78 +21,43 @@
</view> </view>
<view class="u-flex" v-if="!isSellout"> <view class="u-flex" v-if="!isSellout">
<template v-if="data.type == 'sku' || data.groupType == 1"> <template v-if="data.type == 'sku' || data.groupType == 1">
<button <button class="btn" hover-class="btn-hover-class" @tap="emitEvent('chooseGuige')">
class="btn"
hover-class="btn-hover-class"
@tap="emitEvent('chooseGuige')"
>
选规格 选规格
</button> </button>
</template> </template>
<template v-else> <template v-else>
<view class="u-flex icon-btn"> <view class="u-flex icon-btn">
<view
class="u-flex"
@tap.stop="emitEvent(data.type == 'weight' ? 'tapweigh' : 'add')"
>
<image
src="/pagesCreateOrder/static/images/icon-add.svg"
class="icon"
mode=""
></image>
</view>
<template v-if="data.chooseNumber"> <template v-if="data.chooseNumber">
<view class="u-flex" @tap.stop="emitEvent('reduce')">
<image src="/pagesCreateOrder/static/images/icon-reduce.svg" class="icon" mode="">
</image>
</view>
<view class="u-font-32" > <view class="u-font-32" >
{{ data.chooseNumber.toFixed(2) }} {{ data.chooseNumber.toFixed(2) }}
</view> </view>
<view class="u-flex" @tap.stop="emitEvent('reduce')">
<image
src="/pagesCreateOrder/static/images/icon-reduce.svg"
class="icon"
mode=""
>
</image>
</view>
</template> </template>
<view class="u-flex" @tap.stop="emitEvent(data.type == 'weight' ? 'tapweigh' : 'add')">
<image src="/pagesCreateOrder/static/images/icon-add.svg" class="icon" mode=""></image>
</view>
</view> </view>
</template> </template>
</view> </view>
<template v-if="isSellout"> <template v-if="isSellout">
<view class="isSellout" v-if="data.isSale == 0"> <view class="isSellout" v-if="data.isSale == 0">
<image <image class="isSellout_icon" src="/pagesCreateOrder/static/images/no-toDown.svg" mode=""></image>
class="isSellout_icon"
src="/pagesCreateOrder/static/images/no-toDown.svg"
mode=""
></image>
</view> </view>
<view <view class="isSellout" v-else-if="
class="isSellout"
v-else-if="
!isProductAvailable(data.days, data.startTime, data.endTime) !isProductAvailable(data.days, data.startTime, data.endTime)
" ">
> <image class="isSellout_icon" src="/pagesCreateOrder/static/images/no-saleTime.svg" mode=""></image>
<image
class="isSellout_icon"
src="/pagesCreateOrder/static/images/no-saleTime.svg"
mode=""
></image>
</view> </view>
<view class="isSellout" v-else-if="data.isSoldStock == 1"> <view class="isSellout" v-else-if="data.isSoldStock == 1">
<image <image class="isSellout_icon" src="/pagesCreateOrder/static/images/no-sold.svg" mode=""></image>
class="isSellout_icon"
src="/pagesCreateOrder/static/images/no-sold.svg"
mode=""
></image>
</view> </view>
<view <view class="isSellout" v-else-if="data.isStock == 1 && data.stockNumber <= 0">
class="isSellout" <image class="isSellout_icon" src="/pagesCreateOrder/static/images/no-stock.svg" mode=""></image>
v-else-if="data.isStock == 1 && data.stockNumber <= 0"
>
<image
class="isSellout_icon"
src="/pagesCreateOrder/static/images/no-stock.svg"
mode=""
></image>
</view> </view>
</template> </template>
</view> </view>
@@ -108,7 +65,11 @@
</template> </template>
<script setup> <script setup>
import { computed, toRef, inject } from "vue"; import {
computed,
toRef,
inject
} from "vue";
import util from "../util.js"; import util from "../util.js";
import dayjs from "dayjs"; import dayjs from "dayjs";
import isBetween from "dayjs/plugin/isBetween.js"; import isBetween from "dayjs/plugin/isBetween.js";
@@ -318,11 +279,13 @@ image {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
.isSellout_icon { .isSellout_icon {
height: 60%; height: 60%;
width: 60%; width: 60%;
} }
} }
.limit-discount { .limit-discount {
background-color: #cc5617; background-color: #cc5617;
padding: 10rpx 20rpx; padding: 10rpx 20rpx;
@@ -337,6 +300,7 @@ image {
border-radius: 0 0rpx 20rpx 0rpx; border-radius: 0 0rpx 20rpx 0rpx;
color: #fff; color: #fff;
} }
.line-through { .line-through {
font-size: 24rpx; font-size: 24rpx;
color: rgba(255, 255, 255, 0.8); color: rgba(255, 255, 255, 0.8);

View File

@@ -0,0 +1,90 @@
<template>
<view>
<up-popup :show="show" mode="center" @close="show=flase" :close-on-click-overlay="true">
<view class="box">
<view class="u-flex u-row-between">
<text class="u-font-32 font-bold">修改数量</text>
<up-icon name="close" @click="show=false"></up-icon>
</view>
<view class="form-box">
<up-form label-position="left" label-width="auto">
<up-form-item label="数量" required>
<up-number-box inputWidth="200rpx" :step="1"
:integer="integer"
v-model="number"></up-number-box>
</up-form-item>
</up-form>
</view>
<view class="u-m-t-12 u-flex gap-20">
<view class="u-flex-1">
<my-button type="default" @click="show=false">取消</my-button>
</view>
<view class="u-flex-1">
<my-button type="primary" @click="confirm">确认</my-button>
</view>
</view>
</view>
</up-popup>
</view>
</template>
<script setup>
import {
watch,ref, computed
} from 'vue';
const show = defineModel(false)
const props = defineProps({
min: {
type: Number,
default: 0
},
max: {
type: Number,
default: 9999
},
goods: {
type: Object,
default: ()=>{number:0}
}
})
const integer=computed(()=>{
if(props.goods.product_type=="weight"){
return false
}
return true
})
const number = ref(0)
const emits=defineEmits('confirm')
function confirm(){
emits('confirm',{
goods:props.goods,
num:number.value
})
show.value=false
}
watch(() => show.value, (newval) => {
if (newval) {
number.value = props.goods.number||0
} else {
number.value = 0
}
})
</script>
<style lang="scss" scoped>
.box {
width: 690rpx;
border-radius: 16rpx;
padding: 32rpx 28rpx;
}
.form-box {
padding: 20rpx;
}
</style>

View File

@@ -79,9 +79,9 @@
<view class="u-flex u-m-t-20 u-flex-wrap u-row-between"> <view class="u-flex u-m-t-20 u-flex-wrap u-row-between">
<view class="u-m-b-30" v-for="(goodsItem, goodsIndex) in searchResult" :key="goodsIndex"> <view class="u-m-b-30" v-for="(goodsItem, goodsIndex) in searchResult" :key="goodsIndex">
<list-goods-item :img="{ width: '330rpx', height: '330rpx' }" <list-goods-item :img="{ width: '330rpx', height: '330rpx' }"
:limitTimeDiscount="data.limitTimeDiscount" @chooseGuige=" :limitTimeDiscount="data.limitTimeDiscount"
chooseGuige(goodsItem.goodsIndex, goodsItem.index) @chooseGuige="chooseGuige(goodsItem.goodsIndex, goodsItem.index)"
" @add="searchGoodsUpdate(goodsItem, goodsIndex, true)" @add="searchGoodsUpdate(goodsItem, goodsIndex, true)"
@reduce="searchGoodsUpdate(goodsItem, goodsIndex, false)" @reduce="searchGoodsUpdate(goodsItem, goodsIndex, false)"
@tapweigh="tapweigh(goodsItem.goodsIndex, goodsItem.index)" @tapweigh="tapweigh(goodsItem.goodsIndex, goodsItem.index)"
:index="goodsItem.goodsIndex" :data="goodsItem"></list-goods-item> :index="goodsItem.goodsIndex" :data="goodsItem"></list-goods-item>
@@ -96,6 +96,7 @@
<view class="bottom w-full"> <view class="bottom w-full">
<my-car :isCreateOrderToDetail="isCreateOrderToDetail" @updateNumber="carsNumberChange" :table="data.table" <my-car :isCreateOrderToDetail="isCreateOrderToDetail" @updateNumber="carsNumberChange" :table="data.table"
:data="cars" :orderInfo="data.orderInfo" :limitTimeDiscount="data.limitTimeDiscount" :data="cars" :orderInfo="data.orderInfo" :limitTimeDiscount="data.limitTimeDiscount"
@changeNumber="goodsChangeNumber"
@clear="cleaCart"></my-car> @clear="cleaCart"></my-car>
</view> </view>
<!-- 套餐选择规格 --> <!-- 套餐选择规格 -->
@@ -112,6 +113,9 @@
<text>历史订单</text> <text>历史订单</text>
<text class="num">{{ data.historyOrderNum }}</text> <text class="num">{{ data.historyOrderNum }}</text>
</view> </view>
<!-- 修改购物车数量 -->
<popupChangeNumber v-model="popupChangeNumberData.show" :goods="popupChangeNumberData.data" @confirm="carsNumberChange"></popupChangeNumber>
</view> </view>
</template> </template>
<script setup> <script setup>
@@ -137,6 +141,13 @@
import { import {
stickCount stickCount
} from '@/http/api/product/stick.js' } from '@/http/api/product/stick.js'
import popupChangeNumber from './components/popup-change-number.vue'
const popupChangeNumberData=reactive({
show:false,
data:null
})
import guigeModel from "./components/guige"; import guigeModel from "./components/guige";
import taocanModel from "./components/taocanModel.vue"; import taocanModel from "./components/taocanModel.vue";
import weighItem from "./components/weigh.vue"; import weighItem from "./components/weigh.vue";
@@ -846,6 +857,16 @@
} }
} }
function goodsChangeNumber(e){
console.log(e);
popupChangeNumberData.data=e;
popupChangeNumberData.show=true
}
/** /**
* socket通知购物车商品数量修改处理 * socket通知购物车商品数量修改处理
*/ */