会员,充值,明细,下单问题修复

This commit is contained in:
2025-09-28 17:41:19 +08:00
parent a8c2096096
commit 4245c2be0d
13 changed files with 508 additions and 151 deletions

View File

@@ -7,7 +7,7 @@
</view>
<scroll-view scroll-x="true" class="u-m-t-20">
<view class="list">
<view class="item color1" @click="itemClick" v-for="(item,index) in list" :key="index"
<view class="item color1" @click="itemClick(index)" v-for="(item,index) in list" :key="index"
:class="{active:sel==index}">
<view class="">
<text></text>
@@ -26,9 +26,9 @@
</view>
<view class="font-12 color-666" v-if="item.couponInfoList.length">
<text></text>
<text>{{item.couponInfoList.length}}</text>
<text>{{couponNum(item.couponInfoList)}}</text>
<text>张券</text>
<text class="color2 u-m-l-8" v-if="sel==index">查看</text>
<text class="color2 u-m-l-8" v-if="sel==index" @click="lookCoupon(item)">查看</text>
</view>
<view class="sel u-flex" v-if="sel==index">
@@ -40,21 +40,39 @@
</scroll-view>
</view>
<view class="" v-else></view>
<CouponList v-model="couponModel.show" :list="couponModel.couponInfoList"></CouponList>
</view>
</template>
<script setup>
import CouponList from '@/components/coupon/list.vue'
import * as rechargeApi from '@/common/api/market/recharge.js'
import {
useCartsStore
} from '@/stores/carts.js';
const cartStore = useCartsStore()
import {
onMounted,
onMounted,reactive,
ref,
watch
} from 'vue';
const couponModel = reactive({
show: false,
couponInfoList: []
})
function lookCoupon(item) {
couponModel.couponInfoList = item.couponInfoList
couponModel.show = true
}
function couponNum(list) {
return list.reduce((prve, cur) => {
return prve + cur.num
}, 0)
}
const cartStore = useCartsStore()
const list = ref([])
const sel = ref(-1)
const isShow = ref(false)
@@ -82,19 +100,25 @@
updateSel()
}
})
const emits=defineEmits(['updateChargeSel','updateRechargeId'])
function updateSel(){
const selItem=list.value[sel.value]
emits('updateChargeSel',selItem?selItem:{})
emits('updateRechargeId',data.id)
}
function itemClick(index){
console.log('itemClick',sel.value,index);
if(sel.value==-1){
sel.value=index
return
}
if(sel.value==index){
sel.value=-1
return
}
sel.value=index
}
const emits=defineEmits(['updateChargeSel'])
watch(()=>sel.value,(newval)=>{
updateSel()
})
@@ -104,8 +128,14 @@
</script>
<style lang="scss" scoped>
.color1{
color: #5F2E0F;
}
.color2{
color: #FF6300;
}
.box {
background: linear-gradient(179.4deg, #f8eadc 0%, #fdf9f6 82%, #ffffff 100%);
background-color: #fdf9f6;
padding: 30rpx;
margin-top: 32rpx;
border-radius: 22rpx;
@@ -125,7 +155,7 @@
.item {
padding: 36rpx 22rpx;
border-radius: 42rpx;
background: linear-gradient(180deg, #F5F5F5 58.54%, #FFF 140.47%);
background: linear-gradient(180deg, #F5F5F5 58.54%, #FFF 104.47%);
display: flex;
flex-direction: column;
justify-content: center;

View File

@@ -88,8 +88,7 @@
<!-- isTableFee == 0是不免除 -->
<view class="cell-item"
v-if="cartStore.orderCostSummary.seatFee">
<view class="cell-item" v-if="cartStore.orderCostSummary.seatFee">
<view class="label">餐位费</view>
<view class="val">
<view>X{{cartStore.seatFeeConfig.personCount}}</view>
@@ -117,33 +116,50 @@
<u-image bgColor="#fff" :width="item.width||'44rpx'" :height="item.height||'44rpx'"
v-if="item.icon" :src="item.icon" mode=""></u-image>
</view>
<text class="name u-m-l-16"> {{ item.name }} </text>
<text class="name u-m-l-16 no-wrap"> {{ item.name }} </text>
<text class="font-12" style="color: #666;margin-right: 16rpx;" v-if="item.type=='points'">
可用积分{{pointsRes.accountPoints}}最大可抵扣{{maxPointDiscount}}
</text>
</view>
<!-- 优惠卷 -->
<view class="favorable_right" v-if="item.type=='coupon'">
<text class="favorable_right_text red" v-if="returnCouponDiscount>0">-{{returnCouponDiscount}}</text>
<text class="favorable_right_text red"
v-if="returnCouponDiscount>0">-{{returnCouponDiscount}}</text>
<up-icon name="arrow-right" color="#575B66" size="16"
v-if="listinfo.status == 'unpaid' || listinfo.status == 'paying'||!listinfo.id"></up-icon>
</view>
<!-- 新客立减 -->
<view class="favorable_right" v-if="item.type=='newUser'">
<text class="favorable_right_text red" v-if="newUserDiscount>0">-{{newUserDiscount}}</text>
<text class="favorable_right_text red"
v-if="newUserDiscount>0">-{{newUserDiscount}}</text>
</view>
<!-- 积分 -->
<view class="favorable_right" v-if="item.type=='points'">
<view class="favorable_right u-flex u-col-center" v-if="item.type=='points'">
<up-icon name="checkmark-circle-fill" size="24rpx" v-if="usePoints"
color="#FE7E00"></up-icon>
<text v-if="usePoints" class="red">
-¥{{cartStore.orderCostSummary.pointDeductionAmount}}
</text>
<view v-else class="u-flex u-col-center">
<view class="round"></view>
<text class="color-333 font-12 no-wrap">使用抵扣</text>
</view>
</view>
<!-- <view class="favorable_right" v-if="item.type=='points'">
<text class="favorable_right_text" style="color: #666;margin-right: 16rpx;"
v-if="calcUsablePointsData.integral">
使用 {{ calcUsablePointsData.integral}}
积分抵扣{{props.listinfo.pointsDiscountAmount}}
</text>
<up-icon v-else name="arrow-right" color="#575B66" size="16"></up-icon>
</view>
</view> -->
</view>
</view>
@@ -215,7 +231,7 @@
</view>
<IntegralInput :visible="calcUsablePointsData.showModal" :minValue="calcUsablePointsData.minIntegral"
@@ -247,6 +263,12 @@
} from 'vue'
const usePoints = ref(false)
function chnageIsUsePoints() {
usePoints.value = !usePoints.value
}
import IntegralInput from './IntegralInput.vue';
import {
APImemberPointsmyPoints,
@@ -278,8 +300,7 @@
},
])
const favorablelist = reactive([
{
const favorablelist = reactive([{
name: "新客立减",
type: "newUser",
width: '40rpx',
@@ -374,12 +395,12 @@
}
const returnCouponDiscount = computed(() => {
if(!favorablelist[1].value){
if (!favorablelist[1].value) {
return 0
}
return favorablelist[1].value.reduce((prve,cur)=>{
return prve+(cur.discountAmount||0)
},0)
return favorablelist[1].value.reduce((prve, cur) => {
return prve + (cur.discountAmount || 0)
}, 0)
})
// 清空
@@ -426,8 +447,10 @@
shoppingCart: JSON.stringify([...props.nowCarts, ...props.listinfo.combinedArray]),
})
break;
case 'points':
chnageIsUsePoints()
return
IntegralInputclose()
if (calcUsablePointsData.usable == 0) {
uni.showToast({
@@ -453,14 +476,47 @@
})
const pointsRes = reactive({
accountPoints: 0
})
getMaxPointsDiscount()
const maxPointDiscount=ref(0)
async function getMaxPointsDiscount() {
//积分可抵扣最大金额
const maxMoney = cartStore.orderCostSummary.goodsRealAmount - cartStore.orderCostSummary
.couponDeductionAmount
let res = await APImemberPointscalcUsablePoints({
shopUserId: props.orderVIP.id,
orderAmount: maxMoney
})
console.log(res);
Object.assign(pointsRes, res)
const maxUsablePoints = res.maxUsablePoints
maxPointDiscount.value=res.maxDeductionAmount
// props.listinfo.pointsDiscountAmount = await APImemberPointscalcDeductionAmount({
// points: maxUsablePoints,
// shopUserId: props.orderVIP.id,
// orderAmount: maxMoney
// })
cartStore.setUserPoints(maxUsablePoints)
}
watch(() => usePoints.value, (newval) => {
if (newval) {
getMaxPointsDiscount()
} else {
cartStore.setUserPoints(0)
}
})
const handleConfirm = async (integral) => {
//积分可抵扣最大金额
const maxMoney= cartStore.orderCostSummary.goodsRealAmount-cartStore.orderCostSummary.couponDeductionAmount
const maxMoney = cartStore.orderCostSummary.goodsRealAmount - cartStore.orderCostSummary
.couponDeductionAmount
calcUsablePointsData.integral = integral
props.listinfo.pointsDiscountAmount = await APImemberPointscalcDeductionAmount({
points: integral,
shopUserId: props.orderVIP.id,
orderAmount:maxMoney
orderAmount: maxMoney
})
cartStore.setUserPoints(integral)
emits('clickPointsamount', {
@@ -473,7 +529,7 @@
const getCalcUsablePoints = async (data) => {
Object.assign(calcUsablePointsData, data);
try {
cartStore.setPointDeductionRule(data.equivalentPoints,data.maxDeductionAmount)
cartStore.setPointDeductionRule(data.equivalentPoints, data.maxDeductionAmount)
calcUsablePointsData.minIntegral = data.minDeductionPoints
calcUsablePointsData.maxIntegral = data.maxUsablePoints
calcUsablePointsData.instructionText =
@@ -513,19 +569,20 @@
bwcclear,
IntegralInputclose
});
watch(()=>props.listinfo.seatNum,(newval)=>{
cartStore.setSeatFeeConfig('personCount',newval||1)
watch(() => props.listinfo.seatNum, (newval) => {
cartStore.setSeatFeeConfig('personCount', newval || 1)
})
const newUserDiscount=ref(0)
async function getConsumeDiscount(){
const newUserDiscount = ref(0)
async function getConsumeDiscount() {
const consumeDiscountRes = await consumeDiscount({
shopId: uni.cache.get('shopId'),
})
if(consumeDiscountRes){
newUserDiscount.value=consumeDiscountRes.amount
cartStore.newUserDiscount=consumeDiscountRes.amount||0
if (consumeDiscountRes&&consumeDiscountRes.isUse) {
newUserDiscount.value = consumeDiscountRes.amount
cartStore.newUserDiscount = consumeDiscountRes.amount || 0
cartStore.consumeDiscount=consumeDiscountRes
}
}
getConsumeDiscount()
@@ -537,6 +594,14 @@
border-radius: 10rpx 10rpx 10rpx 10rpx;
}
.round {
width: 24rpx;
height: 24rpx;
border-radius: 50%;
background-color: #fff;
border: 1px solid #D9D9D9;
}
::v-deep .u-textarea__field {
background: #FAFAFA;
border-radius: 10rpx 10rpx 10rpx 10rpx;
@@ -1043,7 +1108,8 @@
font-size: 24rpx;
color: #999;
font-weight: 400rpx;
&.red{
&.red {
color: #FF3232;
}
}
@@ -1058,9 +1124,11 @@
.favorable_right_text {
margin-bottom: 10rpx;
&.red{
&.red {
color: #FF3232;
}
text:nth-child(1) {
font-size: 26rpx;
color: #999;
@@ -1205,7 +1273,8 @@
}
}
}
.red{
color:#FF3232;
.red {
color: #FF3232;
}
</style>

View File

@@ -118,7 +118,10 @@
BigNumber
} from 'bignumber.js';
import ChargeVue from './components/charge.vue';
import {pay} from '@/utils/pay.js'
import {
pay
} from '@/utils/pay.js'
function onback() {
closeSocket()
back()
@@ -149,7 +152,8 @@
import {
APIgetOrderById,
APIputuserorder,
APIhistoryOrder,rechargePayOrder
APIhistoryOrder,
rechargePayOrder
} from '@/common/api/order/index.js'
import {
APIusershopInfodetail,
@@ -166,19 +170,22 @@
useWebSocket
} from '@/stores/carts-websocket.js';
const cartStore = useCartsStore()
//充值相关
const rechargeItem=ref({id:''})
const rechargeId=ref(null)
function updateRechargeId(e){
rechargeId.value=e
const rechargeItem = ref({
id: ''
})
const rechargeId = ref(null)
function updateRechargeId(e) {
rechargeId.value = e
}
function updateChargeSel(e){
rechargeItem.value=e
function updateChargeSel(e) {
rechargeItem.value = e
}
async function onMessage(Message) {
cartStore.onMessage(Message, cartsSocket)
listinfo.totalPrices = historyTotalPrices * 1 + cartStore.totalPrice * 1
@@ -192,8 +199,8 @@
let res = await APIgetOrderById({
orderId: listinfo.id
})
console.log('onMessage:APIgetOrderById',res);
if(res){
console.log('onMessage:APIgetOrderById', res);
if (res) {
// cartStore.carts=[];
// cartStore.setOldOrder(res)
}
@@ -590,7 +597,7 @@
// cartStore.carts=[];
// cartStore.setOldOrder(res)
getOrderInfoAfterCalcInit(res)
cartsSocket.sendMessage({
type: 'shopping',
table_code: uni.cache.get('tableCode'),
@@ -647,12 +654,12 @@
if (!cartStore.isEmpty) {
const res = await createOrder()
//历史订单数据
const res1= await APIgetOrderById({
const res1 = await APIgetOrderById({
orderId: res.id
})
cartStore.setOldOrder(res1)
}
goToPay()
} else {
@@ -700,22 +707,26 @@
const goToPay = async (isCreateOrder = false) => {
// 余额支付
if (paymentmethod.payType == 'accountPay') {
if (orderVIP.value.isVip == 0) {
uni.showModal({
title: '提示',
content: '您还不是会员,是否去注册会员?',
success: (res) => {
if (res.confirm) {
uni.pro.navigateTo('user/member/index', {
shopId: orderVIP.value.shopId,
type: 'detail'
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
})
} else if (orderVIP.value.payPwd == '') {
// if (orderVIP.value.isVip == 0) {
// uni.showModal({
// title: '提示',
// content: '您还不是会员,是否去注册会员?',
// success: (res) => {
// if (res.confirm) {
// uni.pro.navigateTo('user/member/index', {
// shopId: orderVIP.value.shopId,
// type: 'detail'
// })
// } else if (res.cancel) {
// console.log('用户点击取消');
// }
// }
// })
// return
// }
if (orderVIP.value.payPwd == '') {
uni.showModal({
title: '提示',
content: '您还未设置支付密码,是否去设置?',
@@ -779,7 +790,7 @@
vipPrice: cartStore.useVipPrice ? 1 : 0, //是否使用会员价0否1是
userAllPack: is_type.value == 0 ? 0 : 1, //是否整单打包
seatNum: is_type.value == 0 ? cartStore.seatFeeConfig.personCount : 0, //用餐人数
originAmount: cartStore.orderCostSummary.goodsRealAmount , //订单原金额(包含打包费+餐位费) 不含折扣价格
originAmount: cartStore.orderCostSummary.goodsRealAmount, //订单原金额(包含打包费+餐位费) 不含折扣价格
discountRatio: 1, //折扣比例(计算时 向上取整保留 两位小数) 写死1
discountAmount: 0, //手动优惠金额 写死0
productCouponDiscountAmount: cartStore.orderCostSummary.productCouponDeduction, //商品优惠券抵扣金额
@@ -789,25 +800,29 @@
roundAmount: 0, //抹零金额 减免多少钱
pointsDiscountAmount: cartStore.orderCostSummary
.pointDeductionAmount, //积分抵扣金额(tb_points_basic_setting表)
pointsNum: listinfo.pointsNum, //(扣除各类折扣 enable_deduction后使用)
pointsNum: cartStore.orderCostSummary.pointUsed, //(扣除各类折扣 enable_deduction后使用)
newCustomerDiscountAmount: cartStore.orderCostSummary.newUserDiscount, //新客立减
newCustomerDiscountId: cartStore.orderCostSummary.newUserDiscount > 0 ? cartStore
.consumeDiscount.id : '',
remark: '', //用户备注
}
console.log('topay checkOrderPay', checkOrderPay);
try {
if(rechargeItem.value.id&&rechargeId.value){
if (rechargeItem.value.id && rechargeId.value) {
//充值支付
const payRes= await rechargePayOrder({
const payRes = await rechargePayOrder({
checkOrderPay,
payType: paymentmethod.payType,
buyerRemark: '',
returnUrl: '',
rechargeId:rechargeId.value,
rechargeDetailId:rechargeItem.value.id,
shopUserId:orderVIP.value.id,
rechargeId: rechargeId.value,
rechargeDetailId: rechargeItem.value.id,
shopUserId: orderVIP.value.id,
shopId: orderVIP.value.shopId,
})
pay(payRes)
}else{
await pay(payRes)
pay_unlock()
} else {
console.log('微信支付');
await storeMemberpay.actionsltPayOrder({
checkOrderPay,
@@ -815,15 +830,17 @@
buyerRemark: '',
returnUrl: ''
})
pay_unlock()
}
} catch (error) {
console.log('error',error);
console.log('error', error);
pay_unlock()
//TODO handle the exception
}
}
pay_unlock()
console.log('orderorderInfo');
orderorderInfo()
}
@@ -853,7 +870,7 @@
vipPrice: cartStore.useVipPrice ? 1 : 0, //是否使用会员价0否1是
userAllPack: is_type.value == 0 ? 0 : 1, //是否整单打包
seatNum: is_type.value == 0 ? cartStore.seatFeeConfig.personCount : 0, //用餐人数
originAmount: cartStore.orderCostSummary.goodsRealAmount , //订单原金额(包含打包费+餐位费) 不含折扣价格
originAmount: cartStore.orderCostSummary.goodsRealAmount, //订单原金额(包含打包费+餐位费) 不含折扣价格
discountRatio: 1, //折扣比例(计算时 向上取整保留 两位小数) 写死1
discountAmount: 0, //手动优惠金额 写死0
productCouponDiscountAmount: cartStore.orderCostSummary.productCouponDeduction, //商品优惠券抵扣金额
@@ -863,7 +880,10 @@
roundAmount: 0, //抹零金额 减免多少钱
pointsDiscountAmount: cartStore.orderCostSummary
.pointDeductionAmount, //积分抵扣金额(tb_points_basic_setting表)
pointsNum: listinfo.pointsNum, //(扣除各类折扣 enable_deduction后使用)
pointsNum: cartStore.orderCostSummary.pointUsed, //(扣除各类折扣 enable_deduction后使用)
newCustomerDiscountAmount: cartStore.orderCostSummary.newUserDiscount, //新客立减
newCustomerDiscountId: cartStore.orderCostSummary.newUserDiscount > 0 ? cartStore.consumeDiscount
.id : '',
remark: '', //用户备注
}
try {
@@ -934,7 +954,7 @@
url: '/pages/product/index'
})
}
const packfee=computed(()=>{
const packfee = computed(() => {
return cartStore.orderCostSummary.packFee
})
//不计算各种折扣前的实付金额

View File

@@ -323,7 +323,10 @@
let noUseGoodsCoupon = []
let noUseDiscountCoupon = []
const user = uni.cache.get('shopUserInfo')
const shopInfo = uni.cache.get('shopInfo')
let shopInfo = uni.cache.get('shopInfo')||{}
if(!shopInfo.isMemberPrice){
shopInfo={}
}
const goodsOrderPrice = uni.getStorageSync('goodsOrderPrice') || 0
const goodsList = uni.getStorageSync('canDikouGoodsArr') || []
const dinnerType = uni.getStorageSync('dinnerType')