From cab9f836af2302d78681729b5b158368de2a3247 Mon Sep 17 00:00:00 2001
From: wwz <1144797966@qq.com>
Date: Tue, 11 Mar 2025 16:42:37 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E8=AF=A6=E6=83=85=E5=AE=8C?=
=?UTF-8?q?=E5=96=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
common/api/api.js | 19 ++-
common/api/pay.js | 9 ++
common/api/shop/index.js | 27 ++++
common/js/websocket.js | 2 +-
components/CustomNavbar.vue | 11 +-
components/payPassword.vue | 7 +-
pages/index/indexs.vue | 4 +-
pages/order/components/IntegralInput.vue | 152 ++++++++++++++++++
pages/order/components/orderInfoAfter.vue | 117 +++++++++-----
pages/order/coupon.vue | 17 +-
pages/order/detail.vue | 126 +++++++++++----
pages/product/components/confirmorder.vue | 9 +-
pages/product/index.vue | 13 +-
.../user/member/components/registermember.vue | 39 ++---
stores/order.js | 46 +++---
stores/pay.js | 34 +++-
16 files changed, 506 insertions(+), 126 deletions(-)
create mode 100644 pages/order/components/IntegralInput.vue
diff --git a/common/api/api.js b/common/api/api.js
index 727ac77..18f86bf 100644
--- a/common/api/api.js
+++ b/common/api/api.js
@@ -21,7 +21,6 @@ export const APIuserlogin = (data) => {
})
}
-
//用户信息获取
export const APIuser = (data) => {
return request({
@@ -31,3 +30,21 @@ export const APIuser = (data) => {
toast: false
})
}
+
+//获取手机号
+export const APIuserphone = (data) => {
+ return request({
+ url: url + '/user/phone',
+ method: 'post',
+ data: data
+ })
+}
+
+//文件上传
+export const APIuserupload = (data) => {
+ return request({
+ url: url + '/user/common/upload',
+ method: 'post',
+ data: data
+ })
+}
\ No newline at end of file
diff --git a/common/api/pay.js b/common/api/pay.js
index adfe022..27096fe 100644
--- a/common/api/pay.js
+++ b/common/api/pay.js
@@ -20,4 +20,13 @@ export const APIpayltPayOrder = (data) => {
method: 'post',
data: data
})
+}
+
+// 会员退款
+export const APIrefundVip = (data) => {
+ return request({
+ url: urlOrder + '/pay/vipPay',
+ method: 'post',
+ data: data
+ })
}
\ No newline at end of file
diff --git a/common/api/shop/index.js b/common/api/shop/index.js
index 9d788b7..61f3575 100644
--- a/common/api/shop/index.js
+++ b/common/api/shop/index.js
@@ -11,4 +11,31 @@ export const APIgeocodelocation = (data) => {
method: 'get',
data: data
})
+}
+
+//001-会员积分账户信息
+export const APImemberPointsmyPoints = (data) => {
+ return request({
+ url: urlAccount + '/user/points/memberPoints/myPoints',
+ method: 'get',
+ data: data
+ })
+}
+
+//002-获取订单可用积分及抵扣金额(支付页面使用)
+export const APImemberPointscalcUsablePoints = (data) => {
+ return request({
+ url: urlAccount + '/user/points/memberPoints/calcUsablePoints',
+ method: 'get',
+ data: data
+ })
+}
+
+//003-根据积分计算可抵扣金额
+export const APImemberPointscalcDeductionAmount = (data) => {
+ return request({
+ url: urlAccount + '/user/points/memberPoints/calcDeductionAmount',
+ method: 'get',
+ data: data
+ })
}
\ No newline at end of file
diff --git a/common/js/websocket.js b/common/js/websocket.js
index e8cdcd1..a3fd63f 100644
--- a/common/js/websocket.js
+++ b/common/js/websocket.js
@@ -78,7 +78,7 @@ const useWebSocket = (options = {}) => {
isConnected.value = true;
reconnectAttempts.value = 0;
// 监听初始化成功在开启心跳
- startHeartbeat();
+ // startHeartbeat();
},
fail: () => {
console.error('WebSocket 连接失败,尝试重连');
diff --git a/components/CustomNavbar.vue b/components/CustomNavbar.vue
index d3d16f1..f3765fc 100644
--- a/components/CustomNavbar.vue
+++ b/components/CustomNavbar.vue
@@ -34,7 +34,8 @@
watch,
onMounted,
computed,
- toRefs
+ toRefs,
+ watchEffect
} from 'vue';
const store = useNavbarStore();
@@ -63,7 +64,7 @@
const navbarStyle = computed(() => {
return {
- // height: `${height}px`,
+ // height: `${height}px`,store.showSearch=fa
backgroundColor: store.scrollTop >= 44 ? '#fff' : 'transparent'
};
});
@@ -72,6 +73,12 @@
oneStyle: {},
towStyle: {}
});
+
+ watchEffect(()=>{
+ if(store.showSearch>44){
+
+ }
+ })
onMounted(() => {
// #ifdef MP-WEIXIN || MP-ALIPAY
const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
diff --git a/components/payPassword.vue b/components/payPassword.vue
index 3e48b6b..db71cc5 100644
--- a/components/payPassword.vue
+++ b/components/payPassword.vue
@@ -22,6 +22,7 @@
import {
ref,
defineProps,
+ defineExpose,
defineEmits
} from 'vue';
@@ -34,7 +35,7 @@
});
// 定义向父组件发送事件
- const emits = defineEmits(['inputComplete', 'close']);
+ const emits = defineEmits(['inputComplete', 'close', 'closeModal']);
// 存储输入的密码
const password = ref('');
@@ -56,6 +57,10 @@
emits('close');
password.value = '';
};
+ // 将方法暴露给父组件
+ defineExpose({
+ closeModal
+ });
\ No newline at end of file
diff --git a/pages/order/components/orderInfoAfter.vue b/pages/order/components/orderInfoAfter.vue
index f2b71f4..54dc009 100644
--- a/pages/order/components/orderInfoAfter.vue
+++ b/pages/order/components/orderInfoAfter.vue
@@ -6,7 +6,7 @@
-
+
- {{item.value.uniqueIds}}个
- -¥{{item.value.Productroll}}
+ {{item.value.uniqueIds}}张
+ ¥-{{item.value.Productroll}}
-
-
-
- 使用 {{ calcUsablePointsData.pointsNum}}
- 积分抵扣¥{{calcUsablePointsData.pointsNum/calcUsablePointsData.equivalentPoints}}
-
-
- {{calcUsablePointsData.unusableReason||''}}
-
-
-
-
-
+
+
+
+ 使用 {{ calcUsablePointsData.integral}}
+ 积分抵扣¥{{props.listinfo.pointsDiscountAmount}}
+
+
+
@@ -236,6 +229,10 @@
{{ listinfo.seatNum || ""}}
+
@@ -252,6 +249,14 @@
defineExpose
} from 'vue'
+ import IntegralInput from './IntegralInput.vue';
+
+ import {
+ APImemberPointsmyPoints,
+ APImemberPointscalcUsablePoints,
+ APImemberPointscalcDeductionAmount
+ } from '@/common/api/shop/index.js'
+
// 定义自定义事件
const emits = defineEmits(['customevent', 'istype']);
@@ -315,15 +320,6 @@
}
})
- const calcUsablePointsData = reactive({
- usable: '',
- pointsNum: '',
- equivalentPoints: '',
- unusableReason: '',
-
- })
- const isPointsChecked = ref(false)
-
const is_type = ref(0)
// 监听送餐/打包切换
const tabClick = (item, index) => {
@@ -342,20 +338,12 @@
}
- const childOnShow = () => {}
-
- // * 监听优惠券/商品券选择
- const changeCoupon = (data) => {}
-
- const setPayAmount = (cartLists) => {}
-
- // * 积分状态监听
- const pointsChange = () => {}
-
// 跳转
const goUrl = (item) => {
switch (item.type) {
case 'coupon':
+ // 清空积分
+ IntegralInputclose()
uni.pro.navigateTo('/pages/order/coupon', {
type: "confirm_order_coupon",
shopId: uni.cache.get('orderVIP').shopId,
@@ -365,6 +353,11 @@
})
break;
case 'product':
+ // 清空积分
+ IntegralInputclose()
+ // 清空优惠卷
+ props.listinfo.coupondiscountAmount = 0
+ favorablelist[1].value = ''
uni.pro.navigateTo('/pages/order/coupon', {
type: "confirm_order_product",
shopId: uni.cache.get('orderVIP').shopId,
@@ -373,11 +366,52 @@
shoppingCart: JSON.stringify(props.listinfo.combinedArray)
})
break;
+ case 'points':
+ if (calcUsablePointsData.usable == 0) {
+ uni.showToast({
+ title: '此次订单不可用积分!'
+ })
+ return false;
+ }
+ calcUsablePointsData.showModal = true
+ break;
}
}
+ // 积分
+ const calcUsablePointsData = reactive({
+ minIntegral: 1, //最小
+ maxIntegral: '', //最多积分
+ instructionText: '',
+ unusableReason: '',
+ showModal: false,
+ integral: ''
+ })
+ const handleConfirm = async (integral) => {
+ calcUsablePointsData.integral = integral
+ props.listinfo.pointsDiscountAmount = await APImemberPointscalcDeductionAmount({
+ points: integral,
+ userId: props.orderVIP.id,
+ orderAmount: props.listinfo.totalCost
+ })
+ emits('clickPointsamount', props.listinfo.pointsDiscountAmount);
+ };
+
// * 获取积分相关信息
- const getCalcUsablePoints = async () => {}
+ const getCalcUsablePoints = async (data) => {
+ Object.assign(calcUsablePointsData, data);
+ calcUsablePointsData.minIntegral = data.minDeductionPoints
+ calcUsablePointsData.maxIntegral = data.maxUsablePoints
+ calcUsablePointsData.instructionText = `请输入 ${ data.minDeductionPoints} - ${data.maxUsablePoints} 之间的积分`
+
+ }
+
+ // 积分取消清空
+ const IntegralInputclose = async () => {
+ calcUsablePointsData.integral = null
+ props.listinfo.pointsDiscountAmount = 0
+ calcUsablePointsData.showModal = false
+ }
// * 复制订单号
const copyHandle = (e) => {
@@ -394,7 +428,8 @@
// 将方法暴露给父组件
defineExpose({
- dataprocessing
+ dataprocessing,
+ getCalcUsablePoints
});
diff --git a/pages/order/coupon.vue b/pages/order/coupon.vue
index 82f0a71..881dc3d 100644
--- a/pages/order/coupon.vue
+++ b/pages/order/coupon.vue
@@ -64,11 +64,14 @@
-
+
确定
+
+
+
@@ -256,12 +259,24 @@
console.log(res)
}
+ // 商品取消
const cancelCoupon = () => {
uni.$emit('returnData', Selectedlist.value);
uni.navigateBack({
delta: 1
});
}
+
+ // 优惠卷取消
+ const IntegralInputclose = () => {
+ uni.$emit('returnData', {
+ typeOrder: Orderinfo.typeOrder,
+ });
+ uni.navigateBack({
+ delta: 1
+ });
+ }
+
onMounted(async () => {
// 获取当前页面栈
const pages = getCurrentPages();
diff --git a/pages/order/detail.vue b/pages/order/detail.vue
index c4e87a4..98a9b24 100644
--- a/pages/order/detail.vue
+++ b/pages/order/detail.vue
@@ -1,17 +1,19 @@
-
+
-
-
- 待支付
-
- 已完成
+
+ 待支付
+ 已完成
+ 退单
+ 部分退单
+ 取消订单
+
+ 下单时间:{{ listinfo.createTime }}
+
+ 付款时间:{{listinfo.paidTime}}
-
- 下单时间:{{ listinfo.createTime }}
- 付款时间:{{listinfo.paidTime}}
@@ -33,7 +35,8 @@
+ :listinfo="listinfo" :orderVIP="orderVIP" :ordershopUserInfo='ordershopUserInfo' @istype="istype"
+ @clickPointsamount='clickPointsamount'>
@@ -60,7 +63,8 @@
-->
-
+
- 购物车
{{ shopInfo.name }}
@@ -218,7 +217,7 @@
return total + parseFloat(item.memberPrice) * parseFloat(item.num);
} else {
// salePrice销售价
- return total + parseFloat(item.salePrice) * parseFloat(item.num);
+ return total + parseFloat(item.price) * parseFloat(item.num);
}
}, 0);
console.log(cartone)
@@ -436,7 +435,7 @@
.head {
display: flex;
justify-content: space-between;
- padding: 32rpx 0;
+ // padding: 32rpx 0;
.head_left {
display: flex;
@@ -780,7 +779,7 @@
.head_bg {
height: 456rpx;
- background: linear-gradient(180deg, #E8AD7B 0%, #F5F5F5 100%);
+ // background: linear-gradient(180deg, #E8AD7B 0%, #F5F5F5 100%);
position: absolute;
left: 0;
right: 0;
diff --git a/pages/product/index.vue b/pages/product/index.vue
index 12805b8..188c27a 100644
--- a/pages/product/index.vue
+++ b/pages/product/index.vue
@@ -1,6 +1,6 @@
-
+
-
+
{{ ifcartNumber(item) }}
@@ -106,7 +106,7 @@
v-if="item.suitNum>1">{{item.suitNum<99?item.suitNum:'99+'}}
-
+
@@ -419,7 +419,7 @@
store.updateNavbarConfig({
showBack: true, //左边返回键
rightText: '', //右边文字
- showSearch: true, //true是标题其他事文字
+ showSearch: false, //true是标题其他事文字
title: '',
isTransparent: false,
hasPlaceholder: false //是否要占位符
@@ -561,6 +561,11 @@
uni.$u.debounce(store.scrollTop = res.scrollTop, 500)
uni.$u.debounce(navScroll.value = res.scrollTop, 500)
uni.$u.debounce(mainScroll(res), 500)
+ if(res.scrollTop >= 44){
+ store.showSearch = true
+ }else{
+ store.showSearch = false
+ }
});
// 点击详情
diff --git a/pages/user/member/components/registermember.vue b/pages/user/member/components/registermember.vue
index b0c6082..a238a0e 100644
--- a/pages/user/member/components/registermember.vue
+++ b/pages/user/member/components/registermember.vue
@@ -92,6 +92,9 @@
APIshopUser
} from '@/common/api/member.js'
+ import {
+ APIuserphone
+ } from '@/common/api/api.js'
const props = defineProps({
shopUserInfo: {
@@ -167,8 +170,7 @@
//#ifdef MP-WEIXIN
let avatarUrl = e.detail.avatarUrl
uni.uploadFile({
- url: uni.conf.baseUrl + '/common/upload',
- // url: uni.conf.baseUrl + '/common/upload',
+ url: uni.conf.baseUrl + '/account/user/common/upload',
filePath: avatarUrl,
header: {
environment: 'app',
@@ -202,7 +204,7 @@
let avatarUrl = res.tempFilePaths[0]; // 获取文件路径
my.uploadFile({
- url: uni.conf.baseUrl + '/common/upload',
+ url: uni.conf.baseUrl + '/account/user/common/upload',
filePath: avatarUrl,
header: {
environment: 'app',
@@ -236,8 +238,8 @@
// 确定生日
const confirmTime = (e) => {
- this.calendarShow = false;
- this.birthDay = this.getDate(e.value);
+ calendarShow.value = false;
+ formInfo.birthDay = getDate(e.value);
}
// 获取手机号
@@ -247,14 +249,13 @@
uni.login({
provider: 'weixin',
success: async (data) => {
- console.log(data)
- // let res = await APIshopUser({
- // code: data.code,
- // encryptedData: d.detail.encryptedData,
- // iv: d.detail.iv,
- // source: "wechar"
- // })
- formInfo.telephone = res.data
+ let res = await APIuserphone({
+ code: data.code,
+ encryptedData: d.detail.encryptedData,
+ iv: d.detail.iv,
+ source: "wechar"
+ })
+ formInfo.telephone = res
}
})
}
@@ -267,11 +268,11 @@
console.log(res)
my.getPhoneNumber({
success: async (data) => {
- let res = await this.api.userwxlogins({
+ let res = await APIuserphone({
encryptedData: JSON.parse(data.response).response,
source: "alipay"
})
- this.telephone = res.data
+ formInfo.telephone = res
// console.log(this.phonetitle)
}
});
@@ -331,12 +332,12 @@
});
return;
}
- let res = await this.api.openMember({
- id: uni.cache.get('userInfo').id,
- shopId: uni.cache.get('shopId'),
+ let res = await APIshopUser({
+ // id: uni.cache.get('userInfo').id,
+ // shopId: uni.cache.get('shopId'),
nickName: formInfo.nickName,
headImg: userHeadImg.value,
- telephone: formInfo.telephone,
+ phone: formInfo.telephone,
birthDay: formInfo.birthDay
})
if (res.code == 0) {
diff --git a/stores/order.js b/stores/order.js
index 34b02db..ab706ce 100644
--- a/stores/order.js
+++ b/stores/order.js
@@ -16,11 +16,19 @@ export const useCartStore = defineStore('cart', () => {
// const isTableFee = uni.cache.get('ordershopUserInfo').isTableFee //此店是否免桌位费
// const tableFee = uni.cache.get('ordershopUserInfo').tableFee //一个餐位费多钱
- // 计算单个商品的打包费用(向下取整并保留两位小数)
- const itemSinglePackFee = (item) => {
- const fee = item.packFee * item.cartNumber;
- // 先将结果乘以 100,向下取整,再除以 100 以保留两位小数
- return Math.floor(fee * 100) / 100
+ // 计算向上取整
+ const roundUpToTwoDecimals = (num, i) => {
+ // 先将数字乘以 100 并转换为字符串保留足够的小数位
+ let temp = (num * 100).toFixed(10);
+ // 向上取整
+ let rounded = null
+ if (i == 'upward') {
+ rounded = Math.ceil(parseFloat(temp));
+ } else {
+ rounded = Math.floor(parseFloat(temp));
+ }
+ // 再除以 100 得到保留两位小数的结果
+ return rounded / 100;
};
// 计算购物车商品总价格
@@ -43,7 +51,8 @@ export const useCartStore = defineStore('cart', () => {
}
}, 0);
// 向上取整并保留两位小数
- return cart = Math.ceil(cart * 100) / 100;
+ let result = roundUpToTwoDecimals(cart, 'upward')
+ return result;
});
// 计算商品卷所选择的总价格
@@ -64,34 +73,33 @@ export const useCartStore = defineStore('cart', () => {
}
}, 0);
// 向上取整并保留两位小数
- return cart = Math.ceil(cart * 100) / 100;
+ let result = roundUpToTwoDecimals(cart, 'upward')
+ return result;
});
// 桌位置
const getTotalSeatcharge = (seatNum) => computed(() => {
// 是否免除桌位费 0 否 1 是
- let tableFeeTotals = 0
+ let cart = 0
- if (uni.cache.get('ordershopUserInfo').isTableFee == 0 && (seatNum || uni.cache.get('dinersNum'))) {
- tableFeeTotals = Math.ceil(parseFloat((seatNum || uni.cache.get('dinersNum'))) * parseFloat(
+ if (uni.cache.get('ordershopUserInfo').isTableFee == 0 && seatNum) {
+ cart = Math.ceil(parseFloat(seatNum) * parseFloat(
uni.cache.get('ordershopUserInfo').tableFee) * 100) / 100;
}
- console.log(uni.cache.get('ordershopUserInfo').isTableFee,seatNum,22222)
- return Math.floor(tableFeeTotals * 100) / 100;
+ // 向下取整并保留两位小数
+ let result = roundUpToTwoDecimals(cart, 'downward')
+ return result;
});
// 计算购物车总打包费用(向下取整并保留两位小数)
const getTotalPackFee = (cartList) => computed(() => {
- let total = 0;
- for (const item of cartList) {
- total += itemSinglePackFee(item);
- }
- return Math.floor(total * 100) / 100 ? Math.floor(total * 100) / 100 : 0;
- // 同样对总费用进行向下取整并保留两位小数处理
+ const total = cartList.reduce((sum, item) => {
+ return sum + item.packAmount * (item.packNumber || (item.num - item.returnNum));
+ }, 0);
+ return Math.floor(total * 100) / 100;
});
return {
- itemSinglePackFee,
getTotalPackFee,
getTotalSeatcharge,
getTotalTotalPrices,
diff --git a/stores/pay.js b/stores/pay.js
index 6bef341..86fdc6e 100644
--- a/stores/pay.js
+++ b/stores/pay.js
@@ -8,7 +8,8 @@ import {
import {
APIpayltPayOrder,
- APIpayltPayVip
+ APIpayltPayVip,
+ APIrefundVip
} from '@/common/api/pay.js'
import {
@@ -182,6 +183,37 @@ export const Memberpay = defineStore('memberpay', {
})
},
+ //会员支付
+ balancePayOrder(data) {
+ return new Promise(async (resolve, reject) => {
+ try {
+ let res = await APIrefundVip({
+ shopId: uni.cache.get('shopId'),
+ checkOrderPay: data.checkOrderPay,
+ pwd: data.pwd,
+ payType: 'accountPay',
+ returnUrl: data.returnUrl,
+ buyerRemark: data.buyerRemark,
+ shopUserId: data.shopUserId,
+ })
+ if (res) {
+ uni.showLoading({
+ title: '加载中...',
+ mask: true
+ })
+ }
+ } catch (e) {
+ uni.showToast({
+ title: "支付失败"
+ })
+ setTimeout(() => {
+ uni.hideLoading()
+ }, 1000)
+ reject(false)
+ }
+ })
+ },
+
// 生成订单
actionscreateOrder(data) {
return new Promise(async (resolve, reject) => {