diff --git a/commons/utils/goodsUtil.js b/commons/utils/goodsUtil.js
index b0e821d..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,18 +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'
+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 numSum(arr){
- const sum=arr.reduce((a,b)=>{
- return a+b*100
- },0)
- return (sum/100).toFixed(2)
+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)
}
\ 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/components/my-components/my-date-pickerview.vue b/components/my-components/my-date-pickerview.vue
index 0e1d466..0ea73ad 100644
--- a/components/my-components/my-date-pickerview.vue
+++ b/components/my-components/my-date-pickerview.vue
@@ -389,9 +389,10 @@
const year = years[arr[0]]
const month = arr[1] + 1
const day = arr[2] + 1
- const hour = ('0' + arr[3]).slice(-2)
- const min = ('0' + arr[4]).slice(-2)
- const sen = ('0' + arr[5]).slice(-2)
+ const hour = ('0' + (arr[3]||0)).slice(-2)
+ console.log(hour)
+ const min = ('0' + (arr[4]||0)).slice(-2)
+ const sen = ('0' + (arr[5]||0)).slice(-2)
if (isObj) {
return new Date(year, month, day, hour, min, sen)
}
@@ -400,6 +401,7 @@
function confirm(e) {
+ console.log(value.value);
const start = returnDateString(value.value)
console.log(start);
const end = returnDateString(value1.value)
diff --git a/http/yskApi/Instead.js b/http/yskApi/Instead.js
index 3221307..d964201 100644
--- a/http/yskApi/Instead.js
+++ b/http/yskApi/Instead.js
@@ -331,4 +331,62 @@ export function $returnOrder(data) {
...data
}
});
+}
+
+//获取订单可用优惠券
+export function $activateByOrderId(data) {
+ return request({
+ url: '/api/tbShopCoupon/activateByOrderId',
+ method: "get",
+ params:{
+ shopId: uni.getStorageSync("shopId"),
+ ...data
+ }
+ });
+}
+
+//会员积分列表
+export function $returnMemberPointsList(data) {
+ return request({
+ url: '/api/points/member-points/page',
+ method: "get",
+ params:{
+ shopId: uni.getStorageSync("shopId"),
+ ...data
+ }
+ });
+}
+
+// 会员积分账户信息
+export function $returnMemberPoints(memberId) {
+ return request({
+ url: '/api/points/member-points/'+memberId,
+ method: "get",
+ params:{
+ shopId: uni.getStorageSync("shopId"),
+ ...data
+ }
+ });
+}
+//002-获取订单可用积分及抵扣金额(支付页面使用)
+export function $calcUsablePoints(data) {
+ return request({
+ url: '/api/points/member-points/calc-usable-points',
+ method: "get",
+ params:{
+ shopId: uni.getStorageSync("shopId"),
+ ...data
+ }
+ });
+}
+// 003-根据积分计算可抵扣金额
+export function $calcDeDuctionPoints(data) {
+ return request({
+ url: '/api/points/member-points/calc-deduction-amount',
+ method: "get",
+ params:{
+ shopId: uni.getStorageSync("shopId"),
+ ...data
+ }
+ });
}
\ No newline at end of file
diff --git a/http/yskApi/http.js b/http/yskApi/http.js
index 67aef22..2f109f3 100644
--- a/http/yskApi/http.js
+++ b/http/yskApi/http.js
@@ -17,10 +17,10 @@ import infoBox from "@/commons/utils/infoBox.js"
import go from '@/commons/utils/go.js';
import { reject } from 'lodash';
// 测试服
-let baseUrl = 'https://admintestpapi.sxczgkj.cn'
+// let baseUrl = 'https://admintestpapi.sxczgkj.cn'
//预发布
-// let baseUrl = 'https://pre-cashieradmin.sxczgkj.cn'
+let baseUrl = 'https://pre-cashieradmin.sxczgkj.cn'
//正式
// let baseUrl = 'https://cashieradmin.sxczgkj.cn'
diff --git a/pageProduct/add-Product/add-Product - 副本.vue b/pageProduct/add-Product/add-Product - 副本.vue
index f9ec7b6..e08499a 100644
--- a/pageProduct/add-Product/add-Product - 副本.vue
+++ b/pageProduct/add-Product/add-Product - 副本.vue
@@ -1,189 +1,845 @@
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{category.list[FormData.category]||'分类'}}
-
-
-
-
-
-
-
-
-
- {{FormData.specificationsGroup||'添加规格组'}}
-
-
-
-
-
-
-
-
-
-
- {{salesMethod.list[FormData.salesMethod]||'售卖方式'}}
-
-
-
-
-
-
- 库存
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
- 打折设置
-
-
+
+
+
+
+ 注:第一张图为商品封面图,图片尺寸为750x750
-
-
-
-
+
+
-
-
-
- 不参与会员折扣
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
- 每日销量上限
-
+
-
-
-
-
- 每单限购
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 设为推荐
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 名称
+ 操作
+
+
+
+
+ {{item.name}}
+
+
+
+
+
+
+
+
+
+ 添加团购券分类
+
+
+
+
+
+
+
+
+
+
+
+
+ 选择规格
+ 编辑规格
+
+
+
+ {{FormData.specsInfoName}}
+ 请选择
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 套餐商品
+
+
+
+
+
+
+
+ 商品信息
+
+
+ 名称
+ 数量
+ 操作
+
+
+
+
+ {{product.name}}
+
+
+
+
+ x1
+
+
+
+
+
+
+
+
+ 添加商品
+
+
+
+
+
+
+
+
+
+
+ 删除分组
+
+
+
+
+
+
+ 添加分组
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 上架
+
+
+
+
+
+
+ 库存开关
+
+
+ 注:关闭则不计算出入库数据
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 设为推荐
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 删除该商品
+
-
-
-
+
+
+ 保存
+
+
+
-
- 删除该商品
-
-
+
-
-
-
+
+
+
+
+
+
+
+
+ 确定
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pageProduct/add-Product/add-Product.vue b/pageProduct/add-Product/add-Product.vue
index e08499a..dad2fe6 100644
--- a/pageProduct/add-Product/add-Product.vue
+++ b/pageProduct/add-Product/add-Product.vue
@@ -846,7 +846,7 @@
},
{
minLength: 1,
- maxLength: 20,
+ maxLength: 40,
errorMessage: '商品名称长度在 {minLength} 到 {maxLength} 个字符',
}
]
@@ -1375,7 +1375,7 @@
for (let i of FormData.specificationsGroup.selectSpec) {
if (i.selectSpecResult.length) {
skuSnap.push({
- label: i.name,
+ name: i.name,
value: i.selectSpecResult.join(',')
})
}
diff --git a/pageProduct/index/components/edit-price.vue b/pageProduct/index/components/edit-price.vue
index 79f676a..f4c77eb 100644
--- a/pageProduct/index/components/edit-price.vue
+++ b/pageProduct/index/components/edit-price.vue
@@ -227,7 +227,9 @@
// }
onMounted(()=>{
+ // #ifndef H5
refForm.value.setRules(rules)
+ // #endif
})
diff --git a/pageProduct/index/components/edit-stock.vue b/pageProduct/index/components/edit-stock.vue
index 79a407b..cbd9303 100644
--- a/pageProduct/index/components/edit-stock.vue
+++ b/pageProduct/index/components/edit-stock.vue
@@ -256,7 +256,9 @@
// }
onMounted(()=>{
+ // #ifndef H5
refForm.value.setRules(rules)
+ // #endif
})
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 @@
{{to2(allPrice*1+seatFeePrice*1+packFee*1) }}
@@ -137,20 +165,93 @@
重新打印
+
+
+ 优惠详情
+
+
+ 满减券抵扣
+
+ ¥
+ {{orderInfo.fullCouponDiscountAmount}}
+
+
+
+ 商品券抵扣
+
+ ¥
+ {{orderInfo.productCouponDiscountAmount||productCoupPrice}}
+
+
+
+ 积分抵扣
+
+ ¥
+ {{orderInfo.pointsDiscountAmount}}
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pagesOrder/pay-order/pay-order.vue b/pagesOrder/pay-order/pay-order.vue
index ed2d9c2..cfd15d8 100644
--- a/pagesOrder/pay-order/pay-order.vue
+++ b/pagesOrder/pay-order/pay-order.vue
@@ -1,36 +1,76 @@
-
- ¥
- {{discount.currentPrice?discount.currentPrice:order.amount}}
-
-
- ¥
- {{order.amount}}
-
-
- 修改
-
+
+
+ ¥
+
+ {{payPrice}}
+
+
+ ¥
+ {{order.amount}}
+
+
+ 修改
+
+
+
+
+ ¥
+ {{order.amount}}
+
+
+ 修改
+
+
+
-
- 优惠券
-
- 选择优惠券
-
-
+
+
+ 优惠券
+
+ 选择优惠券
+
+
+
+
+
+
+
+
+ 减
+ {{item.name}}
+ x{{item.num}}
+
+
+ -¥{{item.discountAmount}}
+
+
+
+
+
+
+
+
+ 服务员改价
+
+ -¥{{to2(order.amount- discount.currentPrice)}}
+
+
+
+ 积分抵扣
+
+ -¥{{to2(accountPoints.price)}}
-
- 服务员改价
-
- -¥{{to2(order.amount- discount.currentPrice)}}
-
-
+
@@ -45,7 +85,7 @@
{{item.payName}}
-
+
会员:
{{user.telephone||user.nickName}}
@@ -54,6 +94,10 @@
余额:
¥{{user.amount||'0'}}
+
@@ -62,6 +106,51 @@
+
+
+
+ 积分抵扣
+
+ (
+ {{user.accountPoints||'0'}}
+ )
+
+
+
+
+
+
+ {{accountPoints.num}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ *
+ {{accountPoints.calcRes.unusableReason}}
+
+
+ *
+ 100积分等于{{to2(accountPoints.calcRes.equivalentPoints*100)}}元,
+
+ 最大抵扣积分{{accountPoints.calcRes.maxUsablePoints}}
+
+ ,
+ 最小抵扣积分0
+
+
+
确认付款
@@ -81,7 +170,7 @@
- ¥{{discount.currentPrice?discount.currentPrice: order.amount}}
+ ¥{{payPrice}}
@@ -106,6 +195,8 @@
+
+
@@ -115,29 +206,121 @@
onMounted,
watch,
ref,
- onBeforeUnmount
+ onBeforeUnmount,
+ computed
} from 'vue';
import {
onLoad,
- onBackPress,onShow
+ onBackPress,
+ onShow
} from '@dcloudio/uni-app'
import go from '@/commons/utils/go.js'
import * as Api from '@/http/yskApi/Instead.js'
import {
queryAllShopUser
} from '@/http/yskApi/shop-user.js'
- import {hasPermission} from '@/commons/utils/hasPermission.js'
+ import {
+ hasPermission
+ } from '@/commons/utils/hasPermission.js'
import * as orderApi from '@/http/yskApi/order.js'
import infoBox from '@/commons/utils/infoBox.js'
import editDiscount from '@/components/my-components/edit-discount.vue'
- async function discountShow(){
- const bol=await hasPermission('yun_xu_da_zhe')
- if(bol){
- showModel('editMoney',true)
+ 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) {
+ return
+ }
+ refPoints.value.open()
+ }
+ const accountPoints = reactive({
+ sel: false,
+ num: 0,
+ calcRes: {
+ usable: false,
+ unusableReason: '',
+ minDeductionPoints: 0,
+ maxUsablePoints: 0
+ },
+ price: 0
+ })
+ function pointsConfirm(e){
+ accountPoints.num=e
+ }
+ async function calcUsablePoints() {
+ if (!order.memberId) {
+ return
+ }
+ const res = await Api.$calcUsablePoints({
+ memberId: order.memberId,
+ orderAmount: pointCanDicountPrice.value
+ })
+ accountPoints.calcRes = res
+ accountPoints.num = res.maxUsablePoints
+ return res;
+ }
+ watch(() => accountPoints.sel, (newval) => {
+ if (newval) {
+ calcUsablePoints()
+ }
+ })
+ async function calcDeDuctionPoints() {
+ const res = await Api.$calcDeDuctionPoints({
+ memberId: order.memberId,
+ orderAmount: order.amount,
+ points: accountPoints.num
+ })
+ accountPoints.price = res
+ return res
+ }
+ watch(() => accountPoints.num, (newval) => {
+ if (!newval) {
+ accountPoints.price = 0
+ return
+ }
+ calcDeDuctionPoints()
+ })
+
+ function changeAccountPoints() {
+ if (!accountPoints.calcRes.usable) {
+ return
+ }
+ accountPoints.sel = !accountPoints.sel
+ if (!accountPoints.sel) {
+ accountPoints.num = 0
}
}
- let option = {isNowPay:false}
- let payFinish=ref(false)
+
+ function toQuan() {
+ console.log(order);
+ if (!order.memberId) {
+ return infoBox.showToast('请先选择会员', 0.5).then(() => {
+ chooseUser()
+ })
+ }
+ go.to('PAGES_ORDER_QUAN', {
+ orderId: order.id,
+ memberId: order.memberId,
+ orderPrice: payPrice.value*1+coupAllPrice.value*1
+ })
+ }
+ async function discountShow() {
+ const bol = await hasPermission('yun_xu_da_zhe')
+ if (bol) {
+ showModel('editMoney', true)
+ }
+ }
+ let option = {
+ isNowPay: false
+ }
+ let payFinish = ref(false)
onBackPress(() => {
uni.$emit('orderDetail:update')
console.log('onBackPress');
@@ -148,7 +331,6 @@
// }
// return false
})
- let payStatus = ref(null) //loading success
let timer = null
@@ -173,41 +355,78 @@
payTypes: {
list: [],
selIndex: 0
- }
+ },
+ quan: []
})
-
+
function chooseUser() {
go.to('PAGES_CHOOSE_USER')
}
//更新选择用户
- function setUser(par) {
+ function setUser(par) {
console.log(option);
const submitPar = {
tableId: order.tableId,
+ orderId: order.id,
masterId: order.masterId,
vipUserId: user.value.id ? user.value.id : '',
- orderId:order.id,
type: user.value.id ? 0 : 1 //0 设置 1 取消
}
Object.assign(submitPar, par)
return Api.$setUser(submitPar)
}
+
function watchChooseuser() {
uni.$off('choose-user')
uni.$on('choose-user', (data) => {
console.log(data);
- setUser({
- vipUserId: data.id ? data.id : '',
- type: data.id ? 0 : 1 //0 设置 1 取消
- }).then(res=>{
- user.value = data
- order.memberId=data.id
- init()
- })
+ setUser({
+ vipUserId: data.id ? data.id : '',
+ type: data.id ? 0 : 1 //0 设置 1 取消
+ }).then(res => {
+ user.value = data
+ order.memberId = data.id
+ init()
+ })
})
}
- onShow(()=>{
+
+ function watchChooseQuan() {
+ uni.$off('choose-quan')
+ uni.$on('choose-quan', (arr) => {
+ console.log(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]
+ })
+ }
+
+ onShow(() => {
watchChooseuser()
+ watchChooseQuan()
})
watch(() => pays.selIndex, (newval) => {
@@ -249,6 +468,7 @@
Object.assign(discount, form)
getPayUrl()
}
+
async function getPayType() {
const payTypeList = await Api.$getPayType()
pays.payTypes.list = payTypeList
@@ -256,16 +476,18 @@
function changePayType(i, item) {
pays.payTypes.selIndex = i
- if (item.payType == 'vipPay' ) {
- chooseUser()
+ if (item.payType == 'vipPay') {
+ chooseUser()
}
}
+ let payStatus = '';
//支付成功回调
function paySuccess() {
infoBox.showToast('支付成功')
+ payStatus = 'success'
setTimeout(() => {
// uni.$emit('orderDetail:update')
- payFinish.value=true
+ payFinish.value = true
uni.$emit('get:table')
uni.$emit('update:orderDetail')
uni.navigateBack({
@@ -282,27 +504,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
+ infoBox.showToast('余额不足')
+ return
+ }
+ 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()
+ } catch (e) {
+ //TODO handle the exception
+ payStatus = ''
}
- await Api.$payOrder({
- tableId: order.tableId,
- masterId: order.masterId,
- orderId: order.id || order.orderId,
- payType,
- vipUserId: order.memberId,
- discount: 1,
- code: ''
- })
- paySuccess()
}
- onMounted(() => {
- getPayType()
- })
const order = reactive({
amount: 0
})
@@ -346,41 +585,76 @@
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({
id: orderRes.memberId
}).then(res => {
- if(res.content[0]){
- user.value =res.content[0]
+ if (res.content[0]) {
+ user.value = res.content[0]
}
})
}
- getPayUrl()
}
function getPayUrl() {
orderApi.$getOrderPayUrl({
orderId: order.id,
- payAmount: discount.currentPrice ? discount.currentPrice : order.amount
+ payAmount: payPrice.value
}).then(res => {
payCodeUrl.value = res
})
}
+ 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)
+ })
+ 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)
+ })
+ 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()
})
+ .no-use {
+ position: absolute;
+ left: 0;
+ right: 0;
+ top: 0;
+ bottom: 0;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+
+ .img {
+ width: 200rpx;
+ height: 200rpx;
+ z-index: 10;
+ }
+ }
+
+ .fixed-b {
+ position: fixed;
+ bottom: 0;
+ background-color: #fff;
+ right: 0;
+ left: 0;
+ }
+
+ .bg-gray {
+ border-radius: 18rpx;
+ overflow: hidden;
+ }
+
+ .price1 {
+ color: rgb(255, 107, 0);
+ }
+
+ .payType {
+ .radio {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ background-color: rgb(255, 212, 0);
+ width: 40rpx;
+ height: 40rpx;
+ border-radius: 40rpx;
+ opacity: 0;
+
+ }
+
+ .active {
+ .radio {
+ opacity: 1;
+ }
+ }
+ }
+
+ .left-block {
+ position: relative;
+
+ &::after {
+ content: '';
+ position: absolute;
+ left: -30rpx;
+ display: block;
+ width: 12rpx;
+ top: 0;
+ background-color: rgb(255, 212, 0);
+ bottom: 0;
+ }
+ }
+
+ .filtergray {
+ filter: grayscale(1);
+ }
+
+ .radio {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ background-color: rgb(255, 255, 255);
+ width: 40rpx;
+ height: 40rpx;
+ border-radius: 40rpx;
+
+ &.active {}
+ }
+
+ .use-btn {
+ background-color: #fff;
+ border-radius: 100rpx;
+ padding: 4rpx 20rpx;
+ color: $quan-color;
+ }
+
+ .u-font-40 {
+ font-size: 40rpx;
+ }
+
+ .yilingqu {
+ position: absolute;
+ bottom: 20rpx;
+ right: 20rpx;
+ }
+
+ .lingqu {
+ position: absolute;
+ bottom: 20rpx;
+ right: 20rpx;
+ background-color: rgb(255, 207, 0);
+ padding: 10rpx 30rpx;
+ border-radius: 100rpx;
+ }
+
+ .btn {
+ background-color: $my-main-color;
+ color: #fff;
+ border: none;
+ padding: 10rpx 20rpx;
+ border-radius: 10rpx;
+ }
+
+ .hui {
+ // background-color: $quan-color;
+ background-image: linear-gradient(to right bottom, rgb(254, 103, 4), rgb(241, 50, 42));
+ padding: 4rpx 10rpx;
+ border-radius: 10rpx;
+ font-size: 24rpx;
+ color: #fff;
+ }
+
+ .quan {
+ border: 1px solid rgb(238, 238, 238);
+ position: relative;
+ border-radius: 10rpx;
+ box-shadow: 0 0 5px #eee;
+ overflow: hidden;
+
+ .sel {
+ padding: 2rpx 4rpx;
+ position: absolute;
+ background-color: $quan-color;
+ left: 0;
+ top: 0;
+ border-radius: 0 0 24rpx 0;
+ }
+
+ .right {
+ position: absolute;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ padding: 20rpx 24rpx;
+ color: #fff;
+ display: flex;
+ flex-direction: column;
+ background-color: $quan-color;
+ height: 100%;
+ }
+
+ &.goods {
+ .right {
+ background-color: #fff;
+ position: initial;
+
+ .use-btn {
+ padding: 10rpx 40rpx;
+ color: #fff;
+ background-color: $quan-color;
+ }
+ }
+ }
+ }
+
+ .bottom {
+ padding: 30rpx 30rpx 80rpx 30rpx;
+ }
+
\ No newline at end of file
diff --git a/pagesOrder/quan_util.js b/pagesOrder/quan_util.js
new file mode 100644
index 0000000..ff5bd96
--- /dev/null
+++ b/pagesOrder/quan_util.js
@@ -0,0 +1,206 @@
+export function isTui(item) {
+ return item.status == 'return' || item.status == 'refund' || item.status == 'refunding'
+}
+//是否使用会员价
+export function isUseVipPrice(vipUser,goods){
+ return vipUser.id&&vipUser.isVip&&goods.isMember
+}
+
+//计算商品券优惠价格
+export function returnProductCouponPrice(coup, goodsArr, vipUser) {
+ const item = goodsArr.find(v => v.productId == coup.proId);
+ if (!item) {
+ return 0
+ }
+ const memberPrice = item.memberPrice ? item.memberPrice : item.price;
+ const price = item ? (isUseVipPrice(vipUser,item) ? memberPrice : item.price) : 0;
+ return price * coup.num
+
+}
+//返回新的商品列表,过滤掉退菜的,退单的商品
+export function returnNewGoodsList(arr) {
+ let goodsMap = {}
+ return arr.filter(v => !isTui(v))
+}
+//根据当前购物车商品以及数量,已选券对应商品数量,判断该商品券是否可用
+export function returnCoupCanUse(goodsArr = [], coup, selCoupArr = []) {
+ // if(!coup.use){
+ // return false
+ // }
+ const findGoods = goodsArr.filter(v => v.productId == coup.proId)
+ if (!findGoods.length) {
+ return false
+ }
+ const findGoodsTotalNumber = findGoods.reduce((prve, cur) => {
+ return prve + cur.num * 1
+ }, 0)
+ const selCoupNumber = selCoupArr.filter(v => v.proId == coup.proId).reduce((prve, cur) => {
+ return prve + cur.num * 1
+ }, 0)
+ if (selCoupNumber >= findGoodsTotalNumber) {
+ return false
+ }
+ return findGoodsTotalNumber < (coup.num + selCoupNumber) ? false : true
+}
+//查找购物车商品根据购物车商品数据返回商品券信息(抵扣价格以及是否满足可用需求)
+export function returnProductCoupon(coup, goodsArr, vipUser, selCoupArr = []) {
+ const newGoodsArr = returnNewGoodsList(goodsArr)
+ const item = newGoodsArr.find(v => v.productId == coup.proId);
+ if (!item) {
+ return {
+ ...coup,
+ discountAmount: 0,
+ use: false
+ }
+ }
+ const memberPrice = item.memberPrice ? item.memberPrice : item.price;
+ const price = item ? (isUseVipPrice(vipUser,item) ? memberPrice : item.price) : 0;
+ const discountAmount = (price * coup.num).toFixed(2)
+ console.log(discountAmount);
+
+ const canUse = !coup.use ? false : (discountAmount > 0 && returnCoupCanUse(goodsArr, coup, selCoupArr))
+ // const canUse=discountAmount>0
+ return {
+ ...coup,
+ discountAmount: discountAmount,
+ use: canUse
+ }
+
+}
+/**
+ * 根据购物车商品计算商品券抵扣价格以及是否满足可用需求
+ * 1.商品券对应商品数量大于购物车对应商品数量不可用
+ * 2.未在购物车找到相关商品不可用
+ * @param {*} coupArr
+ * @param {*} goodsArr
+ * @param {*} vipUser
+ * @returns
+ */
+export function returnProductAllCoup(coupArr, goodsArr, vipUser) {
+ return coupArr.map((v) => {
+ return returnProductCoupon(v, goodsArr, vipUser)
+ })
+
+}
+//返回商品实际支付价格
+export function returnProductPayPrice(goods,vipUser){
+ const memberPrice = goods.memberPrice ? goods.memberPrice : goods.price;
+ const price = isUseVipPrice(vipUser,goods) ? memberPrice : goods.price;
+ return price
+}
+//返回商品券抵扣的商品价格
+export function returnProductCoupAllPrice(productPriceArr,startIndex,num){
+ return productPriceArr.slice(startIndex,startIndex+num).reduce((prve,cur)=>{
+ let curPrice=0
+ if(typeof cur==='object'){
+ curPrice=cur.memberPrice*1
+ }else{
+ curPrice=cur*1
+ }
+ return prve+curPrice
+ },0)
+}
+//返回同类商品券在同类商品价格数组里的开始位置
+export function returnProCoupStartIndex(coupArr,index){
+ return coupArr.slice(0,index).reduce((prve,cur)=>{
+ return prve+cur.num*1
+ },0)
+}
+//返回商品数量从0到n每一个对应的价格对照表
+export function returnGoodsPayPriceMap(goodsArr){
+ return goodsArr.reduce((prve,cur)=>{
+ if(!prve.hasOwnProperty(cur.productId)){
+ prve[cur.productId]=[]
+ }
+ const arr=new Array(cur.num).fill(cur).map(v=>{
+ return {
+ memberPrice:v.memberPrice?v.memberPrice:v.price,
+ price:v.price
+ }
+ })
+ prve[cur.productId].push(...arr)
+ return prve
+ },{})
+}
+//计算商品券总优惠价格
+export function returnProductCouponAllPrice(coupArr, goodsArr, vipUser) {
+ if (coupArr.length == 0) {
+ return 0;
+ }
+ //商品分组
+ const goodsMap={}
+ //商品数量从0到n每一个对应的价格
+ const goodsPayPriceMap={}
+ //商品券分组
+ let coupMap={}
+ for(let i in coupArr){
+ const coup=coupArr[i]
+ if(coupMap.hasOwnProperty(coup.proId)){
+ coupMap[coup.proId].push(coup)
+ }else{
+ coupMap[coup.proId]=[coup]
+ }
+ }
+ let total=0
+ for(let key in coupMap){
+ const arr=coupMap[key]
+ for(let i in arr){
+ const coup=arr[i]
+ if(!goodsMap.hasOwnProperty(coup.proId)){
+ goodsMap[coup.proId]=goodsArr.filter(v=>v.productId==coup.proId).map(v=>{
+ return {
+ ...v,
+ payPrice:returnProductPayPrice(v,vipUser)
+ }
+ }).sort((a,b)=>{
+ const aPrice=a.payPrice
+ const bPrice=b.payPrice
+ return aPrice-bPrice
+ })
+ goodsPayPriceMap[coup.proId]=goodsMap[coup.proId].reduce((prve,cur)=>{
+ const arr=new Array(cur.num).fill(cur.payPrice)
+ console.log(arr);
+ prve.push(...arr)
+ return prve
+ },[])
+ }
+ const proCoupStartIndex=returnProCoupStartIndex(arr,i)
+ console.log(proCoupStartIndex);
+ total+=returnProductCoupAllPrice(goodsPayPriceMap[coup.proId],proCoupStartIndex,coup.num)
+ }
+ }
+
+ return total.toFixed(2);
+
+}
+//计算满减券总优惠价格
+export function returnFullReductionCouponAllPrice(coupArr) {
+ if (coupArr.length == 0) {
+ return 0;
+ }
+ return coupArr.filter(v => v.type == 1).reduce((a, b) => {
+ const price = b.discountAmount
+ return a + price;
+ }, 0).toFixed(2);
+
+}
+//计算优惠券总价格
+export function returnCouponAllPrice(coupArr, goodsArr, vipUser) {
+ const poductAllprice = returnProductCouponAllPrice(coupArr, goodsArr, vipUser)
+ const pointAllPrice = returnFullReductionCouponAllPrice(coupArr)
+ return (poductAllprice * 1 + pointAllPrice * 1).toFixed(2);
+}
+
+//返回当前满减券列表可用状态
+export function returnCanUseFullReductionCoupon(coupArr, payPrice, selCoup) {
+ return coupArr.map(v => {
+ if (v.id == selCoup.id) {
+ return v
+ }
+ const isfullAmount = payPrice >= v.fullAmount * 1
+ return {
+ ...v,
+ use: v.use && isfullAmount
+ }
+ })
+}
\ No newline at end of file
diff --git a/pagesOrder/static/image/no-use.svg b/pagesOrder/static/image/no-use.svg
new file mode 100644
index 0000000..a5df700
--- /dev/null
+++ b/pagesOrder/static/image/no-use.svg
@@ -0,0 +1 @@
+
\ No newline at end of file