1S06DB>ShxCA7kW3ouH(tC-*z@}QXf`GK8=q_bd!FQdL}2PBGa
zKsLwR*-NDQ-baRsJZl@i^%i-ubFZGd+@91g+81ZMVs;#Jkmj{x93Kc5a
z1YtCNPT`u%&
zp3KY~dNhmO83wzn$jmkOEVQwb0%BlvRDY*vKP*rOpSP;*a)^tgPqE?(=Y{E8P;y!3
z`Ytf`$te_}Fr5~3-eM@3O7qrkxWK%2e$uRY+au(&4vxXW2UZHanZA
z=Wwd#pm@2Jme`k)p6c&DTpYPB=hKzp#FT-QlI<3V)g{knf=Q<{{OZD|45bqohQ>WD
zb!@IIN0LGHy7AOCp!mztMkYCW<|6&8)*+-p<9v*pl4)xelf}>#)AA#CUTy!}LD5`n
z*;*y{n#q)5NM@2LULPJ|cs_y6uAryV)Gdmzv!RZPWy?V|`?G;IIYn@sdyZ_>ErTw(zz__
z%02vG^Cncc2V-`U6UX1_a9jp46h2$
z)iQPMrNaL|{`)=cnVh!Qkb0Y;>EvQ@%DrWrIdzIvO-p$E-mR7l#6Ld6<2@ge{>GiW
z`|4ZVa`)YAXus8()vSb;vd73~_wL?y-=BR?bi=nFH-dKmBRkveh`l10YqOU*kh;N^
zrh4vcUW|$$dEo;8cI*_1Z`{M=@F=-dj16~eMYTJ7bRqWc?zs2==Y`d^;P&j@6UZfV
zJE|%x+wZOlHLMB;1H$cEt&faw=*VwB`t0_$sK@6YNJpo;Yg$`h+tu;SFZD|A{{Zgj
VB$+|kekA|^002ovPDHLkV1l9%DDeOQ
literal 0
HcmV?d00001
diff --git a/static/icon/add-goods.png b/static/icon/add-goods.png
new file mode 100644
index 0000000000000000000000000000000000000000..d6ee88fa975e0d6b91e563fb39d667ea13ceaad0
GIT binary patch
literal 1289
zcmV+k1@`)hP)Px(!%0LzRA@u(S;0~oSrk3@(WH`@4cQoQrC%`Q3r4>n60B_1FBsjWgetH~%A4Hj~)r*kqfi9AtkbRw$jSvk7{AoMzxunM>=NVJtTJhfCNxo%2)QH0-a<(7b2Ht
zIrXpXUyeKcN+h4J=E~hk;G+CK7b0!*?Fz}nR|SMY2R&g_pUUeE0)24)CX%a}T-k~O
zbdv4di3q_jmvTof1*B6iC~_-5B@rF;BaumQ1Oyjg2`OS^#}Kwia82ULNgOXlCi2xRr=Fo-
z3Ti(<)CBYANg<=eK-flBf;Wipr>ZTQo1C1A+LJ{h(l*O0B>QLj!RqFv#Bt9ss&PZ3
zUEkj(P|3S5YClABFYKP7iF`Nrvn<7#9u_R=U>XAceEO$e*i8_Xltd4Hvsfh8!-QHW
zA^{{UAvou@9)3V7{C>yviVczK!DxlORkhEc2I*c8MP?!qe>f4S@k1CpesBu>Z@B)8
znbvdxh*L9E_uRAlRU&M;p1Bgqm-k)BL?Ui~x_!l1w*ARpQ$$Pl!dMXG9CBAb`p<
z*W5p2c3+utFP(o^4YD0eWDru$o5E=`guR~0{XKj`d_OI0F;i7}VHV0Y?xr27X5)My
z0NpE*Tn!4bu|zKFg%1okVZ`7aUDpSmICl?k?2@Ih2B463@
zF9{^#@rEy?Jju^!T_uw1QB)}|$OS?X_%XhVso2|CyD;deH=ULo$C}-aOh+m=qc3GK?EbkB9&ww~GOE)A`DC_XdXq1L{eXTaIEo45bif
zju5%{R6J)=uRL!7{ATWFg{|b6o6DQ;8c_hnwVjGcr(R%nuw*`7-aHx^dBz15XI*R}
z{t2O9;^Ke_yGG@p;J&G~@F0lPUH`^+lS!toki4S=AW(k)Pa?X=gdy**C7vA7i71Jc
zf=<}BQ$!Sfs1OE?Ya@j96h^BjZ#t{~Hd6~&;r|>-JCxqpWRrPaYd*ngEhd8W#TBs3YD@;o?S`f|s5&5Q(bgvqTkjuY2o=Hil7S
z%!U03)bfv{CXRy^mW>bCBaub()T2ih%_IK-CJMe$w;4*000000NkvXXu0mjf71CSo
literal 0
HcmV?d00001
diff --git a/static/icon/coup.png b/static/icon/coup.png
new file mode 100644
index 0000000000000000000000000000000000000000..558815adde14d5a86e4fc8d6aa4f626aacdb81e3
GIT binary patch
literal 619
zcmV-x0+juUP)Px%B}qg3>Da`}^p!aBee7~(Wd2dtEuF!PXz79#RQM1Ly=?K1Nn5#2EJn6=iw@uk&jeVotd
zam8@i^2V4@L|z~k00kGFbDQ&62T0G=03N#=je^H2SMcSmHvWq<_=kwPA~K4iXng9E
zpJV=;^?iA>zV{?iN)4HLlHYjI>2wCO*=%u+g$}*PcB*AYjhiT?zB2Oz3>%436{Iod
zRYU?9w20gzk2mHV1VOjmZu?B0I_Cz5Dsam0l~NDPJc2;T;5d%6T`Z+X4vFYP9uBOv
z(^D2bWUi0gG)+HvxE(-T&{{td(H%42TWj(8;=^YzGf%CxrJdW!-~2p&M-@5ezFnN|
zy*U_)2nzMdIfu?_Gim|2Pm~=%tu@p`RgbN;IJ6fZh4yNvI7@*2e*b2*TA>fSYJa$|
zI5&VrlVs*+YwhjDr7J98j2Vdtytw4U86YGkqDgL&B_FyLWUeB14@QmGk8x(y1%m`j
zC2(GZt*{`Z3A&lASwK-FN%9!San&zPh+f|xH18xwAK|9uKU%tcVx!Px&P)S5VR9Hvtm|t?*Fc8LfMf^?kPCU~eiHcMMp60Gkdo@snpPOFymjX}=Z1fjxL&yzmNK_KG=2xYcUa
z=JR=%i2Q<~W}fHu#^dqKrC%pt&iQ))_yzz~mrl2A)0R>WZ2!6fKL9`t0B!(agosbJ
zj$OYKQ3n7n0N^Q#qWW|?HTG=#I5_zjwsn)|oZl*6!5F)oOeX4m?a=~nk}iMUg&jn=SOU)ug*c)Z
zZr*$fjczOm0_&+{0!|FcCW2GTe>4Z5SQ1sh7-sV$n67RUU4&h>p$XV2^Xw|N?EfyA
zH5WKNVi3_NxFTUQ2_zAo=Xv$KDkK*;^}sIfsc7glS?PqQ15VRqPY4kf4Q1-jCOjRm
za|KZJWHPHel2Wdn**f4
zC^~JcVJb@3fcH^!Isj|EabAQ=FFI|&rlK@2!lf6THegdxx&-W!8f}9W^<7t#E&=be
z=(J5tSCp;-TkV}~prXF(?Clb8YM}Q~blN7SD@s>^|C@(codD-tU0tc0&80iN+&!F>
zH$>Nru~M$4Y|)M5_$?wPrfYEp`_CSj5{Iqd(!V3(np?~@KWhIl#@>~DGusqFT*Qv(Ggwk@8BZ*0=@R=JUH10>i_@%07*qoM6N<$g308cQUCw|
literal 0
HcmV?d00001
diff --git a/static/icon/points.png b/static/icon/points.png
new file mode 100644
index 0000000000000000000000000000000000000000..d579e844c17a56505b6d896d5c3f3094b75877c2
GIT binary patch
literal 964
zcmV;#13UbQP)Px&en~_@R9HvtnO{;GK@i5jo+VYjg*>LpDBJ+pwaPc~1d-wZ>Io7~z;J@#2{g}<
z;0;3Fta8!K382KPJchg)b~+jUm<1M?C0UFqe6@S#H(&R5&oqQ5_D4^Q7i-|SBldqN
z>^M%Inacn&0Fp7O<}vfh_4V~xl=Y_+&gF7tB9c)S`9oXJ_x*j(^SUPMi~;9zxg#Pv
z)s93|>GgV5(}hen3)&3#(osz5y(}S~C>5*=(+?dIX}n@49Yd4ZKK!sQ-^u
zVaIXa>3oX{HLN$;^$-`Ie6c6KsKsheeBwGT5Nhc$`VfOQGdC2v{aS#>rx;AKG<
z`K^J23hnOhrta_W=ca{aS)NG)7_A$t!lSM$ku`7>wU)76D?CfJPF?0%
z@oOO{$;_z-J4P3vFA!+FD#*vbz~9#7kpPz&_zgMZR0OnH(D6L*SW}`?tCRsX`5NvL
z&}AZBbCVdTJvRGLpwf0xhCYI018&u2DxtVF6tfFOCy4~kUKZq3bGWO^jPmi8h!02h
zJwfSoK~BvoVgtTCmj^_wyBHXByj7G7Cp?{xvI^!m+9x3>9d@|bfLnE$Oep>q__#bG
zdd~u00%&WPuXUN~^>bV8fhi9jJP>p){}7a2sls~W+jDsq2(xk7RiMgtQHD-}VpCYt
z-POu1lj<;e60PuNv62ouVQiD1&Ig%?U_FM?SzLhVnZG;4>?D
zARK@OIZT4Gn*}*_RSli30Vp(^%?slgh8PBc8K`a*D^pMWNw>RN`ILbpW8lE_vdhe+
zsI%K3fd1&7DZY6~2||Mvo%j|S!H-GXSqi$M90or+qmt%E-x=bpE-SSg*-DdmWAi6kR+k!!uU=E&lk9u2WkWy
mRozwCuWSzdw+{2Px%Z%IT!R9HvFmyJ;rK@f%eWuO^I1V{vW5kLqK0TKZcfe--_0U7~k1VRL81d_pX
z-_{J(JJWOL?QJ<-b#*^=GxKe~{u`JxlAq1&gPHwsKkK{9|K^wN`uWhzegpVaE<^$I
z)y&oa^gbHNQvm`v+x67w|C{zJVeZZB4#2kp<^;gWLNFiA>SM9HCoN%*X>exU?q#*Nq^qN=ON#
zO>d)=BUxqHK55>P_cef%%fl2-ZvF0y;hr#IA@wjSYNt_g8zcP7`BTZE^4j1fCDvHkl-uj36SC~bcWy->;TzHsfTx<&NIWi@fs$6)O
zun?t%8~f87pj0ky{Dk0PnzbZ#@qGG)`GcbCA%sqcSO;S3{61#o2Y
zl4fE}a!T=wePX3ps|Yz=dFXdc`ZT5)6B26P$S^nCdpz
b32yxtldy~^g1D+S00000NkvXXu0mjf#q=uH
literal 0
HcmV?d00001
diff --git a/stores/carts.js b/stores/carts.js
new file mode 100644
index 0000000..9e4015d
--- /dev/null
+++ b/stores/carts.js
@@ -0,0 +1,452 @@
+import {
+ defineStore
+} from 'pinia';
+import {
+ ref,
+ computed,
+ reactive,
+ watchEffect
+} from 'vue';
+import {
+ productminiApphotsquery,
+ APIgroupquery,
+} from "@/common/api/product/product.js";
+export const useCartsStore = defineStore('cart',
+ () => {
+ // const dinersNum = uni.cache.get('dinersNum')
+ // const isVip = uni.cache.get('orderVIP').isVip //此用户是否是会员
+ // const isMemberPrice = uni.cache.get('ordershopUserInfo').isMemberPrice //此店是否可以用会员
+ // const isTableFee = uni.cache.get('ordershopUserInfo').isTableFee //此店是否免桌位费
+ // const tableFee = uni.cache.get('ordershopUserInfo').tableFee //一个餐位费多钱
+
+ const goodsIsloading = ref(true);
+
+
+
+ //商品数据Map
+ const goodsMap = reactive({})
+ //获取商品数据
+ async function goodsInit() {
+ goodsIsloading.value=true;
+ //获取招牌菜商品
+ const hotres = await productminiApphotsquery();
+ for (let product of hotres) {
+ setGoodsMap(product.id, product)
+ }
+ //获取分组商品
+ const groupres = await APIgroupquery()
+ for (let group of groupres) {
+ for (let product of group.productList) {
+ setGoodsMap(product.id, product)
+ }
+ }
+ goodsIsloading.value = false
+ }
+
+ function setGoodsMap(product_id, data) {
+ goodsMap[product_id] = data;
+ }
+
+ //websocket回执
+ const websocketsendMessage = (data) => {
+ uni.$u.debounce(sendMessage(data), 500)
+ }
+
+ const isLoading = ref(true);
+
+ function getProductDetails(v) {
+ const goods = goodsMap[v.product_id]
+ if (!goods) {
+ return undefined
+ }
+ let skuData = undefined;
+ skuData = goods?.skuList.find((sku) => sku.id == v.sku_id);
+
+ // if (goods.type == 'package') {
+ // //套餐商品
+ // const SnapSku = findInGroupSnapSku(goods.groupSnap, v.sku_id)
+ // skuData = { ...SnapSku, salePrice: SnapSku ? SnapSku.price : 0 }
+ // } else {
+ // skuData = goods?.skuList.find((sku: { id: string, salePrice: number }) => sku.id == v.sku_id);
+ // }
+ skuData = goods?.skuList.find((sku) => sku.id == v.sku_id);
+
+ if (skuData) {
+ return {
+ ...v,
+ productId: v.product_id,
+ salePrice: skuData ? skuData.salePrice : 0,
+ price: skuData ? skuData.salePrice : 0,
+ memberPrice: skuData ? skuData.memberPrice : 0,
+ coverImg: goods.coverImg,
+ productImg: goods.coverImg,
+ name: goods.name,
+ productName: goods.name,
+ specInfo: skuData.specInfo,
+ packFee: goods.packFee || 0,
+ type: goods.type,
+ skuData,
+ skuName: skuData.name,
+ num: v.number * 1
+ }
+ } else {
+ return undefined
+ }
+ }
+ // 用于记录已经处理过的消息的 msg_id
+ const processedMessageIds = new Set();
+
+ //购物车商品信息补全初始化
+ function cartsGoodsInfoInit(arr) {
+ carts.value = arr.map(v => {
+ return getProductDetails(v)
+ }).filter(v => v)
+ }
+
+
+ //收到socket消息时对购物车进行处理
+ async function onMessage(Message) {
+ console.log('Message');
+ console.log(Message);
+ if (Message) {
+ // 心跳返回 过滤
+ if (Message.type == "ping_interval" || Message.msg_id == "ping_interval") {
+ isLoading.value = false;
+ return false
+ }
+ // 检查消息是否已经处理过
+ if (processedMessageIds.has(Message.msg_id)) {
+ return;
+ }
+ processedMessageIds.add(Message.msg_id);
+ const msgData = Message.data
+ // 初始化
+ if (Message.operate_type == "init") {
+ console.log('carts init', msgData);
+ cartsGoodsInfoInit(msgData)
+ uni.hideLoading();
+ isLoading.value = false;
+ }
+
+ // 清空购物车
+ if (Message.operate_type == 'cleanup') {
+ carts.value = []
+ }
+
+ // 删除除购物车
+ if (Message.operate_type == 'del' && Message.status == 1) {
+ // 优化:使用可选链操作符避免报错
+ carts.value = carts.value.filter(item => item.id !== msgData?.id);
+ // carts.value = carts.value.filter(item => item.id != Message.data.id);
+ }
+
+ // 添加或者减少购物后返回
+ if (Message.operate_type == 'add' || Message.operate_type == 'edit') {
+ const index = carts.value.findIndex((v => v.id == msgData.id))
+ if (index !== -1) {
+ carts.value[index] = getProductDetails(msgData);
+ } else {
+ carts.value.push(getProductDetails(msgData));
+ }
+ }
+
+ // 历史订单
+ if (Message.operate_type == 'clearOrder') {}
+
+ // 购物车数据更新从新请求
+ if (Message.type == 'product' && Message.data_type == 'product_update' && Message
+ .operate_type == 'product_update') {
+ await goodsInit()
+ await cartsGoodsInfoInit()
+ }
+
+ // 提示
+ if (Message.status == 0 && Message.type != 'no_suit_num') {
+ uni.showToast({
+ title: Message.msg,
+ icon: "none"
+ })
+ }
+
+ if (Message.type == 'no_suit_num') {
+ // console.log(specifications)
+ uni.showModal({
+ title: '提示',
+ showCancel: false,
+ content: '此商品库存不足起售数量!',
+ success: async (data) => {
+
+ }
+ });
+ }
+
+
+
+ }
+ }
+
+
+ //购物车数据
+ const carts = ref([])
+
+ //历史订单数据
+ const oldOrder = ref({
+ detailMap: {},
+ originAmount: 0
+ })
+
+
+ // 会员信息
+ const orderVIP = ref(uni.cache.get('orderVIP') || {
+ isVip: false
+ })
+
+ function updateData(key, newval) {
+ if (key === 'orderVIP') {
+ uni.cache.set('orderVIP', newval)
+ return orderVIP.value = newval
+ }
+ if (key === 'shopInfo') {
+ uni.cache.set('shopInfo', newval)
+ return shopInfo.value = newval
+ }
+ }
+
+ // 商品订单会员
+ const shopInfo = ref(uni.cache.get('shopInfo') || {
+ isMemberPrice: 0
+ })
+
+ //是否使用会员价
+ const useVipPrice = computed(() => {
+ const isUse=(orderVIP.value.isVip && shopInfo.value.isMemberPrice)?true:false
+ console.log('useVipPrice',isUse);
+ return isUse
+ })
+ function currentCalcMpneyNumber(item){
+ const n=item.number-(item.returnNum||0)
+ return n<=0?0:n
+ }
+ //历史订单商品价格总和
+ const oldOrderMoney = computed(() => {
+ let total = 0
+ for (let i in oldOrder.value.detailMap) {
+ total += oldOrder.value.detailMap[i].reduce((prve, cur) => {
+ if (cur.isGift) {
+ return prve + 0
+ }
+ const discount_sale_amount = cur.discount_sale_amount * 1 || 0
+ const memberPrice = cur.skuData ? (cur.skuData.memberPrice || cur.skuData
+ .salePrice) : 0
+ const price = (discount_sale_amount || cur.salePrice || 0)
+ const number =currentCalcMpneyNumber(cur)
+ return prve + (number <= 0 ? 0 : number) * (discount_sale_amount || (useVipPrice
+ .value ? memberPrice : price))
+ }, 0)
+ }
+ return total
+ })
+
+ //当前购物车总价格
+ const totalPrice = computed(() => {
+ const money = carts.value.reduce((prve, cur) => {
+ const memberPrice = cur.memberPrice || cur.salePrice
+ const price = useVipPrice.value ? memberPrice : cur.salePrice;
+ const curMoney = price * currentCalcMpneyNumber(cur)
+ return prve + curMoney
+ }, 0)
+ return money
+ })
+ // 霸王餐购物车原价,不享受任何优惠
+ const totalOriginPrice = computed(() => {
+ const money = carts.value.reduce((prve, cur) => {
+ const curMoney = cur.salePrice * currentCalcMpneyNumber(cur)
+ return prve + curMoney
+ }, 0)
+ return money
+ })
+
+ //商品券抵扣金额
+ // const productCouponDiscountAmount = computed(() => {
+ // let index = -1;
+ // return quansSelArr.value.reduce((pre, cur) => {
+ // index++;
+ // return pre + returnProDiscount(cur, index) * 1;
+ // }, 0);
+ // });
+
+
+ //返回打包数量(称重商品打包数量最大为1)
+ function returnCartPackNumber(cur) {
+ const maxReturnNum = cur.number - (cur.returnNum || 0);
+ let pack_number = cur.number;
+ pack_number = (cur.product_type == 'weight' && pack_number > 1) ? 1 : pack_number;
+ pack_number = Math.min(maxReturnNum, pack_number);
+ pack_number = pack_number <= 0 ? 0 : pack_number
+ return pack_number * 1
+ }
+
+
+ //当前购物车打包费
+ const totalPackFee = computed(() => {
+ const money = carts.value.reduce((prve, cur) => {
+ const curMoney = (cur.packFee || 0) * currentCalcMpneyNumber(cur)
+ return prve + curMoney
+ }, 0)
+ return money
+ })
+
+ //打包费
+ const packFee = computed(() => {
+ const nowPackFee = carts.value.reduce((acc, cur) => {
+ return acc + (cur.packFee || 0) * returnCartPackNumber(cur)
+ }, 0)
+ let oldPackfee = 0;
+ for (let i in oldOrder.value.detailMap) {
+ oldPackfee += oldOrder.value.detailMap[i].reduce((prve, cur) => {
+ return prve + (cur.packFee || 0) * returnCartPackNumber(cur)
+ }, 0)
+ }
+ return nowPackFee + oldPackfee
+ })
+
+ //购物车是否为空
+ const isEmpty = computed(() => {
+ return !carts.value || carts.value.length <= 0
+ })
+ // 计算向上取整
+ 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;
+ };
+
+ // 精确计算函数
+ const preciseCalculation = (num1, num2) => {
+ // 将数字转换为整数,乘以 100 以保留两位小数
+ const int1 = BigInt(Math.round(num1 * 100));
+ const int2 = BigInt(Math.round(num2 * 100));
+ // 执行乘法运算
+ const result = int1 * int2;
+ // 再除以 10000 以还原为原来的小数
+ return Number(result) / 10000;
+ };
+
+ // 计算购物车商品总价格
+ const getTotalTotalPrices = (matchedProducts, isBwc = true) => {
+ if (!matchedProducts || !Array.isArray(matchedProducts)) {
+ return 0;
+ }
+ // console.log(uni.cache.get('orderVIP').isVip, uni.cache.get('ordershopUserInfo').isMemberPrice,
+ // 111)
+ // 购物车总数价格
+ console.log('isBwc');
+ console.log(isBwc);
+ let cart = matchedProducts.reduce((total, item) => {
+ if(isBwc===true){
+ return total + (parseFloat(item.price) * parseFloat(item.num - item.returnNum));
+ }
+ // 是否启用会员价 0否1是
+ if (useVipPrice.value) {
+ // memberPrice会员价
+ return total + (parseFloat(item.memberPrice || item.price) * parseFloat(item
+ .num - item
+ .returnNum));
+ } else {
+ // salePrice销售价
+ return total + (parseFloat(item.price) * parseFloat(item.num - item.returnNum));
+ }
+ }, 0);
+
+ cart = cart.toFixed(2)
+ console.log(parseFloat(cart))
+ // 向上取整并保留两位小数
+ // let result = roundUpToTwoDecimals(cart, 'upward')
+ return parseFloat(cart);
+ };
+
+ // 计算商品卷所选择的总价格
+ const getTotalProductroll = (matchedProducts) => computed(() => {
+ if (!matchedProducts || !Array.isArray(matchedProducts)) {
+ return 0;
+ }
+ // 购物车总数价格
+ let cart = matchedProducts.reduce((total, item) => {
+ // 是否启用会员价 0否1是
+ if (useVipPrice.value) {
+ // memberPrice会员价
+ return total + parseFloat(item.memberPrice || item.price)
+ } else {
+ // salePrice销售价
+ return total + parseFloat(item.price)
+ }
+ }, 0);
+ // 向上取整并保留两位小数
+ let result = roundUpToTwoDecimals(cart, 'upward')
+ return result;
+ });
+
+ // 桌位置
+ const getTotalSeatcharge = (seatNum) => computed(() => {
+ // 是否免除桌位费 0 否 1 是
+ let cart = 0
+
+ if (uni.cache.get('ordershopUserInfo').isTableFee == 0 && seatNum) {
+ cart = parseFloat(seatNum) * parseFloat(uni.cache.get('ordershopUserInfo').tableFee)
+
+ // Math.ceil(parseFloat(seatNum) * parseFloat(
+ // uni.cache.get('ordershopUserInfo').tableFee) * 100) / 100;
+ }
+ // 向下取整并保留两位小数
+ let result = roundUpToTwoDecimals(cart, 'downward')
+ return result;
+ });
+
+ // 计算购物车总打包费用(向下取整并保留两位小数)
+ const getTotalPackFee = (cartList) => computed(() => {
+ const total = cartList.reduce((sum, item) => {
+ return sum + (parseFloat(item.packAmount) * (parseFloat(item.packNumber) || (
+ parseFloat(item.num) - parseFloat(item.returnNum))));
+ }, 0);
+ // 向下取整并保留两位小数
+ let result = roundUpToTwoDecimals(total, 'downward')
+ return result;
+ // return Math.floor(total * 100) / 100;
+ });
+
+ //获取热门商品
+ async function getHotProduct() {
+
+ }
+
+ //获取分组商品
+ async function getGroupProduct() {
+
+ }
+
+ return {
+ getTotalPackFee,
+ getTotalSeatcharge,
+ getTotalTotalPrices,
+ getTotalProductroll,
+ carts,
+ isEmpty,
+ setGoodsMap,
+ goodsIsloading,
+ goodsInit,
+ onMessage,
+ totalPrice,
+ totalPackFee,
+ updateData,
+ useVipPrice,totalOriginPrice
+ };
+ }
+);
\ No newline at end of file
diff --git a/stores/order.js b/stores/order.js
index 59a2beb..a6132ab 100644
--- a/stores/order.js
+++ b/stores/order.js
@@ -2,130 +2,159 @@ import {
defineStore
} from 'pinia';
import {
+ ref,
computed,
+ reactive,
watchEffect
} from 'vue';
-import {
- ref
-} from 'vue';
-export const useCartStore = defineStore('cart', () => {
- // const dinersNum = uni.cache.get('dinersNum')
- // const isVip = uni.cache.get('orderVIP').isVip //此用户是否是会员
- // const isMemberPrice = uni.cache.get('ordershopUserInfo').isMemberPrice //此店是否可以用会员
- // const isTableFee = uni.cache.get('ordershopUserInfo').isTableFee //此店是否免桌位费
- // const tableFee = uni.cache.get('ordershopUserInfo').tableFee //一个餐位费多钱
+export const useCartStore = defineStore('cart',
+ () => {
+ // const dinersNum = uni.cache.get('dinersNum')
+ // const isVip = uni.cache.get('orderVIP').isVip //此用户是否是会员
+ // const isMemberPrice = uni.cache.get('ordershopUserInfo').isMemberPrice //此店是否可以用会员
+ // const isTableFee = uni.cache.get('ordershopUserInfo').isTableFee //此店是否免桌位费
+ // const tableFee = uni.cache.get('ordershopUserInfo').tableFee //一个餐位费多钱
- // 计算向上取整
- 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));
+ //商品数据Map
+ const goodsMap = reactive({})
+
+ function setGoodsMap(product_id, data) {
+ goodsMap[product_id] = data;
}
- // 再除以 100 得到保留两位小数的结果
- return rounded / 100;
- };
-
- // 精确计算函数
- const preciseCalculation = (num1, num2) => {
- // 将数字转换为整数,乘以 100 以保留两位小数
- const int1 = BigInt(Math.round(num1 * 100));
- const int2 = BigInt(Math.round(num2 * 100));
- // 执行乘法运算
- const result = int1 * int2;
- // 再除以 10000 以还原为原来的小数
- return Number(result) / 10000;
- };
- // 计算购物车商品总价格
- const getTotalTotalPrices = (matchedProducts, changeFreeenable = true) => computed(() => {
- if (!matchedProducts || !Array.isArray(matchedProducts)) {
- return 0;
- }
- // console.log(uni.cache.get('orderVIP').isVip, uni.cache.get('ordershopUserInfo').isMemberPrice,
- // 111)
- // 购物车总数价格
- let cart = matchedProducts.reduce((total, item) => {
- // 是否启用会员价 0否1是
- if (uni.cache.get('orderVIP').isVip == 1 && uni.cache.get('ordershopUserInfo')
- .isMemberPrice == 1 && changeFreeenable) {
- // memberPrice会员价
- return total + (parseFloat(item.memberPrice || item.price) * parseFloat(item
- .num - item
- .returnNum));
+
+ //购物车数据
+ const carts = ref([])
+ //购物车是否为空
+ const isEmpty = computed(() => {
+ return !carts.value || carts.value.length <= 0
+ })
+ // 计算向上取整
+ const roundUpToTwoDecimals = (num, i) => {
+ // 先将数字乘以 100 并转换为字符串保留足够的小数位
+ let temp = (num * 100).toFixed(10);
+ // 向上取整
+ let rounded = null
+ if (i == 'upward') {
+ rounded = Math.ceil(parseFloat(temp));
} else {
- // salePrice销售价
- return total + (parseFloat(item.price) * parseFloat(item.num - item.returnNum));
+ rounded = Math.floor(parseFloat(temp));
}
- }, 0);
-
- cart = cart.toFixed(2)
- console.log(parseFloat(cart))
- // 向上取整并保留两位小数
- // let result = roundUpToTwoDecimals(cart, 'upward')
- return parseFloat(cart);
- });
+ // 再除以 100 得到保留两位小数的结果
+ return rounded / 100;
+ };
- // 计算商品卷所选择的总价格
- const getTotalProductroll = (matchedProducts) => computed(() => {
- if (!matchedProducts || !Array.isArray(matchedProducts)) {
- return 0;
- }
- // 购物车总数价格
- let cart = matchedProducts.reduce((total, item) => {
- // 是否启用会员价 0否1是
- if (uni.cache.get('orderVIP').isVip == 1 && uni.cache.get('ordershopUserInfo')
- .isMemberPrice == 1) {
- // memberPrice会员价
- return total + parseFloat(item.memberPrice || item.price)
- } else {
- // salePrice销售价
- return total + parseFloat(item.price)
+ // 精确计算函数
+ const preciseCalculation = (num1, num2) => {
+ // 将数字转换为整数,乘以 100 以保留两位小数
+ const int1 = BigInt(Math.round(num1 * 100));
+ const int2 = BigInt(Math.round(num2 * 100));
+ // 执行乘法运算
+ const result = int1 * int2;
+ // 再除以 10000 以还原为原来的小数
+ return Number(result) / 10000;
+ };
+
+ // 计算购物车商品总价格
+ const getTotalTotalPrices = (matchedProducts, changeFreeenable = true) => computed(() => {
+ if (!matchedProducts || !Array.isArray(matchedProducts)) {
+ return 0;
}
- }, 0);
- // 向上取整并保留两位小数
- let result = roundUpToTwoDecimals(cart, 'upward')
- return result;
- });
+ // console.log(uni.cache.get('orderVIP').isVip, uni.cache.get('ordershopUserInfo').isMemberPrice,
+ // 111)
+ // 购物车总数价格
+ let cart = matchedProducts.reduce((total, item) => {
+ // 是否启用会员价 0否1是
+ if (uni.cache.get('orderVIP').isVip == 1 && uni.cache.get('ordershopUserInfo')
+ .isMemberPrice == 1 && changeFreeenable) {
+ // memberPrice会员价
+ return total + (parseFloat(item.memberPrice || item.price) * parseFloat(item
+ .num - item
+ .returnNum));
+ } else {
+ // salePrice销售价
+ return total + (parseFloat(item.price) * parseFloat(item.num - item.returnNum));
+ }
+ }, 0);
- // 桌位置
- const getTotalSeatcharge = (seatNum) => computed(() => {
- // 是否免除桌位费 0 否 1 是
- let cart = 0
+ cart = cart.toFixed(2)
+ console.log(parseFloat(cart))
+ // 向上取整并保留两位小数
+ // let result = roundUpToTwoDecimals(cart, 'upward')
+ return parseFloat(cart);
+ });
- if (uni.cache.get('ordershopUserInfo').isTableFee == 0 && seatNum) {
- cart = parseFloat(seatNum) * parseFloat(uni.cache.get('ordershopUserInfo').tableFee)
+ // 计算商品卷所选择的总价格
+ const getTotalProductroll = (matchedProducts) => computed(() => {
+ if (!matchedProducts || !Array.isArray(matchedProducts)) {
+ return 0;
+ }
+ // 购物车总数价格
+ let cart = matchedProducts.reduce((total, item) => {
+ // 是否启用会员价 0否1是
+ if (uni.cache.get('orderVIP').isVip == 1 && uni.cache.get('ordershopUserInfo')
+ .isMemberPrice == 1) {
+ // memberPrice会员价
+ return total + parseFloat(item.memberPrice || item.price)
+ } else {
+ // salePrice销售价
+ return total + parseFloat(item.price)
+ }
+ }, 0);
+ // 向上取整并保留两位小数
+ let result = roundUpToTwoDecimals(cart, 'upward')
+ return result;
+ });
+
+ // 桌位置
+ const getTotalSeatcharge = (seatNum) => computed(() => {
+ // 是否免除桌位费 0 否 1 是
+ let cart = 0
+
+ if (uni.cache.get('ordershopUserInfo').isTableFee == 0 && seatNum) {
+ cart = parseFloat(seatNum) * parseFloat(uni.cache.get('ordershopUserInfo').tableFee)
+
+ // Math.ceil(parseFloat(seatNum) * parseFloat(
+ // uni.cache.get('ordershopUserInfo').tableFee) * 100) / 100;
+ }
+ // 向下取整并保留两位小数
+ let result = roundUpToTwoDecimals(cart, 'downward')
+ return result;
+ });
+
+ // 计算购物车总打包费用(向下取整并保留两位小数)
+ const getTotalPackFee = (cartList) => computed(() => {
+ const total = cartList.reduce((sum, item) => {
+ return sum + (parseFloat(item.packAmount) * (parseFloat(item.packNumber) || (
+ parseFloat(item.num) - parseFloat(item.returnNum))));
+ }, 0);
+ // 向下取整并保留两位小数
+ let result = roundUpToTwoDecimals(total, 'downward')
+ console.log(result)
+ return result;
+ // return Math.floor(total * 100) / 100;
+ });
+
+ //获取热门商品
+ async function getHotProduct() {
- // Math.ceil(parseFloat(seatNum) * parseFloat(
- // uni.cache.get('ordershopUserInfo').tableFee) * 100) / 100;
}
- // 向下取整并保留两位小数
- let result = roundUpToTwoDecimals(cart, 'downward')
- return result;
- });
- // 计算购物车总打包费用(向下取整并保留两位小数)
- const getTotalPackFee = (cartList) => computed(() => {
- const total = cartList.reduce((sum, item) => {
- return sum + (parseFloat(item.packAmount) * (parseFloat(item.packNumber) || (
- parseFloat(item.num) - parseFloat(item.returnNum))));
- }, 0);
- // 向下取整并保留两位小数
- let result = roundUpToTwoDecimals(total, 'downward')
- console.log(result)
- return result;
- // return Math.floor(total * 100) / 100;
- });
+ //获取分组商品
+ async function getGroupProduct() {
- return {
- getTotalPackFee,
- getTotalSeatcharge,
- getTotalTotalPrices,
- getTotalProductroll
- };
-});
\ No newline at end of file
+ }
+ return {
+ getTotalPackFee,
+ getTotalSeatcharge,
+ getTotalTotalPrices,
+ getTotalProductroll,
+ carts,
+ isEmpty,
+ setGoodsMap
+ };
+ }, {
+ unistorage: true, // 开启后对 state 的数据读写都将持久化
+ },
+);
\ No newline at end of file
diff --git a/stores/pay.js b/stores/pay.js
index b7503da..7c75ce7 100644
--- a/stores/pay.js
+++ b/stores/pay.js
@@ -241,6 +241,8 @@ export const Memberpay = defineStore('memberpay', {
placeNum: data.placeNum, //当前订单下单次数
waitCall: data.waitCall //是否等叫 0 否 1 等叫
})
+ console.log('actionscreateOrder res:');
+ console.log(res);
if (res) {
resolve(res)
} else {
diff --git a/stores/shop.js b/stores/shop.js
new file mode 100644
index 0000000..e69de29
diff --git a/stores/user.js b/stores/user.js
index dbf137d..651562e 100644
--- a/stores/user.js
+++ b/stores/user.js
@@ -9,16 +9,21 @@ import {
APIuser
} from '@/common/api/api.js'
import {
- APIproductqueryShop,
+ APIproductqueryShop,APIusershopInfodetail,
APIshopUserInfo
} from '@/common/api/member.js'
export const Storelogin = defineStore('login', {
state: () => ({
token: '',
miniAppOpenId: '',
- userInfo: ''
+ userInfo: '',
+ shopInfo:{}
}),
actions: {
+ async getShopInfo(shopId){
+ const shopRes=await APIusershopInfodetail({shopId})
+ console.log(shopRes);
+ },
actionslogin() {
return new Promise(async (resolve, reject) => {
// #ifdef MP-WEIXIN
@@ -98,21 +103,26 @@ export const productStore = defineStore('product', {
scanCodeactions(q) {
return new Promise(async (resolve, reject) => {
if (q) {
+ console.log(q)
+ let tableCode =""
// #ifdef MP-WEIXIN
- let tableCode = this.getQueryString(decodeURIComponent(q), 'code')
+ tableCode = this.getQueryString(decodeURIComponent(q), 'code')
// #endif
// #ifdef MP-ALIPAY
- let tableCode = q
+ tableCode = q
// #endif
-
+ // #ifdef H5
+ tableCode= q.tableCode
+ // #endif
+ console.log(tableCode);
// 储存卓玛
uni.cache.set('tableCode', tableCode)
if (tableCode) {
- let data = await this.actionsproductqueryShop()
+ console.log(uni.cache.get('tableCode'));
+ let data = await this.actionsproductqueryShop(tableCode)
// -4请求登录
- const store = Storelogin()
if (data.code == '500') {
- if (await store.actionslogin()) {
+ if (await this.actionslogin()) {
// 成功 接着在调用
await this.actionsproductqueryShop()
}
@@ -166,51 +176,17 @@ export const productStore = defineStore('product', {
});
// #endif
}
- // #ifdef H5
- if (uni.cache.get('tableCode')) {
- let data = await this.actionsproductqueryShop()
- // -4请求登录
- const store = Storelogin()
- if (data.code == '-4') {
- if (await store.actionslogin()) {
- // 成功 接着在调用
- await this.actionsproductqueryShop()
- }
- }
- // idle-空闲 using-使用中 subscribe预定,closed--关台, opening 开台中,cleaning 台桌清理中
- if (uni.cache.get('shopTable').status == 'cleaning' || uni.cache.get(
- 'shopTable').status == 'cleaning') {
- uni.showToast({
- title: '此台桌暂不可用...',
- icon: 'none'
- })
- return false;
- }
-
- if (uni.cache.get('shopInfo').isTableFee == 0) {
- uni.navigateTo({
- url: '/pages/product/choosetable'
- });
- } else {
- uni.reLaunch({
- url: '/pages/product/index'
- });
- // uni.pro.navigateTo('product/index', {
- // tableCode: uni.cache.get('tableCode'),
- // })
- }
-
- }
- // #endif
+
})
},
// /通过桌码获取当前店铺信息
- actionsproductqueryShop() {
+ actionsproductqueryShop(tableCode) {
return new Promise(async (resolve, reject) => {
// try {
+
let res = await APIproductqueryShop({
- tableCode: uni.cache.get('tableCode'),
+ tableCode: tableCode?tableCode:uni.cache.get('tableCode'),
})
res.shopInfo.isVip = res.vip ? '1' : '0'
res.shopTable.shopExtendMap = res.shopExtendMap
diff --git a/uni.scss b/uni.scss
index 0735599..4c32c35 100644
--- a/uni.scss
+++ b/uni.scss
@@ -73,3 +73,5 @@ $uni-color-subtitle: #555555; // 二级标题颜色
$uni-font-size-subtitle:26px;
$uni-color-paragraph: #3F536E; // 文章段落颜色
$uni-font-size-paragraph:15px;
+
+$my-main-color:#E8AD7B;
\ No newline at end of file
diff --git a/utils/quan_util.js b/utils/quan_util.js
new file mode 100644
index 0000000..4aca99f
--- /dev/null
+++ b/utils/quan_util.js
@@ -0,0 +1,264 @@
+export function isTui(item) {
+ return item.status == "return" || item.status == "refund" || item.status == "refunding";
+}
+//是否使用会员价
+export function isUseVipPrice(vipUser, goods) {
+ return vipUser.id && vipUser.isVip;
+}
+
+//计算商品券优惠价格
+export function returnProductCouponPrice(coup, goodsArr, vipUser) {
+ const item = goodsArr.find((v) => v.productId == coup.proId);
+ if (!item) {
+ return 0;
+ }
+ const discountSaleAmount = item.discountSaleAmount * 1;
+ if (discountSaleAmount > 0) {
+ return discountSaleAmount * coup.num;
+ }
+ 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) => {
+ const num = cur.num - cur.refundNum - cur.returnNum;
+ return prve + (num <= 0 ? 0 : num);
+ }, 0);
+ const selCoupNumber = selCoupArr
+ .filter((v) => v.proId == coup.proId)
+ .reduce((prve, cur) => {
+ return prve + cur.num * 1;
+ }, 0);
+ if (selCoupNumber >= findGoodsTotalNumber) {
+ return false;
+ }
+ return findGoodsTotalNumber < 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 discountSaleAmount = item.discountSaleAmount * 1;
+ const memberPrice = item.memberPrice ? item.memberPrice : item.price;
+ let price = item ? (isUseVipPrice(vipUser, item) ? memberPrice : item.price) : 0;
+ price = discountSaleAmount > 0 ? discountSaleAmount : price;
+ const discountAmount = (price * coup.num).toFixed(2);
+ // 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 discountSaleAmount = goods.discountSaleAmount * 1;
+ const memberPrice = goods.memberPrice ? goods.memberPrice : goods.price;
+ const price = isUseVipPrice(vipUser, goods) ? memberPrice : goods.price;
+ if (discountSaleAmount) {
+ return discountSaleAmount;
+ }
+ return price;
+}
+//返回商品券抵扣的商品价格
+export function returnProductCoupAllPrice(productPriceArr, startIndex, num = 1, isVip = true) {
+ num = num || 1;
+ return productPriceArr.slice(startIndex, startIndex + num).reduce((prve, cur) => {
+ let curPrice = 0;
+ if (typeof cur === "object") {
+ if (cur.discountSaleAmount * 1 > 0) {
+ curPrice = cur.discountSaleAmount * 1;
+ } else {
+ curPrice = isVip ? cur.memberPrice * 1 : cur.price;
+ }
+ } else {
+ curPrice = cur * 1;
+ }
+
+ return prve + curPrice;
+ }, 0);
+}
+
+//返回商品券可抵扣的商品数量
+export function returnProductCanUseNum(productPriceArr, startIndex, num) {
+ let n = 0;
+ for (let i = 0; i < num; i++) {
+ if (productPriceArr[startIndex * 1 + i]) {
+ n += 1;
+ } 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 n = cur.num - cur.returnNum;
+ const arr = new Array(n <= 0 ? 0 : n).fill(cur).map((v) => {
+ return {
+ memberPrice: v.memberPrice ? v.memberPrice : v.price,
+ price: v.price,
+ discountSaleAmount: v.discountSaleAmount * 1,
+ };
+ });
+ 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);
+ prve.push(...arr);
+ return prve;
+ }, []);
+ }
+ const proCoupStartIndex = returnProCoupStartIndex(arr, i);
+ const coupNum = Math.min(goodsPayPriceMap[coup.proId].length, coup.num);
+ 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, use: true };
+ }
+ const isfullAmount = payPrice * 1 >= v.fullAmount * 1;
+ if (payPrice <= 0) {
+ return {
+ ...v,
+ use: false,
+ };
+ }
+ return {
+ ...v,
+ use: v.use && isfullAmount,
+ };
+ })
+ .filter((v) => v.use);
+}
+
+//根据商品数量还有商品券数量返回优惠券可以使用的数量数组
+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;
+}
diff --git a/utils/uniapp.js b/utils/uniapp.js
new file mode 100644
index 0000000..4803be2
--- /dev/null
+++ b/utils/uniapp.js
@@ -0,0 +1,16 @@
+export const back=()=>{
+ console.log('back');
+ try {
+ const arr= getCurrentPages()
+ if(arr.length>=2){
+ return uni.navigateBack()
+ }else{
+ uni.reLaunch({
+ url:'/pages/index/index'
+ })
+ }
+ } catch (error) {
+ console.error('页面返回出错',error)
+ //TODO handle the exception
+ }
+}
\ No newline at end of file
diff --git a/vite.config.js b/vite.config.js
index c04048e..cf024ff 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -9,7 +9,7 @@ export default defineConfig({
hmr: true,
proxy: {
'/api': {
- target: 'https://tapi.cashier.sxczgkj.cn',
+ target: 'http://192.168.1.31',
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, ''),
secure: false