"use strict"; const common_vendor = require("../../common/vendor.js"); const common_assets = require("../../common/assets.js"); const sheep_index = require("../../sheep/index.js"); const sheep_api_trade_order = require("../../sheep/api/trade/order.js"); require("../../sheep/request/index.js"); const sheep_hooks_useGoods = require("../../sheep/hooks/useGoods.js"); require("../../sheep/api/index.js"); require("../../sheep/api/distri/score.js"); require("../../sheep/api/distri/share.js"); require("../../sheep/api/distri/team.js"); require("../../sheep/api/infra/file.js"); require("../../sheep/config/index.js"); require("../../sheep/api/member/address.js"); require("../../sheep/api/member/auth.js"); require("../../sheep/api/member/point.js"); require("../../sheep/api/member/signin.js"); require("../../sheep/api/member/social.js"); require("../../sheep/api/member/user.js"); require("../../sheep/api/migration/app.js"); require("../../sheep/api/migration/chat.js"); require("../../sheep/api/migration/index.js"); require("../../sheep/api/migration/third.js"); require("../../sheep/api/pay/channel.js"); require("../../sheep/api/pay/order.js"); require("../../sheep/api/pay/wallet.js"); require("../../sheep/api/product/category.js"); require("../../sheep/api/product/comment.js"); require("../../sheep/api/product/favorite.js"); require("../../sheep/api/product/history.js"); require("../../sheep/api/product/spu.js"); require("../../sheep/api/promotion/activity.js"); require("../../sheep/api/promotion/article.js"); require("../../sheep/api/promotion/bargain.js"); require("../../sheep/api/promotion/combination.js"); require("../../sheep/api/promotion/coupon.js"); require("../../sheep/api/promotion/diy.js"); require("../../sheep/api/promotion/rewardActivity.js"); require("../../sheep/api/promotion/seckill.js"); require("../../sheep/api/system/area.js"); require("../../sheep/api/system/voice.js"); require("../../sheep/api/trade/afterSale.js"); require("../../sheep/api/trade/brokerage.js"); require("../../sheep/api/trade/cart.js"); require("../../sheep/api/trade/config.js"); require("../../sheep/api/trade/delivery.js"); require("../../sheep/url/index.js"); require("../../sheep/store/index.js"); require("../../sheep/store/app.js"); require("../../sheep/platform/index.js"); require("../../sheep/platform/provider/wechat/index.js"); require("../../sheep/platform/provider/wechat/miniProgram.js"); require("../../sheep/platform/provider/apple/index.js"); require("../../sheep/platform/share.js"); require("../../sheep/router/index.js"); require("../../sheep/hooks/useModal.js"); require("../../sheep/helper/index.js"); require("../../sheep/helper/test.js"); require("../../sheep/helper/digit.js"); require("../../sheep/helper/throttle.js"); require("../../sheep/platform/pay.js"); require("../../sheep/store/user.js"); require("../../sheep/store/cart.js"); require("../../sheep/store/sys.js"); require("../../sheep/store/modal.js"); require("../../sheep/config/zIndex.js"); require("../../sheep/util/index.js"); if (!Array) { const _easycom_s_address_item2 = common_vendor.resolveComponent("s-address-item"); const _easycom_s_goods_item2 = common_vendor.resolveComponent("s-goods-item"); const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput"); const _easycom_s_points_pop2 = common_vendor.resolveComponent("s-points-pop"); const _easycom_su_fixed2 = common_vendor.resolveComponent("su-fixed"); const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout"); (_easycom_s_address_item2 + _easycom_s_goods_item2 + _easycom_uni_easyinput2 + _easycom_s_points_pop2 + _easycom_su_fixed2 + _easycom_s_layout2)(); } const _easycom_s_address_item = () => "../../sheep/components/s-address-item/s-address-item.js"; const _easycom_s_goods_item = () => "../../sheep/components/s-goods-item/s-goods-item.js"; const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js"; const _easycom_s_points_pop = () => "../../sheep/components/s-points-pop/s-points-pop.js"; const _easycom_su_fixed = () => "../../sheep/ui/su-fixed/su-fixed.js"; const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js"; if (!Math) { (_easycom_s_address_item + _easycom_s_goods_item + _easycom_uni_easyinput + _easycom_s_points_pop + _easycom_su_fixed + _easycom_s_layout)(); } const _sfc_main = { __name: "confirm", setup(__props) { const state = common_vendor.reactive({ orderPayload: {}, orderInfo: { items: [], // 商品项列表 price: {} // 价格信息 }, addressInfo: {}, // 选择的收货地址 showPoints: false, // 是否积分抵扣 couponInfo: [], // 优惠劵列表 showDiscount: false, // 是否展示营销活动 currentMemberPoints: 0, //用户当前可用积分 usedPoint: 0, //用户使用的积分 currentTotalPrice: 0, //当前的整个订单的总价格 currentDeliveryPrice: 0 // 当前订单的总运费 }); const shopsByNames = common_vendor.computed(() => { const shops = {}; try { Object.keys(state.orderInfo.shopRespVOMap).forEach((shopId) => { const shopName = state.orderInfo.shopNameMap[shopId]; if (shopName) { shops[shopName] = state.orderInfo.shopRespVOMap[shopId]; shops[shopName].remark = ""; shops[shopName].shopId = shopId; } }); } catch (e) { } return shops; }); const totalItemCount = common_vendor.computed(() => { let totalCount = 0; Object.values(shopsByNames.value).forEach((shop) => { shop.items.forEach((item) => { totalCount += item.count; }); }); return totalCount; }); function onSelectAddress() { common_vendor.index.$once("SELECT_ADDRESS", (e) => { changeConsignee(e.addressInfo); }); console.log(state.orderPayload.spuType); if (state.orderPayload.spuType) { sheep_index.sheep.$router.go("/pages/user/address/list"); } else { sheep_index.sheep.$router.go("/pages/user/dummyAddress/list"); } } async function changeConsignee(addressInfo = {}) { if (!common_vendor.lodashExports.isEmpty(addressInfo)) { state.addressInfo = addressInfo; } await getOrderInfo(); } async function onInputPoints(points) { if (points == void 0) { points = 0; } const payprice = state.currentTotalPrice; state.orderInfo.price.payPrice = (payprice - points) * 100; state.usedPoint = points; state.showPoints = false; } function onConfirm() { if (!state.addressInfo.id) { sheep_index.sheep.$helper.toast("请选择收货地址"); return; } if (state.usedPoint > state.currentMemberPoints) { sheep_index.sheep.$helper.toast("可用积分不足"); return; } submitOrder(); } function customRound(number, decimals) { let factor = Math.pow(10, decimals); let tempNumber = Math.floor(number * factor) / factor; return tempNumber.toFixed(decimals); } async function submitOrder() { const shops = shopsByNames.value; const shopRemarks = {}; Object.keys(shops).forEach((shopName) => { const shop = shops[shopName]; shopRemarks[shop.shopId] = shop.remark; }); const usedPoint = state.orderPayload.highPrecision ? customRound(state.orderInfo.price.virtualPayPrice / 100, 2) : state.usedPoint; const { code, data } = await sheep_api_trade_order.OrderApi.createOrder({ items: state.orderPayload.items, couponId: state.orderPayload.couponId, addressId: state.addressInfo.id, deliveryType: state.orderPayload.spuType == 1 ? 1 : 3, // TODO 非繁人:需要支持【门店自提】 pointStatus: false, // TODO 非繁人:需要支持【积分选择】 combinationActivityId: state.orderPayload.combinationActivityId, combinationHeadId: state.orderPayload.combinationHeadId, seckillActivityId: state.orderPayload.seckillActivityId, payIntegral: usedPoint, // payIntegral: 0.95, shopRemarks }); if (code !== 0) { return; } if (state.orderPayload.items[0].cartId > 0) { sheep_index.sheep.$store("cart").getList(); } sheep_index.sheep.$router.redirect("/pages/pay/index", { id: data.payOrderId }); } async function getOrderInfo() { const shops = shopsByNames.value; let shopRemarks = {}; if (Object.keys(shops).length !== 0) { Object.keys(shops).forEach((shopName) => { const shop = shops[shopName]; shopRemarks[shopName] = shop.remark; }); } const { data, code } = await sheep_api_trade_order.OrderApi.settlementOrder({ items: state.orderPayload.items, couponId: state.orderPayload.couponId, addressId: state.addressInfo.id, deliveryType: state.orderPayload.spuType == 1 ? 1 : 3, // TODO 非繁人:需要支持【门店自提】 pointStatus: false, // TODO 非繁人:需要支持【积分选择】 combinationActivityId: state.orderPayload.combinationActivityId, combinationHeadId: state.orderPayload.combinationHeadId, seckillActivityId: state.orderPayload.seckillActivityId, usedPoint: state.usedPoint, addressType: state.orderPayload.spuType == 1 ? 1 : 2 //如果是虚拟产品 }); if (code !== 0) { return; } state.orderInfo = data; if (Object.keys(shopRemarks).length !== 0) { Object.keys(shopRemarks).forEach((shopName) => { shopsByNames.value[shopName].remark = shopRemarks[shopName]; }); } if (state.orderInfo.address) { state.addressInfo = state.orderInfo.address; } state.currentMemberPoints = sheep_hooks_useGoods.points2point(state.orderInfo.currentQuota); state.currentTotalPrice = sheep_hooks_useGoods.fen2yuan(state.orderInfo.price.payPrice); state.currentDeliveryPrice = sheep_hooks_useGoods.fen2yuan(state.orderInfo.price.deliveryPrice); if (state.orderPayload.spuPayType == 2) { state.usedPoint = state.currentTotalPrice - 0.01; console.log(state.spuType); } } common_vendor.onLoad(async (options) => { if (!options.data) { sheep_index.sheep.$helper.toast("参数不正确,请检查!"); return; } state.orderPayload = JSON.parse(options.data); console.log(state.orderPayload); await getOrderInfo(); }); return (_ctx, _cache) => { return common_vendor.e({ a: common_vendor.p({ item: state.addressInfo, spuType: state.orderPayload.spuType, hasBorderBottom: false }), b: common_vendor.o(onSelectAddress), c: common_vendor.f(shopsByNames.value, (items, name, i0) => { return common_vendor.e({ a: common_vendor.t(name), b: common_vendor.f(items.items, (item, k1, i1) => { var _a; return { a: item == null ? void 0 : item.skuId, b: "324e7894-2-" + i0 + "-" + i1 + ",324e7894-0", c: common_vendor.p({ img: item == null ? void 0 : item.picUrl, title: item == null ? void 0 : item.spuName, skuText: (_a = item == null ? void 0 : item.properties) == null ? void 0 : _a.map((property) => property.valueName).join(" "), price: item.highPrecisionPrice ? item == null ? void 0 : item.highPrecisionPrice : item == null ? void 0 : item.price, num: item == null ? void 0 : item.count, virtualPirce: item.highPrecisionPrice ? true : false }) }; }), c: common_vendor.t(items.price.deliveryPrice ? "¥" + common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(items.price.deliveryPrice) : "包邮"), d: "324e7894-3-" + i0 + ",324e7894-0", e: common_vendor.o(($event) => items.remark = $event, name), f: common_vendor.p({ maxlength: "20", placeholder: "建议留言前先与商家沟通", inputBorder: false, clearable: false, modelValue: items.remark }) }, state.orderPayload.spuType == 0 ? { g: common_vendor.t(totalItemCount.value) } : common_vendor.e({ h: state.orderPayload.spuPayType == 2 }, state.orderPayload.spuPayType == 2 ? { i: common_assets._imports_0 } : {}, { j: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(items.price.payPrice)) }), { k: name }); }), d: state.orderPayload.spuType == 0, e: common_vendor.t(totalItemCount.value), f: state.orderPayload.spuPayType == 2 }, state.orderPayload.spuPayType == 2 ? { g: common_assets._imports_0 } : {}, { h: state.orderPayload.highPrecision }, state.orderPayload.highPrecision ? { i: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan6)(state.orderInfo.price.virtualTotalPrice)) } : { j: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.price.totalPrice)) }, { k: state.orderPayload.spuPayType == 2 }, state.orderPayload.spuPayType == 2 ? { l: common_assets._imports_0 } : {}, { m: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.price.deliveryPrice)), n: state.orderPayload.spuPayType != 2 }, state.orderPayload.spuPayType != 2 ? { o: common_vendor.t(state.usedPoint > 0 ? " 可抵扣" + state.usedPoint + "元" : "不使用积分"), p: common_vendor.n(state.usedPoint > 0 ? "text-red" : "text-disabled"), q: common_vendor.o(($event) => state.showPoints = true) } : {}, { r: common_vendor.t(totalItemCount.value), s: state.orderPayload.spuPayType == 2 }, state.orderPayload.spuPayType == 2 ? { t: common_assets._imports_0 } : {}, { v: state.orderPayload.highPrecision }, state.orderPayload.highPrecision ? { w: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan6)(state.orderInfo.price.virtualTotalPrice)) } : state.orderPayload.spuPayType == 2 ? { y: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.price.payPrice) - 0.01) } : { z: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.price.payPrice)) }, { x: state.orderPayload.spuPayType == 2, A: common_vendor.o(onInputPoints), B: common_vendor.o(($event) => state.showPoints = false), C: common_vendor.o(($event) => state.couponInfo = $event), D: common_vendor.p({ currentMemberPoints: state.currentMemberPoints, currentTotalPrice: state.currentTotalPrice, currentDeliveryPrice: state.currentDeliveryPrice, show: state.showPoints, modelValue: state.couponInfo }), E: state.orderPayload.highPrecision }, state.orderPayload.highPrecision ? common_vendor.e({ F: state.orderPayload.spuPayType == 2 }, state.orderPayload.spuPayType == 2 ? { G: common_assets._imports_0 } : {}, { H: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan6)(state.orderInfo.price.virtualPayPrice) - 0.01) }) : state.orderPayload.spuPayType == 2 ? common_vendor.e({ J: state.orderPayload.spuPayType == 2 }, state.orderPayload.spuPayType == 2 ? { K: common_assets._imports_0 } : {}, { L: common_vendor.t(state.usedPoint) }) : { M: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.price.payPrice)) }, { I: state.orderPayload.spuPayType == 2, N: common_vendor.o(onConfirm), O: common_vendor.p({ bottom: true, opacity: false, bg: "bg-white", placeholder: true, noFixed: false, index: 200 }), P: common_vendor.p({ title: "确认订单" }) }); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-324e7894"], ["__file", "D:/zx/mall-front-app/pages/order/confirm.vue"]]); wx.createPage(MiniProgramPage);