diff --git a/commons/utils/goodsUtil.js b/commons/utils/goodsUtil.js
index 035de76..8c7a802 100644
--- a/commons/utils/goodsUtil.js
+++ b/commons/utils/goodsUtil.js
@@ -2,7 +2,7 @@ export function canComputedPackFee(v) {
return v.pack && v.status != 'return' && v.status != 'refund' && v.status != 'refunding'
}
export function returnCanComputedGoodsArr(arr) {
- return arr.filter(v=>canComputedPackFee(v))
+ return arr.filter(v => canComputedPackFee(v))
}
export function returnPackFee(arr) {
return arr.reduce((prve, cur) => {
@@ -10,22 +10,26 @@ export function returnPackFee(arr) {
}, 0).toFixed(2)
}
-export function canTuicai(orderInfo,item){
- return orderInfo.status=='unpaid'&&orderInfo.useType!='dine-in-before'&& item.status!='return'
+export function canTuicai(orderInfo, item) {
+ if (orderInfo.status == 'unpaid' && orderInfo.isPostpaid !== null && orderInfo.isPostpaid == 0) {
+ return false
+ }
+ return orderInfo.status == 'unpaid' && orderInfo.useType != 'dine-in-before' && item.status != 'return'
}
-export function canTuiKuan(orderInfo,item){
- // 不是未支付退款等状态,也不是商品券抵扣才可以退款
- return orderInfo.status!='unpaid'&& item.status!='return'&&item.status!='refund'&&item.status!='refunding'&&!item.userCouponId
+export function canTuiKuan(orderInfo, item) {
+ // 已完成的订单,也不是商品券抵扣才可以退款
+ return orderInfo.status == 'closed' && item.status != 'return' && item.status != 'refund' && item.status !=
+ 'refunding' && !item.userCouponId
}
-export function isTui(item){
- return item.status=='return'||item.status=='refund'||item.status=='refunding'
+export function isTui(item) {
+ return item.status == 'return' || item.status == 'refund' || item.status == 'refunding'
}
-export function isGift(item){
- return !isTui(item)&&item.gift
+export function isGift(item) {
+ return !isTui(item) && item.gift
}
-export function numSum(arr){
- const sum=arr.reduce((a,b)=>{
- return a+b*100
- },0)
- return (sum/100).toFixed(2)
+export function numSum(arr) {
+ const sum = arr.reduce((a, b) => {
+ return a + b * 100
+ }, 0)
+ return (sum / 100).toFixed(2)
}
\ No newline at end of file
diff --git a/commons/utils/safe-bottom.js b/commons/utils/safe-bottom.js
index c8ed07d..9cfddc1 100644
--- a/commons/utils/safe-bottom.js
+++ b/commons/utils/safe-bottom.js
@@ -1,23 +1,32 @@
import {
getCurrentInstance,
} from 'vue';
-export function getElRect(elClass, dataVal) {
- const instance = getCurrentInstance();
- return new Promise((resolve, reject) => {
- const query = uni.createSelectorQuery().in(instance.proxy);
+export async function getElRect(elClass, instance,option) {
+ instance = instance ? instance : getCurrentInstance();
+ const query = uni.createSelectorQuery().in(instance.proxy);
+ try{
+ const res= await getEle(query,elClass,option)
+ return res
+ }catch(e){
+ console.log(e);
+ }
+}
+async function getEle(query,elClass,option){
+ return new Promise((resolve, reject)=>{
query.select('.' + elClass).fields({
- size: true
+ size: true,
+ ...option
}, res => {
// 如果节点尚未生成,res值为null,循环调用执行
if (!res) {
- setTimeout(() => {
- getElRect(elClass);
+ return setTimeout(() => {
+ getEle(query,elClass,option);
}, 10);
- return;
}
resolve(res);
}).exec();
})
+
}
export async function getSafeBottomHeight(className, height = 16) {
diff --git a/pageUser/index/components/user.vue b/pageUser/index/components/user.vue
index 64fbe6f..8ef3fc6 100644
--- a/pageUser/index/components/user.vue
+++ b/pageUser/index/components/user.vue
@@ -38,7 +38,7 @@
- {{data.totalScore}}
+ {{data.accountPoints}}
积分
@@ -56,7 +56,7 @@
-
+
{{accountPoints.num}}
@@ -126,22 +127,22 @@
-
+
-
+
-
+
*
- {{accountPoints.calcRes.unusableReason}}
+ {{accountPoints.calcRes.unusableReason}}
*
- 100积分等于{{to2(accountPoints.calcRes.equivalentPoints*100)}}元,
+ 100积分等于{{to2(accountPoints.calcRes.equivalentPoints*100)}}元,
最大抵扣积分{{accountPoints.calcRes.maxUsablePoints}}
@@ -225,10 +226,16 @@
import infoBox from '@/commons/utils/infoBox.js'
import editDiscount from '@/components/my-components/edit-discount.vue'
import editAccountPoints from './components/edit-accountPoints.vue'
+ import {
+ returnGoodsPayPriceMap,returnProCoupStartIndex ,returnProductCoupAllPrice
+ } from '../quan_util.js'
+ //商品数量从0到n每一个对应的价格
+ let $goodsPayPriceMap={}
- const refPoints=ref(null)
- function refPointsOpen(){
- if(!accountPoints.calcRes.usable&&accountPoints.sel){
+ const refPoints = ref(null)
+
+ function refPointsOpen() {
+ if (!accountPoints.calcRes.usable && accountPoints.sel) {
return
}
refPoints.value.open()
@@ -236,50 +243,50 @@
const accountPoints = reactive({
sel: false,
num: 0,
- calcRes:{
- usable:false,
- unusableReason:'',
- minDeductionPoints:0,
- maxUsablePoints:0
+ calcRes: {
+ usable: false,
+ unusableReason: '',
+ minDeductionPoints: 0,
+ maxUsablePoints: 0
},
- price:0
+ price: 0
})
- async function calcUsablePoints(){
- if(!order.memberId){
- return
+ async function calcUsablePoints() {
+ if (!order.memberId) {
+ return
}
- const res=await Api.$calcUsablePoints({
- memberId:order.memberId,
- orderAmount:pointCanDicountPrice.value
+ const res = await Api.$calcUsablePoints({
+ memberId: order.memberId,
+ orderAmount: pointCanDicountPrice.value
})
- accountPoints.calcRes=res
- accountPoints.num=res.maxUsablePoints
+ accountPoints.calcRes = res
+ accountPoints.num = res.maxUsablePoints
return res;
}
- watch(()=>accountPoints.sel,(newval)=>{
- if(newval){
+ watch(() => accountPoints.sel, (newval) => {
+ if (newval) {
calcUsablePoints()
}
})
- async function calcDeDuctionPoints(){
- const res=await Api.$calcDeDuctionPoints({
+ async function calcDeDuctionPoints() {
+ const res = await Api.$calcDeDuctionPoints({
memberId: order.memberId,
orderAmount: order.amount,
points: accountPoints.num
})
- accountPoints.price=res
+ accountPoints.price = res
return res
}
- watch(()=>accountPoints.num,(newval)=>{
- if(!newval){
- accountPoints.price=0
- return
+ watch(() => accountPoints.num, (newval) => {
+ if (!newval) {
+ accountPoints.price = 0
+ return
}
calcDeDuctionPoints()
})
-
+
function changeAccountPoints() {
- if(!accountPoints.calcRes.usable){
+ if (!accountPoints.calcRes.usable) {
return
}
accountPoints.sel = !accountPoints.sel
@@ -297,7 +304,8 @@
}
go.to('PAGES_ORDER_QUAN', {
orderId: order.id,
- memberId: order.memberId
+ memberId: order.memberId,
+ orderPrice: payPrice.value*1+coupAllPrice.value*1
})
}
async function discountShow() {
@@ -320,7 +328,6 @@
// }
// return false
})
- let payStatus = ref(null) //loading success
let timer = null
@@ -385,7 +392,32 @@
uni.$off('choose-quan')
uni.$on('choose-quan', (arr) => {
console.log(arr);
- pays.quan = arr
+ const manjianCoup = arr.filter(v => v.type == 1)
+ let productCoup = arr.filter(v => v.type == 2)
+ console.log(productCoup);
+ //商品券分组
+ let coupMap={}
+ for(let i in productCoup){
+ const coup=productCoup[i]
+ if(coupMap.hasOwnProperty(coup.proId)){
+ coupMap[coup.proId].push(coup)
+ }else{
+ coupMap[coup.proId]=[coup]
+ }
+ }
+ for(let key in coupMap){
+ const arr=coupMap[key]
+ for(let i in arr){
+ const coup=arr[i]
+ const proCoupStartIndex=returnProCoupStartIndex(arr,i)
+ console.log(proCoupStartIndex);
+ console.log($goodsPayPriceMap[coup.proId]);
+ coup.discountAmount=returnProductCoupAllPrice($goodsPayPriceMap[coup.proId],proCoupStartIndex,coup.num)
+ console.log(coup.discountAmount);
+ }
+ }
+ console.log(productCoup);
+ pays.quan = [...manjianCoup, ...productCoup]
})
}
@@ -427,13 +459,13 @@
const discount = reactive({
})
-
+
function editDiscountConfirm(form) {
console.log(form);
Object.assign(discount, form)
getPayUrl()
}
-
+
async function getPayType() {
const payTypeList = await Api.$getPayType()
pays.payTypes.list = payTypeList
@@ -445,9 +477,11 @@
chooseUser()
}
}
+ let payStatus = '';
//支付成功回调
function paySuccess() {
infoBox.showToast('支付成功')
+ payStatus = 'success'
setTimeout(() => {
// uni.$emit('orderDetail:update')
payFinish.value = true
@@ -467,35 +501,44 @@
}
payOrder()
}
+ const tipsMap = {
+ paying: '支付中',
+ success: '已支付成功'
+ }
async function payOrder() {
const payType = pays.payTypes.list[pays.payTypes.selIndex].payType
if (payType == 'vipPay' && user.value.amount * 1 < order.amount * 1) {
infoBox.showToast('余额不足')
return
}
- await Api.$payOrder({
- tableId: order.tableId,
- masterId: order.masterId,
- orderId: order.id || order.orderId,
- payType,
- vipUserId: order.memberId,
- discount: 1,
- code: '',
- pointsNum:accountPoints.sel?accountPoints.num:0,
- userCouponInfos:pays.quan.map(v=>{
- return {
- userCouponId:v.id,
- num:v.num
- }
+ if (payStatus) {
+ return infoBox.showToast(tipsMap[payStatus])
+ }
+ try {
+ payStatus = 'paying'
+ await Api.$payOrder({
+ tableId: order.tableId,
+ masterId: order.masterId,
+ orderId: order.id || order.orderId,
+ payType,
+ vipUserId: order.memberId,
+ discount: 1,
+ code: '',
+ pointsNum: accountPoints.sel ? accountPoints.num : 0,
+ userCouponInfos: pays.quan.map(v => {
+ return {
+ userCouponId: v.id,
+ num: v.num
+ }
+ })
})
-
- })
- paySuccess()
+ paySuccess()
+ } catch (e) {
+ //TODO handle the exception
+ payStatus = ''
+ }
}
- onMounted(() => {
- getPayType()
- })
const order = reactive({
amount: 0
})
@@ -539,6 +582,8 @@
async function init() {
const orderRes = await orderApi.tbOrderInfoDetail(order.orderId)
Object.assign(order, orderRes)
+ $goodsPayPriceMap=returnGoodsPayPriceMap(order.detailList)
+ console.log($goodsPayPriceMap);
if (orderRes.memberId) {
calcUsablePoints()
queryAllShopUser({
@@ -549,7 +594,6 @@
}
})
}
- getPayUrl()
}
function getPayUrl() {
@@ -560,37 +604,36 @@
payCodeUrl.value = res
})
}
- const coupAllPrice=computed(()=>{
- return pays.quan.reduce((prve,cur)=>{
- return prve+cur.discountAmount*1
- },0)
+ const coupAllPrice = computed(() => {
+ return pays.quan.reduce((prve, cur) => {
+ return prve + cur.discountAmount * 1
+ }, 0)
})
- const payPrice=computed(()=>{
- const discountPrice=discount.currentPrice?discount.currentPrice:order.amount
- const calcPrice=discountPrice-coupAllPrice.value-accountPoints.price*(accountPoints.sel?1:0)
- return (calcPrice<=0?0:calcPrice).toFixed(2)
+ const payPrice = computed(() => {
+ const discountPrice = discount.currentPrice ? discount.currentPrice : order.amount
+ const calcPrice = discountPrice - coupAllPrice.value - accountPoints.price * (accountPoints.sel ? 1 : 0)
+ return (calcPrice <= 0 ? 0 : calcPrice).toFixed(2)
})
- watch(()=>payPrice.value,()=>{
+ watch(() => payPrice.value, () => {
getPayUrl()
})
- const pointCanDicountPrice=computed(()=>{
- const discountPrice=discount.currentPrice?discount.currentPrice:order.amount
- const calcPrice=discountPrice-coupAllPrice.value
- return (calcPrice<=0?0:calcPrice).toFixed(2)
+ const pointCanDicountPrice = computed(() => {
+ const discountPrice = discount.currentPrice ? discount.currentPrice : order.amount
+ const calcPrice = discountPrice - coupAllPrice.value
+ return (calcPrice <= 0 ? 0 : calcPrice).toFixed(2)
})
- watch(()=>pointCanDicountPrice.value,(newval)=>{
+ watch(() => pointCanDicountPrice.value, (newval) => {
calcUsablePoints()
})
-
+
onLoad(async (opt) => {
console.log(opt);
option = opt
Object.assign(order, opt)
- const payTypeList = await Api.$getPayType()
- pays.payTypes.list = payTypeList
+ getPayType()
init()
})
-
+
onBeforeUnmount(() => {
console.log('onBeforeUnmount');
clear()
diff --git a/pagesOrder/quan/quan.vue b/pagesOrder/quan/quan.vue
index 359bbdc..132da06 100644
--- a/pagesOrder/quan/quan.vue
+++ b/pagesOrder/quan/quan.vue
@@ -6,9 +6,11 @@
+ v-for="(item,index) in myQuan.res.fullReductionCoupon" :class="{filtergray:!item.use}" :key="index">
+
+
+
@@ -70,9 +72,9 @@
-
+
去使用
@@ -90,10 +92,24 @@
-
- 抵扣金额:
- ¥
- {{discountAmount}}
+
+
+
+ 抵扣金额:
+ ¥
+ {{discountAmount}}
+
+
+ 支付金额:
+ ¥
+ {{payPrice }}
+
+
+ ¥
+ {{option.orderPrice}}
+
+
+
@@ -105,7 +121,12 @@
+
+
+