Compare commits
53 Commits
gh_1.0.0
...
gaohao2.0.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df2125f14e | ||
|
|
8c44bbee30 | ||
| d6fe2eac53 | |||
| 95c404a7f1 | |||
| 33e872afab | |||
| 0366e6d595 | |||
| 757b87f33d | |||
| da7474c9d5 | |||
| cad9e052bc | |||
| 61938a6947 | |||
| 0069b7c6fd | |||
| 3316c470d2 | |||
| 688ff10833 | |||
| 31df2b99d4 | |||
| 7f19b6b586 | |||
| f99fcad9bf | |||
| 6cf47c6365 | |||
| 66685c3d7e | |||
| 173d73ae70 | |||
| 8e201b7554 | |||
| 86e920017b | |||
| 66e415051b | |||
| e0ea0f32b0 | |||
| 94d91a14b4 | |||
| 28cb87202b | |||
| f80de032d8 | |||
| 2776cbe13c | |||
| 40514ef243 | |||
| 09079c3384 | |||
| 16cfbfec63 | |||
| 67f92a91b8 | |||
| c9825f8df7 | |||
| d5dbd51c80 | |||
| 5a63a8324d | |||
| 03d820bc9a | |||
| 0d1d353830 | |||
| cb52b972b9 | |||
| fb84f53029 | |||
| 1bf820be53 | |||
| d6f148c2a9 | |||
| 9167ee9a9b | |||
| 5476a6af41 | |||
| c41f78fca8 | |||
|
|
27deb4db4a | ||
|
|
2a40135ac0 | ||
| 7d39bc2bee | |||
| 2691cf9b53 | |||
| aad78417b8 | |||
| 71535693bb | |||
| e0e5f703a1 | |||
| 7f265b7583 | |||
| 1836a5b10b | |||
| f2f5bac39e |
@@ -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)
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -20,10 +20,10 @@ import { reject } from 'lodash';
|
||||
// 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'
|
||||
// let baseUrl = 'https://cashieradmin.sxczgkj.cn'
|
||||
|
||||
// 王伟本地测
|
||||
// let baseUrl = '/ww'
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
充值设置
|
||||
</view>
|
||||
<view class="boxconstantbox_tow">
|
||||
<text>用户消费结账时,成功充值成功</text>
|
||||
<text>用户消费结账时,成功充值</text>
|
||||
<input class="text" v-model="form.rechargeTimes"></input>
|
||||
<text>倍的金额本单即可享受免单</text>
|
||||
</view>
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<view class="lable">使用门槛</view>
|
||||
<view class="lable">使用门槛2</view>
|
||||
<view class="value">
|
||||
<view>满</view><input v-model="formData.fullAmount" placeholder="填写金额" border="none"></input><view>元</view>,<view>减</view><input v-model="formData.discountAmount" placeholder="填写金额" border="none"></input><view>元</view>
|
||||
<view>满</view><input v-model="formData.fullAmount" type="number" placeholder="填写金额" border="none"></input><view>元</view>,<view>减</view><input v-model="formData.discountAmount" type="number" placeholder="填写金额" border="none"></input><view>元</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -35,13 +35,15 @@
|
||||
<view class="item">
|
||||
<view class="lable">有效期(天)</view>
|
||||
<view class="value">
|
||||
<up-input v-model="formData.validDays" placeholder="填写天数" border="none"></up-input>
|
||||
<up-input v-model="formData.validDays" type="number" placeholder="填写天数" border="none"></up-input>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<view class="lable">隔天生效<up-icon @click="modalShow(1)" name="question-circle" color="#999" size="20" style="margin-left: 10rpx;"></up-icon></view>
|
||||
<view class="lable">隔天生效
|
||||
<!-- <up-icon @click="modalShow(1)" name="question-circle" color="#999" size="20" style="margin-left: 10rpx;"></up-icon> -->
|
||||
</view>
|
||||
<view class="value">
|
||||
<view>隔</view><input v-model="formData.daysToTakeEffect" placeholder="填写天数" border="none" ></input><view>天生效</view>
|
||||
<view>隔</view><input v-model="formData.daysToTakeEffect" type="number" placeholder="填写天数" border="none" ></input><view>天生效</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
@@ -79,7 +81,7 @@
|
||||
<view class="card">
|
||||
<view class="item">
|
||||
<view class="lable">总发放数量
|
||||
<up-icon @click="modalShow(2)" name="question-circle" color="#999" size="20" style="margin-left: 10rpx;"></up-icon>
|
||||
<!-- <up-icon @click="modalShow(2)" name="question-circle" color="#999" size="20" style="margin-left: 10rpx;"></up-icon> -->
|
||||
</view>
|
||||
<view class="value">
|
||||
<up-input v-model="formData.number" placeholder="填写数量" border="none" clearable ></up-input>
|
||||
@@ -311,6 +313,7 @@
|
||||
height: 150rpx;
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
z-index: 9;
|
||||
>button {
|
||||
width: 530rpx;
|
||||
margin: 30rpx 0;
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
<view class="item">
|
||||
<view class="lable">使用门槛</view>
|
||||
<view class="value">
|
||||
<view>满</view><input v-model="formData.fullAmount" placeholder="填写金额" border="none"></input><view>元,可用</view>
|
||||
<view>满</view><input v-model="formData.fullAmount" type="number" placeholder="填写金额" border="none"></input><view>元,可用</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<view class="lable">总发放数量</view>
|
||||
<view class="value">
|
||||
<up-input v-model="formData.number" placeholder="填写数量" border="none" clearable ></up-input>
|
||||
<up-input v-model="formData.number" type="number" placeholder="填写数量" border="none" clearable ></up-input>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -36,10 +36,10 @@
|
||||
<view v-if="item.type == 1"> 满 {{ item.fullAmount }} 元减 {{ item.discountAmount }} 元 </view>
|
||||
<view v-if="item.type == 2"> 满 {{ item.fullAmount }} 元可用 </view>
|
||||
</view>
|
||||
<view>
|
||||
<!-- <view>
|
||||
<view> 领取方式 </view>
|
||||
<view> 用户不可自行领取 </view>
|
||||
</view>
|
||||
</view> -->
|
||||
<view v-if="item.type == 1">
|
||||
<view> 有效期 </view>
|
||||
<view> 领券后{{ item.validDays }}天过期 </view>
|
||||
@@ -197,7 +197,7 @@
|
||||
padding: 32rpx 28rpx;
|
||||
background-color: #fff;
|
||||
position: fixed;
|
||||
top: 79rpx;
|
||||
top: 0rpx;
|
||||
z-index: 999;
|
||||
.tag-item {
|
||||
display: inline-block;
|
||||
@@ -253,7 +253,7 @@
|
||||
/* height: 544rpx; */
|
||||
margin: 32rpx auto 0;
|
||||
margin-bottom: 32rpx;
|
||||
padding: 122rpx 28rpx 182rpx 28rpx;
|
||||
padding: 70rpx 28rpx 182rpx 28rpx;
|
||||
}
|
||||
.couponContent {
|
||||
/* background-color: #f9f9f9; */
|
||||
|
||||
@@ -265,11 +265,12 @@
|
||||
}
|
||||
|
||||
.pageLineUpTop {
|
||||
.df;
|
||||
justify-content: space-around;
|
||||
display: flex;
|
||||
// justify-content: space-around;
|
||||
flex-wrap: wrap;
|
||||
margin: 36rpx 0;
|
||||
|
||||
|
||||
>view {
|
||||
width: 208rpx;
|
||||
height: 136rpx;
|
||||
@@ -277,11 +278,18 @@
|
||||
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
||||
border: 2rpx solid #E5E5E5;
|
||||
margin-top: 20rpx;
|
||||
margin-left: 22rpx;
|
||||
|
||||
>view {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
// >view:last-child {
|
||||
// margin-right: auto;
|
||||
// margin-left: 22rpx;
|
||||
// }
|
||||
|
||||
.active {
|
||||
border: 2rpx solid #318AFE;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -227,7 +227,9 @@
|
||||
// }
|
||||
|
||||
onMounted(()=>{
|
||||
// #ifndef H5
|
||||
refForm.value.setRules(rules)
|
||||
// #endif
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -256,7 +256,9 @@
|
||||
// }
|
||||
|
||||
onMounted(()=>{
|
||||
// #ifndef H5
|
||||
refForm.value.setRules(rules)
|
||||
// #endif
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -89,10 +89,13 @@
|
||||
<script setup>
|
||||
import {
|
||||
getCurrentInstance,
|
||||
onMounted,
|
||||
|
||||
reactive,
|
||||
ref
|
||||
} from 'vue';
|
||||
import {
|
||||
onShow,
|
||||
} from '@dcloudio/uni-app';
|
||||
import go from '@/commons/utils/go.js';
|
||||
import {
|
||||
tbShopPermissionList,
|
||||
@@ -123,7 +126,7 @@
|
||||
[]
|
||||
]);
|
||||
const show = ref(false)
|
||||
onMounted(() => {
|
||||
onShow(() => {
|
||||
// 获取角色信息
|
||||
getrolesEvent()
|
||||
if (props.type == 'add') {
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex-1 u-text-center" >
|
||||
<view class="font-bold color-000 pr-16" >{{data.totalScore}}</view>
|
||||
<view class="font-bold color-000 pr-16" >{{data.accountPoints}}</view>
|
||||
<view class="u-flex u-row-center" >
|
||||
<view class="color-999">积分</view>
|
||||
<view class="u-flex">
|
||||
@@ -56,7 +56,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="u-flex-1 u-text-center" @tap="toUser">
|
||||
<view class="font-bold color-000 pr-16">{{data.totalScore}}</view>
|
||||
<view class="font-bold color-000 pr-16">{{data.accountPoints}}</view>
|
||||
<view class="u-flex u-row-center">
|
||||
<view class="color-999">已消费</view>
|
||||
<view class="u-flex">
|
||||
|
||||
@@ -878,6 +878,7 @@
|
||||
},
|
||||
{
|
||||
"path" : "quan/quan",
|
||||
"pageId": "PAGES_ORDER_QUAN",
|
||||
"style" :
|
||||
{
|
||||
"navigationBarTitleText" : "券包"
|
||||
|
||||
@@ -164,11 +164,11 @@
|
||||
icon: '/static/indexImg/icon-line-up.svg',
|
||||
pageUrl: 'PAGES_LINE_UP'
|
||||
},
|
||||
// {
|
||||
// title: '霸王餐',
|
||||
// icon: '/static/indexImg/icon-bwc.svg',
|
||||
// pageUrl: 'PAGES_BWC'
|
||||
// },
|
||||
{
|
||||
title: '霸王餐',
|
||||
icon: '/static/indexImg/icon-bwc.svg',
|
||||
pageUrl: 'PAGES_BWC'
|
||||
},
|
||||
// {
|
||||
// title: '成员管理',
|
||||
// icon: '/static/indexImg/icon-staff.svg',
|
||||
@@ -184,11 +184,11 @@
|
||||
// icon: '/static/indexImg/icon-cashier.svg',
|
||||
// pageUrl: 'PAGES_SHOP_SETUP',
|
||||
// },
|
||||
// {
|
||||
// title: '优惠券',
|
||||
// icon: '/static/coupon/icon_coupon.svg',
|
||||
// pageUrl: 'PAGES_COUPON_INDEX',
|
||||
// },
|
||||
{
|
||||
title: '优惠券',
|
||||
icon: '/static/coupon/icon_coupon.svg',
|
||||
pageUrl: 'PAGES_COUPON_INDEX',
|
||||
},
|
||||
{
|
||||
title: '订阅通知',
|
||||
icon: '/static/indexImg/icon-notification.svg',
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
<view class="page-gray u-font-28">
|
||||
<view class="search bg-fff u-flex u-col-center ">
|
||||
<view class="u-flex-1">
|
||||
<uni-search-bar bgColor="#F9F9F9" cancelButton="none" placeholder="搜索" @confirm="search"
|
||||
@clear="search"
|
||||
<uni-search-bar bgColor="#F9F9F9" cancelButton="none" placeholder="搜索" @confirm="search" @clear="search"
|
||||
v-model="query.name">
|
||||
</uni-search-bar>
|
||||
</view>
|
||||
@@ -25,7 +24,10 @@
|
||||
<image v-if="item.headImg" :src="item.headImg" class="img" mode=""></image>
|
||||
</view>
|
||||
<view class="u-m-l-32">
|
||||
<view>{{item.nickName}}</view>
|
||||
<view class="u-flex">
|
||||
<view>{{item.nickName}}</view>
|
||||
</view>
|
||||
<view class="u-m-t-12 ">手机号:{{item.telephone}}</view>
|
||||
<view class=" u-font-24 u-m-t-12 u-flex">
|
||||
<text class="color-999" v-if="!item.isVip">非会员</text>
|
||||
<text class="color-main" v-else>会员</text>
|
||||
@@ -35,7 +37,7 @@
|
||||
</view>
|
||||
<view class="u-m-l-30 u-flex">
|
||||
<text class="">积分:</text>
|
||||
<text class="color-main">{{item.totalScore}}</text>
|
||||
<text class="color-main">{{item.accountPoints}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -48,7 +50,7 @@
|
||||
<my-pagination :page="query.page" :totalElements="query.totalElements" :size="query.size"
|
||||
@change="pageChange"></my-pagination>
|
||||
</view>
|
||||
|
||||
|
||||
</template>
|
||||
<template v-if="hasAjax&&list.length<=0">
|
||||
<my-img-empty tips="未找到相关用户"></my-img-empty>
|
||||
@@ -91,7 +93,7 @@
|
||||
headImg: '',
|
||||
telephone: '',
|
||||
amount: '0.00',
|
||||
totalScore: '0.00'
|
||||
accountPoints: '0.00'
|
||||
})
|
||||
} else {
|
||||
list[index].checked = true
|
||||
@@ -107,16 +109,16 @@
|
||||
isVip: 1
|
||||
})
|
||||
const list = reactive([])
|
||||
let hasAjax=ref(false)
|
||||
let hasAjax = ref(false)
|
||||
async function getUser() {
|
||||
const {
|
||||
content,
|
||||
totalElements
|
||||
} = await Api.queryAllShopUser(query)
|
||||
hasAjax.value=true
|
||||
list.length=content.length
|
||||
hasAjax.value = true
|
||||
list.length = content.length
|
||||
for (let i in content) {
|
||||
list[i]={
|
||||
list[i] = {
|
||||
...content[i],
|
||||
checked: false
|
||||
}
|
||||
@@ -126,7 +128,7 @@
|
||||
}
|
||||
|
||||
function pageChange(e) {
|
||||
query.page=e
|
||||
query.page = e
|
||||
getUser()
|
||||
}
|
||||
|
||||
|
||||
@@ -17,15 +17,17 @@
|
||||
<!-- <view class="headeimg">
|
||||
<image class="img" :src="user.headImg" mode=""></image>
|
||||
</view> -->
|
||||
<view class="u-m-l-20">{{user.nickName}}</view>
|
||||
<view class="color-main u-m-l-10 u-font-24">{{user.isVip?'会员':'' }}</view>
|
||||
<view class="u-font-24 u-m-l-30"><text>余额:</text><text
|
||||
<view class="u-m-l-20">
|
||||
<!-- <view class="color-main u-font-24 no-wrap">{{user.isVip?'会员':'' }}</view> -->
|
||||
<view class="">{{user.nickName}}</view>
|
||||
</view>
|
||||
<view class="u-font-24 u-m-l-30 u-text-center"><text>余额:</text><text
|
||||
class="color-main">{{user.amount}}</text>
|
||||
</view>
|
||||
<view class="u-font-24 u-m-l-30"><text>积分:</text><text
|
||||
class="color-main">{{user.totalScore}}</text></view>
|
||||
<view class="u-font-24 u-m-l-30 u-text-center"><text>积分:</text><text
|
||||
class="color-main">{{user.accountPoints}}</text></view>
|
||||
</view>
|
||||
<uni-icons type="right" color="#999" size="16"></uni-icons>
|
||||
<uni-icons type="right" color="#999" size="20" bold></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<view class=" ">
|
||||
@@ -85,11 +87,11 @@
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<view>积分</view>
|
||||
<view class="color-333 u-m-l-10"> {{user.totalScore}}</view>
|
||||
<view class="color-333 u-m-l-10"> {{user.accountPoints}}</view>
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<view>已消费</view>
|
||||
<view class="color-333 u-m-l-10"> 0.00</view>
|
||||
<view class="u-text-center">订单数量</view>
|
||||
<view class="color-333 u-m-l-10">{{user.orderNumber||0}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -160,10 +162,29 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="">
|
||||
<view class="font-bold">
|
||||
<text>¥</text>
|
||||
<text v-if="item.isGift">0</text>
|
||||
<text v-else>{{formatPrice(item.salePrice*item.number) }}</text>
|
||||
<view class=" u-relative">
|
||||
<template v-if="item.isGift">
|
||||
<text class="line-th color-999">¥{{formatPrice(item.salePrice*item.number) }}</text>
|
||||
<view class="u-absolute" style="right: 0;bottom: 100%;">
|
||||
<text class="font-bold">¥0</text>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<template v-if="isVip&&item.memberPrice&&item.memberPrice*1!=item.salePrice*1">
|
||||
<text
|
||||
class="line-th color-999">¥{{formatPrice(item.salePrice*item.number) }}</text>
|
||||
<view class="u-absolute" style="right: 0;bottom: 100%;">
|
||||
<text class="font-bold">¥{{formatPrice(item.memberPrice*item.number) }}</text>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view class="font-bold">
|
||||
<text>¥</text>
|
||||
<text class="">{{formatPrice(item.salePrice*item.number) }}</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
</template>
|
||||
</view>
|
||||
<view class="color-999 u-text-right u-font-24 u-m-t-12">×{{item.number}}</view>
|
||||
</view>
|
||||
@@ -220,10 +241,17 @@
|
||||
|
||||
|
||||
|
||||
<view class="u-flex u-row-right u-m-t-38">
|
||||
<view class="u-flex u-row-between u-m-t-38">
|
||||
<!-- <template v-if="$shop.registerType=='munchies'">
|
||||
<view class="color-main" @tap="showModel('editMoney')">修改</view>
|
||||
</template> -->
|
||||
<view class="u-flex">
|
||||
<view class="u-flex price" v-if="youhui*1>0">
|
||||
<view class="">优惠金额</view>
|
||||
<view class="font-bold u-font-32">¥{{formatPrice(youhui) }}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="u-flex price u-m-l-32">
|
||||
<view class="">实收金额</view>
|
||||
<view class="font-bold u-font-32">¥{{formatPrice(allPrice) }}</view>
|
||||
@@ -342,10 +370,10 @@
|
||||
console.log($shop.value);
|
||||
const maxCapacity = table.value.tableId ? (table.value.maxCapacity || 0) : 100
|
||||
if (table.value.tableId && userNumbers.defaultCateIndex * 1 + 1 > maxCapacity) {
|
||||
uni.showToast({
|
||||
uni.showToast({
|
||||
title: '当前台桌最大人数为: ' + maxCapacity
|
||||
})
|
||||
userNumbers.defaultCateIndex=maxCapacity-1
|
||||
userNumbers.defaultCateIndex = maxCapacity - 1
|
||||
return
|
||||
}
|
||||
if (!$shop.value.isTableFee && table.value.tableId) {
|
||||
@@ -492,10 +520,13 @@
|
||||
totalNumber: 0,
|
||||
totalAmount: 0,
|
||||
})
|
||||
const isVip=computed(()=>{
|
||||
return $shop.value.isMemberPrice&& user.value&&user.value.id&&user.value.isVip
|
||||
})
|
||||
const goodsPrice = computed(() => {
|
||||
const goodsTotalPrice = goods.list.reduce((prve, cur) => {
|
||||
const tPrice = cur.salePrice * cur.number
|
||||
console.log(cur.isPack);
|
||||
const memberPrice=cur.memberPrice?cur.memberPrice:cur.salePrice
|
||||
const tPrice = (isVip.value? memberPrice:cur.salePrice) * cur.number
|
||||
const tpackFee = cur.isPack ? cur.packFee * 1 : 0
|
||||
return prve + (cur.isGift ? 0 : tPrice) + tpackFee
|
||||
}, 0)
|
||||
@@ -510,6 +541,19 @@
|
||||
// }, 0)
|
||||
// return (goodsTotalPrice + ($seatFee.totalAmount || 0)).toFixed(2)
|
||||
})
|
||||
const youhui=computed(()=>{
|
||||
if(user.value&&user.value.id&&user.value.isVip){
|
||||
const goodsTotalPrice = goods.list.reduce((prve, cur) => {
|
||||
const tPrice = cur.salePrice * cur.number
|
||||
const tpackFee = cur.isPack ? cur.packFee * 1 : 0
|
||||
return prve + tPrice + tpackFee
|
||||
}, 0)
|
||||
return goodsTotalPrice-allPrice.value
|
||||
}else{
|
||||
return 0
|
||||
}
|
||||
return goodsTotalPrice
|
||||
})
|
||||
|
||||
function setGoodsItem(key, val) {
|
||||
item[key] = val
|
||||
@@ -529,12 +573,17 @@
|
||||
records,
|
||||
seatFee
|
||||
} = await Api.getCart(par)
|
||||
let useType=''
|
||||
if (seatFee && seatFee.useType) {
|
||||
$storageManage.useType(seatFee.useType)
|
||||
// uni.setStorageSync('useType',seatFee.useType);
|
||||
eatTypes.active = seatFee.useType == 'takeout' ? seatFee.useType : seatFee.useType.replace(
|
||||
/-after|-before/g, '');
|
||||
useType=seatFee.useType
|
||||
$storageManage.useType(useType)
|
||||
}else{
|
||||
useType=records[0].info[0].useType
|
||||
$storageManage.useType(useType)
|
||||
}
|
||||
console.log(useType);
|
||||
eatTypes.active =useType == 'takeout' ? useType : useType.replace(
|
||||
/-after|-before/g, '');
|
||||
goods.list = getNowCart(records)
|
||||
if (seatFee && seatFee.totalNumber) {
|
||||
userNumbers.defaultCateIndex = seatFee.totalNumber - 1 || 0
|
||||
@@ -653,7 +702,7 @@
|
||||
tableId: opt.tableId || '',
|
||||
name: opt.name
|
||||
}
|
||||
userNumbers.list = new Array(opt.maxCapacity?opt.maxCapacity*1:100).fill(1).map((v, index) => {
|
||||
userNumbers.list = new Array(opt.maxCapacity ? opt.maxCapacity * 1 : 100).fill(1).map((v, index) => {
|
||||
return (index + 1) + '人'
|
||||
})
|
||||
// console.log(userNumbers.list);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<view class="u-font-24 u-m-l-30"><text>余额:</text><text
|
||||
class="color-main">{{data.vipUser.amount}}</text></view>
|
||||
<view class="u-font-24 u-m-l-30"><text>积分:</text><text
|
||||
class="color-main">{{data.vipUser.totalScore}}</text></view>
|
||||
class="color-main">{{data.vipUser.accountPoints}}</text></view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
@@ -242,7 +242,7 @@
|
||||
itemId: '', // 栏目右边scroll-view用于滚动的id
|
||||
tabbar: storageManage.cacheGoods() || [],
|
||||
menuItemPos: [],
|
||||
arr: storageManage.cacheGoodsNode() || [], //左右联动布局节点信息
|
||||
arr: [], //左右联动布局节点信息
|
||||
scrollRightTop: 0, // 右边栏目scroll-view的滚动条高度
|
||||
timer: null, // 定时器
|
||||
topZhanwei: 136 + 24,
|
||||
@@ -269,6 +269,14 @@
|
||||
return res
|
||||
}
|
||||
|
||||
function returnUrlPar(str) {
|
||||
let arr = str.split("?")[1].split("&"); //先通过?分解得到?后面的所需字符串,再将其通过&分解开存放在数组里
|
||||
let obj = {};
|
||||
for (let i of arr) {
|
||||
obj[i.split("=")[0]] = i.split("=")[1]; //对数组每项用=分解开,=前为对象属性名,=后为属性值
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
function scanCode() {
|
||||
// 只允许通过相机扫码
|
||||
@@ -278,6 +286,24 @@
|
||||
success: function(res) {
|
||||
console.log('条码类型:' + res.scanType);
|
||||
console.log('条码内容:' + res.result);
|
||||
if (res.result.includes('codeplate?code=')) {
|
||||
const par = returnUrlPar(res.result)
|
||||
const tableId = par.code
|
||||
console.log('par');
|
||||
console.log(par);
|
||||
onChooseTable({
|
||||
tableId
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: 'error',
|
||||
title: '请扫描正确的桌台码'
|
||||
})
|
||||
}
|
||||
// uni.showModal({
|
||||
// title:'',
|
||||
// content:res.result
|
||||
// })
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -329,8 +355,10 @@
|
||||
return v.foods.length
|
||||
})
|
||||
data.tabbar = tabbar
|
||||
nextTick(() => {
|
||||
getMenuItemTop()
|
||||
})
|
||||
storageManage.cacheGoods(data.tabbar)
|
||||
getMenuItemTop()
|
||||
}
|
||||
|
||||
|
||||
@@ -448,17 +476,20 @@
|
||||
})
|
||||
console.log(res);
|
||||
if (res && res.content[0]) {
|
||||
data.table={...res.content[0],...data.table}
|
||||
data.table = {
|
||||
...res.content[0],
|
||||
...data.table
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let $originGoods = []
|
||||
let $category = []
|
||||
async function init() {
|
||||
if(option.type=='add'){
|
||||
if (option.type == 'add') {
|
||||
data.masterId = option.masterId
|
||||
setTabBar($category, $originGoods, [])
|
||||
}else{
|
||||
} else {
|
||||
const masterRes = await getMasterId()
|
||||
data.masterId = masterRes.masterId
|
||||
}
|
||||
@@ -488,7 +519,7 @@
|
||||
});
|
||||
$originGoods = goods
|
||||
console.log(option);
|
||||
if(option.type=='add'){
|
||||
if (option.type == 'add') {
|
||||
cars.length = 0
|
||||
setTabBar(category, goods, [])
|
||||
return
|
||||
@@ -504,7 +535,7 @@
|
||||
setTabBar(category, goods, cars)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
const cartRes = await getCart()
|
||||
cars.length = 0
|
||||
const cartArr = getNowCart(cartRes.records)
|
||||
@@ -586,29 +617,56 @@
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
async function onChooseTable(item) {
|
||||
console.log('onChooseTable');
|
||||
const res = await $returnTableDetail({
|
||||
tableId: item.tableId,
|
||||
});
|
||||
if (!res) {
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '桌台不存在或不是该店铺的桌台'
|
||||
})
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
infoBox.showToast('桌台不存在或不是该店铺的桌台')
|
||||
// #endif
|
||||
return
|
||||
}
|
||||
console.log('---table:detail-----');
|
||||
console.log(res);
|
||||
if (data.table.tableId || cars.length <= 0) {
|
||||
data.table = {
|
||||
...res,
|
||||
...item
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (res.status == "unbind") {
|
||||
return infoBox.showToast('该台桌未绑定,清先去桌台管理里绑定码牌')
|
||||
}
|
||||
if (res.status != "idle") {
|
||||
return infoBox.showToast('该台桌已在使用中')
|
||||
}
|
||||
|
||||
if (res.cartCount > 0) {
|
||||
setModalShow('clear', true, item)
|
||||
} else {
|
||||
await $choseTable({
|
||||
masterId: data.masterId,
|
||||
tableId: item.tableId,
|
||||
isClear: false
|
||||
});
|
||||
data.table = item
|
||||
}
|
||||
}
|
||||
|
||||
function watchChooseTable() {
|
||||
uni.$off('choose-table')
|
||||
uni.$on('choose-table', async (item) => {
|
||||
if (data.table.tableId || cars.length <= 0) {
|
||||
data.table = item
|
||||
return;
|
||||
}
|
||||
if (item.status != "idle") {
|
||||
return infoBox.showToast('该台桌已在使用中')
|
||||
}
|
||||
const res = await $returnTableDetail({
|
||||
tableId: item.tableId,
|
||||
});
|
||||
if (res.cartCount > 0) {
|
||||
setModalShow('clear', true, item)
|
||||
} else {
|
||||
await $choseTable({
|
||||
masterId: data.masterId,
|
||||
tableId: item.tableId,
|
||||
isClear:false
|
||||
});
|
||||
data.table = item
|
||||
}
|
||||
uni.$on('choose-table', (item) => {
|
||||
onChooseTable(item)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1045,12 +1103,14 @@
|
||||
}, 10);
|
||||
return;
|
||||
}
|
||||
let arr = []
|
||||
rects.forEach((rect) => {
|
||||
// 这里减去rects[0].top,是因为第一项顶部可能不是贴到导航栏(比如有个搜索框的情况)
|
||||
data.arr.push(rect.top - rects[0].top);
|
||||
storageManage.cacheGoodsNode(data.arr)
|
||||
resolve();
|
||||
arr.push(rect.top - rects[0].top);
|
||||
})
|
||||
data.arr = arr
|
||||
console.log(data.arr);
|
||||
resolve();
|
||||
}).exec()
|
||||
})
|
||||
}
|
||||
@@ -1102,7 +1162,7 @@
|
||||
})
|
||||
}
|
||||
watch(() => data.table.tableId, (newval, oldval) => {
|
||||
if(option.type!='add'){
|
||||
if (option.type != 'add') {
|
||||
onSelTable()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -26,7 +26,9 @@
|
||||
<view class="tui" v-if="isTui(item)">
|
||||
{{item.status=='refunding'?'退款中':'已退'}}
|
||||
</view>
|
||||
<view :class="{'line-th':item.status=='return'||item.status=='refund'||item.status=='refunding'}">{{item.name||item.productName}}
|
||||
<view
|
||||
:class="{'line-th':item.status=='return'||item.status=='refund'||item.status=='refunding'}">
|
||||
{{item.name||item.productName}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-8">
|
||||
@@ -35,6 +37,11 @@
|
||||
custom-style="background-color: #FFF0DF; border-color: #FFF0DF; color: #FF9F2E;">
|
||||
</uni-tag>
|
||||
</view>
|
||||
<view class="u-m-r-20 u-flex " v-if="item.userCouponId">
|
||||
<uni-tag text="商品券抵扣"
|
||||
custom-style="background-color: #FFF0DF; border-color: #FFF0DF; color: #FF9F2E;">
|
||||
</uni-tag>
|
||||
</view>
|
||||
<view class="u-m-r-20 u-flex" v-if="item.pack">
|
||||
<uni-tag
|
||||
custom-style="background-color: #E6F0FF; border-color: #E6F0FF; color: #318AFE;"
|
||||
@@ -54,8 +61,20 @@
|
||||
<view class="line-th color-666 ">¥{{returnTotalMoney(item)}}
|
||||
</view>
|
||||
</template>
|
||||
<template v-else-if="isGift(item)||item.userCouponId">
|
||||
<view>¥0.00</view>
|
||||
<view class="line-th color-666 ">¥{{returnTotalMoney(item)}}
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view>¥{{returnTotalMoney(item)}}</view>
|
||||
<template v-if="user.isVip&&item.isMember&&returnVipMoney(item)>0&&returnVipMoney(item)!=returnTotalMoney(item)">
|
||||
<view>¥{{returnVipMoney(item)}}</view>
|
||||
<view class=" color-666 line-th">
|
||||
¥{{returnTotalMoney(item)}}</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view>¥{{returnTotalMoney(item)}}</view>
|
||||
</template>
|
||||
</template>
|
||||
<view class="u-m-t-22 color-999 u-font-24">X{{item.number||item.num}}</view>
|
||||
</view>
|
||||
@@ -70,10 +89,10 @@
|
||||
</view>
|
||||
</template>
|
||||
<template v-if="canTuiKuan(orderInfo,item)">
|
||||
<view class="u-flex u-row-right gap-20 u-m-t-20">
|
||||
<my-button :width="128" :height="48" plain shape="circle"
|
||||
@tap="tuikuan(item,index)"><text class="no-wrap">退款</text> </my-button>
|
||||
</view>
|
||||
<view class="u-flex u-row-right gap-20 u-m-t-20">
|
||||
<my-button :width="128" :height="48" plain shape="circle" @tap="tuikuan(item,index)"><text
|
||||
class="no-wrap">退款</text> </my-button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
</view>
|
||||
@@ -99,9 +118,19 @@
|
||||
</template>
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<text>小计¥</text>
|
||||
<text class="font-bold u-font-32">{{allPrice}}</text>
|
||||
<view class="u-flex">
|
||||
<view class="u-flex u-m-r-24" v-if="youhuiAllPrice>0">
|
||||
<view class="color-red u-m-r-6 " >
|
||||
已优惠¥{{youhuiAllPrice}}
|
||||
</view>
|
||||
<up-icon name="info-circle" color="#999" :size="14" @click="youhuiDetailShow"></up-icon>
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<text>小计¥</text>
|
||||
<text class="font-bold u-font-32">{{allPrice}}</text>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -129,7 +158,6 @@
|
||||
<view></view>
|
||||
<view>
|
||||
<text>总计¥</text>
|
||||
<!-- <text class="font-bold u-font-32">{{numSum([allPrice,seatFeePrice,packFee]) }}</text> -->
|
||||
<text class="font-bold u-font-32">{{to2(allPrice*1+seatFeePrice*1+packFee*1) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -137,20 +165,107 @@
|
||||
<my-button @tap="printOrder" type="cancel" :color="color.ColorMain">重新打印</my-button>
|
||||
</view>
|
||||
</view>
|
||||
<up-popup :round="10" :show="pop.youhui" mode="center" closeOnClickOverlay @close="youhuiDetailHide" >
|
||||
<view class="u-p-30" style="width: 80vw;">
|
||||
<view class="font-bold u-text-center">优惠详情</view>
|
||||
<view class="u-m-t-32">
|
||||
<!-- <view class="u-flex u-row-between u-m-b-18">
|
||||
<view>会员优惠</view>
|
||||
<view class="color-red">
|
||||
<text>¥</text>
|
||||
<text>{{vipDiscountPrice}}</text>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="u-flex u-row-between u-m-b-18" v-if="orderInfo.discountAmount*1>0">
|
||||
<view>打折</view>
|
||||
<view class="color-red">
|
||||
<text>¥</text>
|
||||
<text>{{orderInfo.discountAmount}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between " v-if="orderInfo.fullCouponDiscountAmount*1>0">
|
||||
<view>满减券抵扣</view>
|
||||
<view class="color-red">
|
||||
<text>¥</text>
|
||||
<text>{{orderInfo.fullCouponDiscountAmount}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-18" v-if="orderInfo.productCouponDiscountAmount||productCoupPrice">
|
||||
<view>商品券抵扣</view>
|
||||
<view class="color-red">
|
||||
<text>¥</text>
|
||||
<text>{{orderInfo.productCouponDiscountAmount||productCoupPrice}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-18" v-if="orderInfo.pointsDiscountAmount">
|
||||
<view>积分抵扣</view>
|
||||
<view class="color-red">
|
||||
<text>¥</text>
|
||||
<text>{{orderInfo.pointsDiscountAmount}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</up-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
computed
|
||||
computed, reactive
|
||||
} from 'vue';
|
||||
import color from '@/commons/color.js'
|
||||
import {
|
||||
hasPermission
|
||||
} from '@/commons/utils/hasPermission.js'
|
||||
import {isTui,canTuiKuan,canTuicai,numSum} from '@/commons/utils/goodsUtil.js'
|
||||
import {
|
||||
isTui,isGift,
|
||||
canTuiKuan,
|
||||
canTuicai,
|
||||
numSum
|
||||
} from '@/commons/utils/goodsUtil.js'
|
||||
const pop=reactive({
|
||||
youhui:false
|
||||
})
|
||||
function youhuiDetailShow(){
|
||||
pop.youhui=true
|
||||
}
|
||||
function youhuiDetailHide(){
|
||||
pop.youhui=false
|
||||
}
|
||||
const props = defineProps({
|
||||
orderInfo: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
},
|
||||
data: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
seatFee: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
},
|
||||
user: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
id: '',
|
||||
isVip: false
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
const emits = defineEmits(['tuicai', 'tuikuan', 'printOrder'])
|
||||
|
||||
function returnVipMoney(item) {
|
||||
if (!item.memberPrice || !props.user.isVip) {
|
||||
return 0
|
||||
}
|
||||
return (item.memberPrice * item.num).toFixed(2)
|
||||
}
|
||||
|
||||
function returnTotalMoney(item) {
|
||||
return (item.price * item.num).toFixed(2)
|
||||
}
|
||||
@@ -177,20 +292,7 @@
|
||||
function printOrder() {
|
||||
emits('printOrder')
|
||||
}
|
||||
const props = defineProps({
|
||||
orderInfo: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
},
|
||||
data: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
seatFee: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
const seatFeePrice = computed(() => {
|
||||
if (!props.seatFee.priceAmount) {
|
||||
@@ -199,21 +301,62 @@
|
||||
const n = props.seatFee.priceAmount * (props.seatFee.status == 'return' ? 0 : 1)
|
||||
return n.toFixed(2)
|
||||
})
|
||||
|
||||
const allPrice = computed(() => {
|
||||
const goodsOriginAllPrice = computed(() => {
|
||||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.filter(v => v.gift != true && v.status !== "return").reduce((a,
|
||||
const curTotal = cur.info.reduce((a,
|
||||
b) => {
|
||||
// return a + b.priceAmount*1||(b.num*b.price+b.packAmount*1)
|
||||
// return a + (b.num*b.price+b.packAmount*1)
|
||||
return a + (b.num * b.price)
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
return goodsPrice.toFixed(2)
|
||||
|
||||
})
|
||||
|
||||
|
||||
const freePrice = computed(() => {
|
||||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.filter(v => v.gift == true || isTui(v)).reduce((a,
|
||||
b) => {
|
||||
return a + (b.num * b.price)
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
return goodsPrice.toFixed(2)
|
||||
})
|
||||
const vipDiscountPrice = computed(() => {
|
||||
if (!props.user.isVip) {
|
||||
return 0
|
||||
}
|
||||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.filter(v => v.gift != true && v.status !== "return" &&!v.userCouponId&&(v.isMember&&v.memberPrice)&&(v.memberPrice!=v.price)).reduce((a,
|
||||
b) => {
|
||||
return a + (b.num * (b.price-b.memberPrice))
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
return goodsPrice.toFixed(2)
|
||||
})
|
||||
|
||||
const productCoupPrice=computed(()=>{
|
||||
if(props.orderInfo.status=='closed'){
|
||||
return props.orderInfo.productCouponDiscountAmount
|
||||
}
|
||||
const goodsPrice = props.data.reduce((a, b) => {
|
||||
const curTotal = b.info.filter(v => v.gift != true&& v.userCouponId).reduce((prve,
|
||||
cur) => {
|
||||
const isVip=props.user.isVip&&cur.isMember
|
||||
const memberPrice=cur.memberPrice?cur.memberPrice:cur.price
|
||||
const price=isVip?memberPrice:cur.price
|
||||
const curTotal=price*cur.num
|
||||
return prve+curTotal
|
||||
}, 0)
|
||||
return a + curTotal
|
||||
}, 0)
|
||||
return goodsPrice.toFixed(2)
|
||||
})
|
||||
|
||||
const youhuiAllPrice=computed(()=>{
|
||||
return (freePrice.value*1+vipDiscountPrice.value*1+props.orderInfo.fullCouponDiscountAmount+props.orderInfo.pointsDiscountAmount+productCoupPrice.value*1+(props.orderInfo.discountAmount||0)).toFixed(2)
|
||||
})
|
||||
const packFee = computed(() => {
|
||||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.filter(v => v.gift != true && v.status !== "return").reduce((a,
|
||||
@@ -225,7 +368,10 @@
|
||||
return goodsPrice.toFixed(2)
|
||||
|
||||
})
|
||||
|
||||
const allPrice = computed(() => {
|
||||
const n=goodsOriginAllPrice.value-youhuiAllPrice.value
|
||||
return (n<0?0:n).toFixed(2)
|
||||
})
|
||||
|
||||
const goodsNumber = computed(() => {
|
||||
let result = 0
|
||||
|
||||
@@ -33,12 +33,12 @@
|
||||
<view class="color-666 u-m-t-8 u-font-24">余额</view>
|
||||
</view>
|
||||
<view class="">
|
||||
<view class="font-bold">{{user.totalScore}}</view>
|
||||
<view class="font-bold">{{user.accountPoints}}</view>
|
||||
<view class="color-666 u-m-t-8 u-font-24">积分</view>
|
||||
</view>
|
||||
<view class="">
|
||||
<view class="font-bold">0.00</view>
|
||||
<view class="color-666 u-m-t-8 u-font-24">已消费</view>
|
||||
<view class="font-bold u-text-center">{{user.orderNumber||0}}</view>
|
||||
<view class="color-666 u-m-t-8 u-font-24">订单数量</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -61,7 +61,7 @@
|
||||
headImg:'',
|
||||
telephone:'',
|
||||
amount:'0.00',
|
||||
totalScore:'0.00'
|
||||
accountPoints:'0.00'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<text class="">{{orderDetail.info.tableName}}</text>
|
||||
</view> -->
|
||||
<goods-list @printOrder="onPrintOrder" @tuikuan="onTuikuan" :orderInfo="orderDetail.info"
|
||||
:user="user"
|
||||
:data="orderDetail.goodsList" :seatFee="orderDetail.seatFee" @tuicai="onTuiCai"></goods-list>
|
||||
<!-- <template v-if="orderDetail.seatFee.totalNumber&&orderDetail.seatFee.totalAmount"> -->
|
||||
<template v-if="true">
|
||||
@@ -315,10 +316,10 @@
|
||||
headImg:'',
|
||||
telephone:'',
|
||||
amount:'0.00',
|
||||
totalScore:'0.00'
|
||||
accountPoints:'0.00'
|
||||
})
|
||||
//更新选择用户
|
||||
function setUser(par) {
|
||||
async function setUser(par) {
|
||||
const submitPar = {
|
||||
orderId:options.id||'',
|
||||
masterId: options.masterId,
|
||||
@@ -327,7 +328,9 @@
|
||||
type: user.value.id ? 0 : 1 //0 设置 1 取消
|
||||
}
|
||||
Object.assign(submitPar, par)
|
||||
return Api.$setUser(submitPar)
|
||||
const res=await Api.$setUser(submitPar)
|
||||
init()
|
||||
return res
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
<view class="u-m-t-32">
|
||||
<view class="u-font-32">{{goosZhonglei}}种商品,共{{goodsNumber}}件</view>
|
||||
<view class="border-bottom u-p-b-32">
|
||||
<view class="" v-for="(item,index) in data.detailList"
|
||||
:key="index">
|
||||
<view class="" v-for="(item,index) in data.detailList" :key="index">
|
||||
<view class="u-flex u-row-between u-col-top u-m-t-32" v-if="item.productId!=-999">
|
||||
<view>
|
||||
<view class=""> {{item.productName}}</view>
|
||||
@@ -41,20 +40,36 @@
|
||||
</view>
|
||||
<view class="u-flex u-flex-1 u-row-right">
|
||||
<view>×{{item.num}}</view>
|
||||
<view class="u-text-right u-relative" :style="computedPriceStyle()">
|
||||
<text :class="{'line-th':item.gift}">¥{{goodsPriceAmount(item)}}</text>
|
||||
<view class="u-absolute" style="bottom: 100%;right: 0;" v-if="item.gift">
|
||||
¥0
|
||||
<template v-if="item.gift||item.userCouponId">
|
||||
<view class="u-text-right u-relative" :style="computedPriceStyle()">
|
||||
<text class="line-th">¥{{goodsPriceAmount(item)}}</text>
|
||||
<view class="u-absolute" style="bottom: 100%;right: 0;">
|
||||
¥0
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else-if="item.isMember&&data.memberId&&item.memberPrice&&item.memberPrice!=item.price">
|
||||
<view class="u-text-right u-relative" :style="computedPriceStyle()">
|
||||
<text class="line-th">¥{{goodsPriceAmount(item)}}</text>
|
||||
<view class="u-absolute" style="bottom: 100%;right: 0;">
|
||||
¥{{goodsVipPriceAmount(item)}}
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view class="u-text-right u-relative" :style="computedPriceStyle()">
|
||||
<text>¥{{goodsPriceAmount(item)}}</text>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="border-bottom u-p-t-32 u-p-b-32" v-if="data.packFee>0||(data.seatInfo&&data.seatInfo.priceAmount>0)">
|
||||
<view class="border-bottom u-p-t-32 u-p-b-32"
|
||||
v-if="data.packFee>0||(data.seatInfo&&data.seatInfo.priceAmount>0)">
|
||||
<view class="u-flex u-row-between u-col-top" v-if="data.packFee>0">
|
||||
<view class="no-wrap u-m-r-32">打包费</view>
|
||||
<view>¥{{data.packFee||0}}</view>
|
||||
@@ -65,8 +80,24 @@
|
||||
<view>¥{{data.seatInfo.priceAmount}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="border-bottom u-p-b-32 u-m-t-32"
|
||||
v-if="data.fullCouponDiscountAmount>0||data.productCouponDiscountAmount>0||data.pointsDiscountAmount>0">
|
||||
<view class="u-flex u-row-between u-col-top" v-if="data.fullCouponDiscountAmount>0">
|
||||
<view class="no-wrap u-m-r-32">满减券抵扣</view>
|
||||
<view class="color-red">-¥{{data.fullCouponDiscountAmount||0}}</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-32 u-col-top" v-if="data.productCouponDiscountAmount>0">
|
||||
<view class="no-wrap u-m-r-32">商品券抵扣</view>
|
||||
<view class="color-red">-¥{{data.productCouponDiscountAmount||0}}</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-32 u-col-top" v-if="data.pointsDiscountAmount>0">
|
||||
<view class="no-wrap u-m-r-32">积分抵扣</view>
|
||||
<view class="color-red">-¥{{data.pointsDiscountAmount||0}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
<view class="u-flex u-row-between border-bottom u-m-t-32 u-p-b-32 u-col-top">
|
||||
<view class="no-wrap u-m-r-32">订单备注</view>
|
||||
<view>{{data.remark||'无'}}</view>
|
||||
@@ -88,7 +119,11 @@
|
||||
import dayjs from 'dayjs';
|
||||
import orderEnum from '@/commons/orderEnum.js'
|
||||
import go from '@/commons/utils/go.js'
|
||||
import {isTui,canTuiKuan,canTuicai} from '@/commons/utils/goodsUtil.js'
|
||||
import {
|
||||
isTui,
|
||||
canTuiKuan,
|
||||
canTuicai
|
||||
} from '@/commons/utils/goodsUtil.js'
|
||||
import {
|
||||
computed,
|
||||
reactive,
|
||||
@@ -100,11 +135,11 @@
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return{
|
||||
packFee:0,
|
||||
seatInfo:{
|
||||
productName:'客座费',
|
||||
priceAmount:0
|
||||
return {
|
||||
packFee: 0,
|
||||
seatInfo: {
|
||||
productName: '客座费',
|
||||
priceAmount: 0
|
||||
},
|
||||
detailList: []
|
||||
}
|
||||
@@ -118,10 +153,19 @@
|
||||
let $goodsMap = {}
|
||||
let goosZhonglei = ref(0)
|
||||
let goodsNumber = ref(0)
|
||||
|
||||
|
||||
const priceSize = 9
|
||||
function goodsPriceAmount(item){
|
||||
return (item.price*item.num).toFixed(2)
|
||||
let minWidth=ref(36)
|
||||
function goodsPriceAmount(item) {
|
||||
const total=(item.price * item.num).toFixed(2)
|
||||
const minW=total.length * priceSize + 15
|
||||
minWidth.value=minW<minWidth.value?minWidth.value:minW
|
||||
return total
|
||||
}
|
||||
|
||||
function goodsVipPriceAmount(item) {
|
||||
const price = item.memberPrice ? item.memberPrice : item.price
|
||||
return (price * item.num).toFixed(2)
|
||||
}
|
||||
// const packeFee=computed(()=>{
|
||||
// return props.data.detailList.reduce((prve,cur)=>{
|
||||
@@ -129,14 +173,8 @@
|
||||
// },0).toFixed(2)
|
||||
// })
|
||||
function computedPriceStyle() {
|
||||
const item = props.data.detailList.reduce((prev, current) => (`${prev.price}`.length > `${current.price}`
|
||||
.length) ? prev : current)
|
||||
if (!item) {
|
||||
return ''
|
||||
}
|
||||
const minW=`${item.price}`.length * priceSize + 15
|
||||
return {
|
||||
'min-width':(minW<36?36:minW) + 'px'
|
||||
'min-width':minWidth.value + 'px'
|
||||
}
|
||||
}
|
||||
// const computedPriceStyle = computed(() => {
|
||||
|
||||
195
pagesOrder/pay-order/components/edit-accountPoints.vue
Normal file
195
pagesOrder/pay-order/components/edit-accountPoints.vue
Normal file
@@ -0,0 +1,195 @@
|
||||
<template>
|
||||
<my-model ref="model" :title="title" iconColor="#000" @close="resetForm">
|
||||
<template #desc>
|
||||
<view class="u-text-left u-p-30 color-666 u-font-28">
|
||||
<view class="u-m-t-32 u-flex ">
|
||||
<view class="" v-if="accountPoints.calcRes.usable">
|
||||
<text class="color-red">*</text>
|
||||
<text class=""
|
||||
v-if="accountPoints.calcRes.equivalentPoints">100积分等于{{to2(accountPoints.calcRes.equivalentPoints*100)}}元,</text>
|
||||
<text>
|
||||
最大抵扣积分{{accountPoints.calcRes.maxUsablePoints}}
|
||||
</text>
|
||||
<text>,
|
||||
最小抵扣积分0
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-40 u-flex ">
|
||||
<view>积分</view>
|
||||
<view class="u-m-l-32 border u-p-l-10 u-p-r-10 u-flex-1">
|
||||
<uni-easyinput type="number" @input="pointsInput" @change="pointsChange" paddingNone
|
||||
:inputBorder="false" v-model="form.points" placeholder="输入积分抵扣数量"></uni-easyinput>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template #btn>
|
||||
<view class="u-p-30">
|
||||
<view class="u-m-t-10">
|
||||
<my-button @tap="confirm" shape="circle" fontWeight="700">修改</my-button>
|
||||
<view class="">
|
||||
<my-button @tap="close" type="cancel" bgColor="#fff">取消</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</my-model>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
reactive,
|
||||
nextTick,
|
||||
ref,
|
||||
watch
|
||||
} from 'vue';
|
||||
import myModel from '@/components/my-components/my-model.vue'
|
||||
import myButton from '@/components/my-components/my-button.vue'
|
||||
import myTabs from '@/components/my-components/my-tabs.vue'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: '积分抵扣'
|
||||
},
|
||||
accountPoints:{
|
||||
type:Object,
|
||||
default:()=>{
|
||||
return {
|
||||
calcRes:{
|
||||
usable: false,
|
||||
unusableReason: '',
|
||||
minDeductionPoints: 0,
|
||||
maxUsablePoints: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
price: {
|
||||
type: [Number, String],
|
||||
default: 0
|
||||
}
|
||||
})
|
||||
|
||||
function to2(n) {
|
||||
if (!n) {
|
||||
return ''
|
||||
}
|
||||
return n.toFixed(2)
|
||||
}
|
||||
|
||||
function pointsInput(e){
|
||||
setTimeout(()=>{
|
||||
form.points=Math.floor(e)
|
||||
},100)
|
||||
}
|
||||
|
||||
|
||||
function pointsChange(newval) {
|
||||
form.points=Math.floor(newval)
|
||||
if (newval < 0) {
|
||||
form.points = 0
|
||||
return infoBox.showToast('积分抵扣不能小于0')
|
||||
}
|
||||
if (newval > props.accountPoints.calcRes.maxUsablePoints) {
|
||||
form.points = props.price
|
||||
return infoBox.showToast('积分抵扣不能大于'+props.accountPoints.calcRes.maxUsablePoints)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const form = reactive({
|
||||
points: props.price,
|
||||
})
|
||||
watch(() => props.price, (newval) => {
|
||||
form.points = newval
|
||||
})
|
||||
|
||||
function resetForm() {
|
||||
form.points=0
|
||||
}
|
||||
|
||||
const model = ref(null)
|
||||
|
||||
function open() {
|
||||
model.value.open()
|
||||
form.points = props.price
|
||||
}
|
||||
|
||||
function close() {
|
||||
model.value.close()
|
||||
}
|
||||
const emits = defineEmits(['confirm'])
|
||||
|
||||
function confirm() {
|
||||
emits('confirm',Math.floor(form.points) )
|
||||
close()
|
||||
}
|
||||
defineExpose({
|
||||
open,
|
||||
close
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.border {
|
||||
border-radius: 8rpx;
|
||||
overflow: hidden;
|
||||
border-color: #999;
|
||||
}
|
||||
|
||||
.lh34 {
|
||||
line-height: 34rpx;
|
||||
}
|
||||
|
||||
.tag {
|
||||
background-color: #fff;
|
||||
border: 1px solid #E5E5E5;
|
||||
line-height: inherit;
|
||||
font-size: 24rpx;
|
||||
color: #666666;
|
||||
padding: 6rpx 20rpx;
|
||||
border-radius: 8rpx;
|
||||
|
||||
&.active {
|
||||
border-color: #E6F0FF;
|
||||
color: $my-main-color;
|
||||
}
|
||||
}
|
||||
|
||||
.hover-class {
|
||||
background-color: #E5E5E5;
|
||||
}
|
||||
|
||||
.discount {
|
||||
.u-absolute {
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.bg1 {
|
||||
background: #F7F7FA;
|
||||
}
|
||||
|
||||
.tab {
|
||||
padding: 0 80rpx;
|
||||
}
|
||||
|
||||
.border {
|
||||
border: 1px solid #E5E5E5;
|
||||
border-radius: 4rpx;
|
||||
}
|
||||
|
||||
.input-box {
|
||||
padding: 22rpx 32rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.placeholder-class {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -1,43 +1,90 @@
|
||||
<template>
|
||||
<view class="bg-gray min-page u-p-30 u-font-28">
|
||||
<view class="u-p-t-60 u-p-b-60 u-text-center">
|
||||
<view class="u-font-32 ">
|
||||
<text class="price-fuhao">¥</text>
|
||||
<text class="font-bold price">{{discount.currentPrice?discount.currentPrice:order.amount}}</text>
|
||||
</view>
|
||||
<view class="u-m-t-10 color-999 old-price">
|
||||
<text class="">¥</text>
|
||||
<text class=" ">{{order.amount}}</text>
|
||||
</view>
|
||||
<view class="u-m-t-10 u-flex u-row-center color-main">
|
||||
<view @click="discountShow">修改</view>
|
||||
</view>
|
||||
<template v-if="order.amount!=payPrice">
|
||||
<view class="u-font-32 ">
|
||||
<text class="price-fuhao">¥</text>
|
||||
<!-- <text class="font-bold price">{{discount.currentPrice?discount.currentPrice:order.amount}}</text> -->
|
||||
<text class="font-bold price">{{payPrice}}</text>
|
||||
</view>
|
||||
<view class="u-m-t-10 color-999 old-price">
|
||||
<text class="">¥</text>
|
||||
<text class=" ">{{order.amount}}</text>
|
||||
</view>
|
||||
<view class="u-m-t-10 u-flex u-row-center color-main">
|
||||
<view @click="discountShow">修改</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view class="u-font-32 ">
|
||||
<text class="price-fuhao">¥</text>
|
||||
<text class="font-bold price">{{order.amount}}</text>
|
||||
</view>
|
||||
<view class="u-m-t-10 u-flex u-row-center color-main">
|
||||
<view @click="discountShow">修改</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
</view>
|
||||
<view class="content bg-fff border-r-12">
|
||||
<view class=" u-p-t-30 u-p-l-26 u-p-r-26 card top u-m-t-30">
|
||||
<view class="u-flex u-p-l-24 u-p-r-24 border-bottom-dashed u-row-between u-p-b-30">
|
||||
<view>优惠券</view>
|
||||
<view class="color-999 u-flex u-col-center">
|
||||
<text>选择优惠券</text>
|
||||
<view class="u-flex u-col-center">
|
||||
<uni-icons type="right" color="#999"></uni-icons>
|
||||
<view class="border-bottom-dashed u-p-b-30">
|
||||
<view class="u-flex u-p-l-24 u-p-r-24 u-row-between " @click="toQuan">
|
||||
<view>优惠券</view>
|
||||
<view class="color-999 u-flex u-col-center">
|
||||
<text>选择优惠券</text>
|
||||
<view class="u-flex u-col-center">
|
||||
<uni-icons type="right" color="#999"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-24" v-if="pays.quan.length>0">
|
||||
<view class="u-flex u-p-l-24 u-p-r-24 u-m-t-24 u-row-between "
|
||||
v-for="(item,index) in pays.quan" :key="index">
|
||||
<view class="u-flex">
|
||||
<view class="hui">减</view>
|
||||
<view class="u-m-l-18">{{item.name}}</view>
|
||||
<view class="u-m-l-18 color-999">x{{item.num}}</view>
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<view class="color-red">
|
||||
-¥{{item.discountAmount}}
|
||||
</view>
|
||||
<view class="u-m-l-12" @click="delQuan(index)">
|
||||
<up-icon :size="16" name="minus-circle-fill" color="rgb(255, 0, 0)"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
<view class="border-bottom u-p-b-30" v-if="(discount.price&&discount.currentPrice!=order.amount)||accountPoints.sel">
|
||||
<view class="u-flex u-p-l-24 u-p-r-24 u-row-between u-p-t-30 "
|
||||
v-if="discount.price&&discount.currentPrice!=order.amount">
|
||||
<view>服务员改价</view>
|
||||
<view class=" u-flex u-col-center">
|
||||
<text style="color: rgb(255, 95, 46);">-¥{{to2(order.amount- discount.currentPrice)}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-p-l-24 u-p-r-24 u-row-between u-p-t-30 "
|
||||
v-if="accountPoints.price&&accountPoints.sel">
|
||||
<view>积分抵扣</view>
|
||||
<view class=" u-flex u-col-center">
|
||||
<text style="color: rgb(255, 95, 46);">-¥{{to2(accountPoints.price)}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-p-l-24 u-p-r-24 border-bottom u-row-between u-p-t-30 u-p-b-30"
|
||||
v-if="discount.price&&discount.currentPrice!=order.amount">
|
||||
<view>服务员改价</view>
|
||||
<view class=" u-flex u-col-center">
|
||||
<text style="color: rgb(255, 95, 46);">-¥{{to2(order.amount- discount.currentPrice)}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="bg-fff border-r-12 ">
|
||||
<view class="u-p-t-30 u-p-l-50 u-p-r-50 card bottom">
|
||||
<my-tabs :list="pays.list" v-model="pays.selIndex"></my-tabs>
|
||||
<template v-if="pays.selIndex==0">
|
||||
<view class="list">
|
||||
<view class="item" @click="changePayType(index,item)"
|
||||
<view class="item" @click="changePayType(index,item)" :class="{disabled:item.disabled}"
|
||||
v-for="(item,index) in pays.payTypes.list" :key="index">
|
||||
<view class="u-flex u-row-between u-p-t-30 u-p-b-30 border-bottom">
|
||||
<view class="u-flex">
|
||||
@@ -45,7 +92,7 @@
|
||||
<text class="u-m-l-10 no-wrap">{{item.payName}}</text>
|
||||
</view>
|
||||
<view class="u-flex color-999 u-font-24">
|
||||
<view class="u-m-r-20" v-if="item.payType=='vipPay'">
|
||||
<view class="u-m-r-20" v-if="item.payType=='vipPay'&&user.id">
|
||||
<view>
|
||||
<text>会员:</text>
|
||||
<text class="u-m-r-4">{{user.telephone||user.nickName}}</text>
|
||||
@@ -54,14 +101,65 @@
|
||||
<text>余额:</text>
|
||||
<text>¥{{user.amount||'0'}}</text>
|
||||
</view>
|
||||
<!-- <view>
|
||||
<text>积分:</text>
|
||||
<text>{{user.accountPoints||'0'}}</text>
|
||||
</view> -->
|
||||
</view>
|
||||
<my-radio @click="changePayType(index,item)"
|
||||
:modelValue="index==pays.payTypes.selIndex">
|
||||
</my-radio>
|
||||
<view :class="{op3:item.disabled}">
|
||||
<my-radio @click="changePayType(index,item)"
|
||||
:modelValue="index==pays.payTypes.selIndex">
|
||||
</my-radio>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="border-bottom-dashed "></view>
|
||||
<view class="u-flex u-row-between u-p-t-24" v-if="user.id" @click="changeAccountPoints">
|
||||
<view class="u-flex ">
|
||||
<view class="">积分抵扣</view>
|
||||
<view class="color-999 u-m-l-10">
|
||||
<text>(</text>
|
||||
<text>{{user.accountPoints||'0'}}</text>
|
||||
<text>)</text>
|
||||
</view>
|
||||
<!-- <view><text class="color-red font-bold">{{accountPoints.price}}</text>元</view> -->
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
|
||||
<view class="u-flex">
|
||||
<view><text>{{accountPoints.num}}</text></view>
|
||||
<view v-if="accountPoints.calcRes.usable" @click.stop="refPointsOpen">
|
||||
<up-icon name="edit-pen" size="16" color="#999"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="u-m-l-32 u-relative" v-if="accountPoints.calcRes.usable">
|
||||
<view class="u-absolute position-all"></view>
|
||||
<my-radio :modelValue="accountPoints.sel">
|
||||
</my-radio>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="color-999 u-font-24 u-m-t-16">
|
||||
<view class="" v-if="accountPoints.calcRes.unusableReason">
|
||||
<text class="color-red">*</text>
|
||||
<text>{{accountPoints.calcRes.unusableReason}}</text>
|
||||
</view>
|
||||
<view class="" v-if="accountPoints.calcRes.usable">
|
||||
<text class="color-red">*</text>
|
||||
<text class=""
|
||||
v-if="accountPoints.calcRes.equivalentPoints">100积分等于{{to2(accountPoints.calcRes.equivalentPoints*100)}}元,</text>
|
||||
<text>
|
||||
最大抵扣积分{{accountPoints.calcRes.maxUsablePoints}}
|
||||
</text>
|
||||
<text>,
|
||||
最小抵扣积分0
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-60 u-p-b-30">
|
||||
<my-button @click="payOrderClick">确认付款</my-button>
|
||||
</view>
|
||||
@@ -81,7 +179,7 @@
|
||||
</view>
|
||||
<view class="bg-fff card bottom border-r-12 u-p-32">
|
||||
<view class="font-bold u-font-32 u-text-center">
|
||||
¥{{discount.currentPrice?discount.currentPrice: order.amount}}</view>
|
||||
¥{{payPrice}}</view>
|
||||
<view class="u-flex u-row-center u-m-t-24">
|
||||
<template v-if="order.status=='unpaid'">
|
||||
<up-loading-icon size="14" text="等待支付"></up-loading-icon>
|
||||
@@ -106,6 +204,13 @@
|
||||
|
||||
<edit-discount @confirm="editDiscountConfirm" title="优惠金额" :ref="setModel" name="editMoney"
|
||||
:price="order.amount"></edit-discount>
|
||||
|
||||
<up-modal :title="modal.title" :content="modal.content" :show="modal.show" :confirmText="modal.confirmText"
|
||||
:cancelText="modal.cancelText" showCancelButton closeOnClickOverlay @confirm="confirmModelConfirm"
|
||||
@cancel="confirmModelCancel" @close="confirmModelCancel" width="300px" />
|
||||
|
||||
<edit-accountPoints @confirm="pointsConfirm" :price="accountPoints.num" :accountPoints="accountPoints"
|
||||
ref="refPoints"></edit-accountPoints>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -115,29 +220,158 @@
|
||||
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,
|
||||
returnProductCanUseNum
|
||||
} from '../quan_util.js'
|
||||
|
||||
const modal = reactive({
|
||||
title: '提示',
|
||||
cancelText: '取消',
|
||||
confirmText: '确认',
|
||||
content: '',
|
||||
key: 'cash',
|
||||
show: false,
|
||||
data: ''
|
||||
})
|
||||
|
||||
function confirmModelCancel() {
|
||||
modal.show=false
|
||||
modal.key=''
|
||||
modal.data=''
|
||||
}
|
||||
|
||||
function cashConfirmShow() {
|
||||
modal.content = '是否确认已现金收款' + payPrice.value
|
||||
modal.key='cash'
|
||||
modal.show=true
|
||||
}
|
||||
async function confirmModelConfirm() {
|
||||
if (modal.key == 'cash') {
|
||||
await pay()
|
||||
confirmModelCancel()
|
||||
}
|
||||
}
|
||||
let option = {isNowPay:false}
|
||||
let payFinish=ref(false)
|
||||
|
||||
//商品数量从0到n每一个对应的价格
|
||||
let $goodsPayPriceMap = {}
|
||||
|
||||
const refPoints = ref(null)
|
||||
|
||||
function delQuan(i) {
|
||||
pays.quan.splice(i, 1)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
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 +382,6 @@
|
||||
// }
|
||||
// return false
|
||||
})
|
||||
let payStatus = ref(null) //loading success
|
||||
|
||||
let timer = null
|
||||
|
||||
@@ -173,41 +406,83 @@
|
||||
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 && v.num >= 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]
|
||||
}
|
||||
}
|
||||
console.log(coupMap);
|
||||
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);
|
||||
const coupUseNum = returnProductCanUseNum($goodsPayPriceMap[coup.proId], proCoupStartIndex,
|
||||
coup.num)
|
||||
const num = Math.min($goodsPayPriceMap[coup.proId].length, coupUseNum)
|
||||
coup.num = num
|
||||
coup.discountAmount = returnProductCoupAllPrice($goodsPayPriceMap[coup.proId],
|
||||
proCoupStartIndex, num).toFixed(2)
|
||||
}
|
||||
}
|
||||
productCoup = productCoup.filter(v => v.num >= 1)
|
||||
console.log(productCoup);
|
||||
pays.quan = [...manjianCoup, ...productCoup]
|
||||
})
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
watchChooseuser()
|
||||
watchChooseQuan()
|
||||
})
|
||||
|
||||
watch(() => pays.selIndex, (newval) => {
|
||||
@@ -241,7 +516,7 @@
|
||||
|
||||
//打折相关数据
|
||||
const discount = reactive({
|
||||
|
||||
discount: 100
|
||||
})
|
||||
|
||||
function editDiscountConfirm(form) {
|
||||
@@ -249,23 +524,34 @@
|
||||
Object.assign(discount, form)
|
||||
getPayUrl()
|
||||
}
|
||||
|
||||
async function getPayType() {
|
||||
const payTypeList = await Api.$getPayType()
|
||||
pays.payTypes.list = payTypeList
|
||||
pays.payTypes.list = payTypeList.map(v => {
|
||||
return {
|
||||
...v,
|
||||
disabled: false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function changePayType(i, item) {
|
||||
if (item.disabled) {
|
||||
return infoBox.showToast(item.payName + '不可用')
|
||||
}
|
||||
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({
|
||||
@@ -280,29 +566,55 @@
|
||||
if (payType == 'scanCode' || payType == 'deposit') {
|
||||
return saomaPay()
|
||||
}
|
||||
if (payType == 'cash' && payPrice.value * 1 > 0) {
|
||||
return cashConfirmShow()
|
||||
}
|
||||
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 {
|
||||
pay()
|
||||
} catch (e) {
|
||||
//TODO handle the exception
|
||||
payStatus = ''
|
||||
}
|
||||
}
|
||||
async function pay(par) {
|
||||
const payType = pays.payTypes.list[pays.payTypes.selIndex].payType
|
||||
payStatus = 'paying'
|
||||
await Api.$payOrder({
|
||||
tableId: order.tableId,
|
||||
masterId: order.masterId,
|
||||
orderId: order.id || order.orderId,
|
||||
payType,
|
||||
vipUserId: order.memberId,
|
||||
discount: 1,
|
||||
code: ''
|
||||
discount: discount.discount / 100,
|
||||
code: '',
|
||||
pointsNum: accountPoints.sel ? accountPoints.num : 0,
|
||||
userCouponInfos: pays.quan.map(v => {
|
||||
return {
|
||||
userCouponId: v.id,
|
||||
num: v.num
|
||||
}
|
||||
}),
|
||||
...par
|
||||
})
|
||||
paySuccess()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getPayType()
|
||||
})
|
||||
const order = reactive({
|
||||
amount: 0
|
||||
})
|
||||
@@ -316,15 +628,7 @@
|
||||
success: function(res) {
|
||||
console.log('条码类型:' + res.scanType);
|
||||
console.log('条码内容:' + res.result);
|
||||
Api.$payOrder({
|
||||
"orderId": order.orderId, // 订单id
|
||||
"payType": item.payType, //
|
||||
"discount": order.discount,
|
||||
"code": res.result
|
||||
}).then(res => {
|
||||
console.log(res);
|
||||
paySuccess()
|
||||
})
|
||||
pay({code: res.result})
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -346,41 +650,96 @@
|
||||
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, (newval) => {
|
||||
getPayUrl()
|
||||
if (newval <= 0) {
|
||||
const arr = ['cash', 'vipPay']
|
||||
pays.payTypes.list.map(v => {
|
||||
if (arr.includes(v.payType)) {
|
||||
v.disabled = false
|
||||
} else {
|
||||
v.disabled = true
|
||||
}
|
||||
})
|
||||
const index = pays.payTypes.list.findIndex(v => !v.disabled)
|
||||
pays.payTypes.selIndex = index
|
||||
} else {
|
||||
pays.payTypes.list.map(v => {
|
||||
v.disabled = false
|
||||
})
|
||||
}
|
||||
})
|
||||
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()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
$quan-color: #318AFE;
|
||||
|
||||
.op3 {
|
||||
opacity: .3;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
.box-shadow {
|
||||
box-shadow: 0 0 5px #E5E5E5;
|
||||
}
|
||||
@@ -403,6 +762,12 @@
|
||||
}
|
||||
|
||||
.list {
|
||||
.item {
|
||||
&.disabled {
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
|
||||
.item:last-child {
|
||||
.border-bottom {
|
||||
border-bottom: none;
|
||||
|
||||
@@ -1,22 +1,570 @@
|
||||
<template>
|
||||
<view>
|
||||
|
||||
<view class="u-p-l-30 u-p-r-30 u-p-t-30 u-font-28 ">
|
||||
<up-sticky offset-top="0">
|
||||
<my-tabs v-model="myQuan.types.sel" :list="myQuan.types.list"></my-tabs>
|
||||
</up-sticky>
|
||||
<view class="u-m-t-32">
|
||||
<template v-if="myQuan.types.sel==0">
|
||||
<view class="" @click="changeFullReductionCouponSel(item)"
|
||||
v-for="(item,index) in myQuan.res.fullReductionCoupon" :class="{filtergray:!item.use}" :key="index">
|
||||
<view class="quan u-row-between u-flex u-col-center u-m-b-32 border-r-10 ">
|
||||
<view class="no-use" v-if="!item.use">
|
||||
<image class="img" src="/pagesOrder/static/image/no-use.svg" mode=""></image>
|
||||
</view>
|
||||
<view class="sel u-abso" v-if="item.id==myQuan.fullReductionCouponSel.id ">
|
||||
<up-icon name="checkbox-mark" color="#fff"></up-icon>
|
||||
</view>
|
||||
<view class="u-p-t-32 u-p-b-32 u-p-l-24 u-p-r-24">
|
||||
<view class="u-flex">
|
||||
<view class="hui">减</view>
|
||||
<view class="u-m-l-18">{{item.name}}</view>
|
||||
</view>
|
||||
<view class=" u-m-t-20 u-flex">
|
||||
<view>有效期:</view>
|
||||
<view class="u-font-24 u-m-l-6"> {{dayjs(item.endTime).format('YYYY-MM-DD HH:mm:ss') }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-10 color-999 u-font-24">
|
||||
{{ formatStr(item.useRestrictions)}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="right u-flex u-flex-col u-row-between">
|
||||
<view class="u-flex u-row-center u-font-36 ">
|
||||
¥{{item.discountAmount}}
|
||||
</view>
|
||||
<view class="u-flex u-font-24">
|
||||
满{{item.fullAmount}}可用
|
||||
</view>
|
||||
<view class="u-flex ">
|
||||
<view class="use-btn" @click.stop="toEmitChooseQuan(item)">去使用</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<template v-if="myQuan.res.fullReductionCoupon.length<=0&&myQuan.hasAjax">
|
||||
<my-img-empty tips="暂无可用优惠券"></my-img-empty>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<template v-if="myQuan.types.sel==1">
|
||||
<view class="" @click="changeProductCoupon(item)" v-for="(item,index) in myQuan.res.productCoupon"
|
||||
:class="{filtergray:!item.use}" :key="index">
|
||||
<view class="quan goods u-row-between u-flex u-col-center u-m-b-32 border-r-10 u-relative">
|
||||
<view class="no-use" v-if="!item.use">
|
||||
<image class="img" src="/pagesOrder/static/image/no-use.svg" mode=""></image>
|
||||
</view>
|
||||
<view class="sel u-abso" v-if="item.checked">
|
||||
<up-icon name="checkbox-mark" color="#fff"></up-icon>
|
||||
</view>
|
||||
<view class="u-p-t-32 u-p-b-32 u-p-l-24 u-p-r-24">
|
||||
<view class="u-flex">
|
||||
<up-image width="80rpx" height="80rpx" :src="item.productCover"></up-image>
|
||||
<view class="u-m-l-18">
|
||||
<view class="u-m-l-18">{{item.productName}}</view>
|
||||
<view class="u-m-l-18 u-m-t-10 u-font-24 color-666">x{{item.num}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class=" u-m-t-14 u-flex">
|
||||
<view>有效期:</view>
|
||||
<view class="u-font-24 u-m-l-6"> {{dayjs(item.endTime).format('YYYY-MM-DD HH:mm:ss') }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-10 color-999 u-font-24">
|
||||
{{ formatStr(item.useRestrictions)}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="right u-flex u-flex-col u-col-bottom u-row-center">
|
||||
<!-- <view class="u-flex u-row-center w-full">
|
||||
<view class="color-red font-bold u-m-b-24 ">¥{{item.discountAmount}}</view>
|
||||
</view> -->
|
||||
<view class="u-flex ">
|
||||
<view class="use-btn" @click.stop="toEmitChooseQuan(item)">去使用</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<template v-if="myQuan.res.productCoupon.length<=0&&myQuan.hasAjax">
|
||||
<my-img-empty tips="暂无可用优惠券"></my-img-empty>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
|
||||
</view>
|
||||
|
||||
<view :style="{height:safebottomHeight+'px'}"></view>
|
||||
<view class="fixed-b bottom safe-bottom border-top">
|
||||
|
||||
<view class="u-m-b-32 u-flex u-row-between u-p-t-10">
|
||||
<view class="u-flex">
|
||||
<text>抵扣金额:</text>
|
||||
<text class="color-red">¥</text>
|
||||
<text class="color-red">{{discountAmount}}</text>
|
||||
</view>
|
||||
<view class="u-flex u-relative">
|
||||
<text>支付金额:</text>
|
||||
<text class="color-red">¥</text>
|
||||
<text class="color-red">{{payPrice }}</text>
|
||||
<view class="u-absolute u-flex u-row-between" style="bottom: 100%;right: 0;"
|
||||
v-if="payPrice*1!=option.orderPrice*1">
|
||||
<view class="u-flex line-th color-999">
|
||||
<text class="">¥</text>
|
||||
<text class="">{{option.orderPrice}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex gap-20">
|
||||
<up-button shape="circle" plain @click="back">
|
||||
<view class="font-bold">取消</view>
|
||||
</up-button>
|
||||
<up-button shape="circle" type="primary" @click="toEmitChooseQuan()">
|
||||
<view class="font-bold">确定</view>
|
||||
</up-button>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
<up-modal :title="modal.title" :content="modal.content" :show="modal.clear" :confirmText="modal.confirmText"
|
||||
:cancelText="modal.cancelText" showCancelButton closeOnClickOverlay @confirm="confirmModelConfirm"
|
||||
@cancel="confirmModelCancel" @close="setModalShow('clear',false)" width="300px" />
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
ref,
|
||||
reactive,
|
||||
watch,
|
||||
computed,
|
||||
onMounted
|
||||
} from 'vue';
|
||||
import color from '@/commons/color.js'
|
||||
import dayjs from 'dayjs';
|
||||
import {
|
||||
getSafeBottomHeight
|
||||
} from '@/commons/utils/safe-bottom.js'
|
||||
import go from '@/commons/utils/go.js'
|
||||
import {
|
||||
onLoad,
|
||||
onReady
|
||||
} from '@dcloudio/uni-app'
|
||||
import * as orderApi from '@/http/yskApi/order.js'
|
||||
import {
|
||||
$activateByOrderId
|
||||
} from '@/http/yskApi/Instead.js'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
import {
|
||||
queryAllShopUser
|
||||
} from '@/http/yskApi/shop-user.js'
|
||||
import {
|
||||
returnNewGoodsList,
|
||||
returnCoupCanUse,
|
||||
returnCouponAllPrice,
|
||||
returnProductCoupon,
|
||||
returnCanUseFullReductionCoupon
|
||||
} from '../quan_util.js'
|
||||
|
||||
const modal = reactive({
|
||||
title: '提示',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
content: '',
|
||||
key: '',
|
||||
clear: false,
|
||||
data: ''
|
||||
})
|
||||
|
||||
function confirmModelCancel() {
|
||||
setModalShow('clear', false, '')
|
||||
}
|
||||
async function confirmModelConfirm() {
|
||||
if (modal.key == 'clear') {
|
||||
myQuan.fullReductionCouponSel = {
|
||||
id: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
const item = modal.data
|
||||
item.checked = !item.checked
|
||||
const CheckedArr = myQuan.res.productCoupon.filter(v => v.checked)
|
||||
const noCheckedArr = myQuan.res.productCoupon.filter(v => !v.checked)
|
||||
noCheckedArr.map(v => {
|
||||
console.log(returnCoupCanUse(canDikouGoodsArr, v, CheckedArr));
|
||||
v.use = returnCoupCanUse(canDikouGoodsArr, v, CheckedArr)
|
||||
})
|
||||
setModalShow('clear', false, '')
|
||||
}
|
||||
}
|
||||
|
||||
function setModalShow(key = 'show', show = true, data) {
|
||||
modal.key = key
|
||||
modal[key] = show
|
||||
modal.data = data
|
||||
}
|
||||
|
||||
|
||||
|
||||
function back() {
|
||||
uni.navigateBack()
|
||||
}
|
||||
let order = ref({
|
||||
|
||||
})
|
||||
let canDikouGoodsArr = []
|
||||
const myQuan = reactive({
|
||||
fullReductionCouponSel: {
|
||||
id: ''
|
||||
},
|
||||
res: {
|
||||
fullReductionCoupon: [],
|
||||
productCoupon: []
|
||||
},
|
||||
types: {
|
||||
list: ['满减券(单选)', '商品券(多选)'],
|
||||
sel: 0
|
||||
},
|
||||
list: [],
|
||||
sel: -1,
|
||||
hasAjax: false
|
||||
})
|
||||
|
||||
function changeProductCoupon(item) {
|
||||
if (!item.use) {
|
||||
return
|
||||
}
|
||||
if (myQuan.fullReductionCouponSel.id && !item.checked) {
|
||||
const goodsQuan = myQuan.res.productCoupon.filter(v => v.checked)
|
||||
const fullReductionCoupon = myQuan.fullReductionCouponSel.id ? [myQuan.fullReductionCouponSel] : []
|
||||
let coupArr = [...goodsQuan, item]
|
||||
const payPrice = option.orderPrice - returnCouponAllPrice(coupArr, canDikouGoodsArr, user.value)
|
||||
if (payPrice<=0) {
|
||||
modal.content = '选择该商品券后支付金额将为0,继续选择将取消选择的满减券'
|
||||
modal.cancelText = '取消'
|
||||
modal.confirmText = '继续选择'
|
||||
setModalShow('clear', true, item)
|
||||
return
|
||||
}
|
||||
if (myQuan.fullReductionCouponSel.fullAmount > payPrice) {
|
||||
modal.content = '选择该商品券后将不满足选择抵扣券的最低满减需求,继续选择将取消选择的满减券'
|
||||
modal.cancelText = '取消'
|
||||
modal.confirmText = '继续选择'
|
||||
setModalShow('clear', true, item)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
item.checked = !item.checked
|
||||
const CheckedArr = myQuan.res.productCoupon.filter(v => v.checked)
|
||||
if (CheckedArr.length <= 0) {
|
||||
return myQuan.res.productCoupon.map(v => {
|
||||
v.use = true
|
||||
})
|
||||
}
|
||||
const noCheckedArr = myQuan.res.productCoupon.filter(v => !v.checked)
|
||||
noCheckedArr.map(v => {
|
||||
console.log(returnCoupCanUse(canDikouGoodsArr, v, CheckedArr));
|
||||
v.use = returnCoupCanUse(canDikouGoodsArr, v, CheckedArr)
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
function changeFullReductionCouponSel(item) {
|
||||
if (!item.use) {
|
||||
return
|
||||
}
|
||||
console.log(item);
|
||||
if (item.id == myQuan.fullReductionCouponSel.id) {
|
||||
myQuan.fullReductionCouponSel = {
|
||||
id: ''
|
||||
}
|
||||
} else {
|
||||
myQuan.fullReductionCouponSel = item
|
||||
}
|
||||
myQuan.res.fullReductionCoupon = returnCanUseFullReductionCoupon($fullReductionCoupon, payPrice.value, myQuan
|
||||
.fullReductionCouponSel)
|
||||
}
|
||||
|
||||
function formatStr(str) {
|
||||
return str.replaceAll('"', '')
|
||||
}
|
||||
|
||||
function toUse(item) {
|
||||
|
||||
}
|
||||
let user = reactive({
|
||||
isVip: false
|
||||
})
|
||||
|
||||
let $fullReductionCoupon = []
|
||||
let $productCoupon = []
|
||||
async function getQuan() {
|
||||
order.value = await orderApi.tbOrderInfoDetail(option.orderId)
|
||||
if (order.value.memberId) {
|
||||
const userRes = await queryAllShopUser({
|
||||
id: order.value.memberId
|
||||
})
|
||||
if (userRes.content[0]) {
|
||||
user.value = userRes.content[0]
|
||||
}
|
||||
}
|
||||
|
||||
console.log(order.value);
|
||||
const res = await $activateByOrderId({
|
||||
orderId: option.orderId,
|
||||
memberId: option.memberId
|
||||
})
|
||||
canDikouGoodsArr = returnNewGoodsList(order.value.detailList || [])
|
||||
res.fullReductionCoupon = res.fullReductionCoupon.filter((v) => {
|
||||
if(option.orderPrice<=0){
|
||||
return false
|
||||
}else{
|
||||
return v.use && option.orderPrice * 1 >= v
|
||||
.fullAmount * 1
|
||||
}
|
||||
|
||||
})
|
||||
res.productCoupon = res.productCoupon.map(v => {
|
||||
const calcCoup = returnProductCoupon(v, canDikouGoodsArr, user.value)
|
||||
return {
|
||||
...calcCoup,
|
||||
checked: false,
|
||||
use:option.orderPrice<=0?false:v.use
|
||||
}
|
||||
}).filter((v) => v.use);
|
||||
$fullReductionCoupon = res.fullReductionCoupon
|
||||
$productCoupon = res.productCoupon
|
||||
myQuan.res = res
|
||||
myQuan.hasAjax = true;
|
||||
}
|
||||
const option = reactive({
|
||||
orderId: '',
|
||||
memberId: '',
|
||||
orderPrice: 0
|
||||
})
|
||||
|
||||
function toEmitChooseQuan(item) {
|
||||
let arr = []
|
||||
if (item) {
|
||||
arr = [item]
|
||||
} else {
|
||||
if (myQuan.fullReductionCouponSel.id) {
|
||||
arr.push(myQuan.fullReductionCouponSel)
|
||||
}
|
||||
const goodsQuan = myQuan.res.productCoupon.filter(v => v.checked)
|
||||
arr.push(...goodsQuan)
|
||||
}
|
||||
uni.$emit('choose-quan', arr)
|
||||
back()
|
||||
}
|
||||
const discountAmount = computed(() => {
|
||||
const goodsQuan = myQuan.res.productCoupon.filter(v => v.checked)
|
||||
const fullReductionCoupon = myQuan.fullReductionCouponSel.id ? [myQuan.fullReductionCouponSel] : []
|
||||
let coupArr = [...fullReductionCoupon, ...goodsQuan]
|
||||
return returnCouponAllPrice(coupArr, canDikouGoodsArr, user.value)
|
||||
})
|
||||
const payPrice = computed(() => {
|
||||
const pay = option.orderPrice - discountAmount.value
|
||||
return (pay < 0 ? 0 : pay).toFixed(2)
|
||||
})
|
||||
watch(() => myQuan.types.sel, (newval) => {
|
||||
if (newval == 0) {
|
||||
myQuan.res.fullReductionCoupon = returnCanUseFullReductionCoupon($fullReductionCoupon, payPrice.value,
|
||||
myQuan.fullReductionCouponSel)
|
||||
}
|
||||
if (newval == 1) {
|
||||
|
||||
}
|
||||
})
|
||||
onLoad((opt) => {
|
||||
Object.assign(option, opt)
|
||||
getQuan()
|
||||
})
|
||||
let safebottomHeight = ref(0)
|
||||
onReady(() => {
|
||||
getSafeBottomHeight('bottom', 0).then(height => {
|
||||
console.log(height);
|
||||
safebottomHeight.value = height
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
<style lang="scss" scoped>
|
||||
// $quan-color:rgb(233, 77, 60);
|
||||
$quan-color: #318AFE;
|
||||
|
||||
</style>
|
||||
.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;
|
||||
}
|
||||
</style>
|
||||
249
pagesOrder/quan_util.js
Normal file
249
pagesOrder/quan_util.js
Normal file
@@ -0,0 +1,249 @@
|
||||
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
|
||||
}
|
||||
console.log(selCoupNumber,findGoodsTotalNumber);
|
||||
return findGoodsTotalNumber < 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
|
||||
const canUse=coup.use
|
||||
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 returnProductCanUseNum(productPriceArr,startIndex,num){
|
||||
console.log(productPriceArr);
|
||||
console.log(num);
|
||||
let n=0;
|
||||
for(let i=0;i<num;i++){
|
||||
if(productPriceArr[startIndex*1+i]){
|
||||
n+=1
|
||||
console.log(n);
|
||||
}else{
|
||||
break
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
//返回同类商品券在同类商品价格数组里的开始位置
|
||||
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);
|
||||
const coupNum=Math.min(goodsPayPriceMap[coup.proId].length,coup.num)
|
||||
console.log(coupNum);
|
||||
total+=returnProductCoupAllPrice(goodsPayPriceMap[coup.proId],proCoupStartIndex,coupNum)
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
if(payPrice<=0){
|
||||
return {
|
||||
...v,
|
||||
use: false
|
||||
}
|
||||
}
|
||||
return {
|
||||
...v,
|
||||
use: v.use && isfullAmount
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//根据商品数量还有商品券数量返回优惠券可以使用的数量数组
|
||||
export function returnCanUseNumProductCoup(coupArr,){
|
||||
let productCoup = coupArr.filter(v => v.type == 2)
|
||||
//商品券分组
|
||||
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]
|
||||
}
|
||||
}
|
||||
return arr
|
||||
}
|
||||
1
pagesOrder/static/image/no-use.svg
Normal file
1
pagesOrder/static/image/no-use.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 6.4 KiB |
Reference in New Issue
Block a user