123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const sheep_index = require("../../sheep/index.js");
- const sheep_api_trade_order = require("../../sheep/api/trade/order.js");
- const sheep_api_promotion_coupon = require("../../sheep/api/promotion/coupon.js");
- const sheep_hooks_useGoods = require("../../sheep/hooks/useGoods.js");
- require("../../sheep/url/index.js");
- require("../../sheep/store/index.js");
- require("../../sheep/store/app.js");
- require("../../sheep/api/promotion/diy.js");
- require("../../sheep/request/index.js");
- require("../../sheep/config/index.js");
- require("../../sheep/platform/index.js");
- require("../../sheep/platform/provider/wechat/index.js");
- require("../../sheep/platform/provider/wechat/miniProgram.js");
- require("../../sheep/api/member/auth.js");
- require("../../sheep/api/member/social.js");
- require("../../sheep/api/member/user.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/api/pay/order.js");
- require("../../sheep/store/user.js");
- require("../../sheep/store/cart.js");
- require("../../sheep/api/trade/cart.js");
- require("../../sheep/api/pay/wallet.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_coupon_select2 = common_vendor.resolveComponent("s-coupon-select");
- const _easycom_s_discount_list2 = common_vendor.resolveComponent("s-discount-list");
- 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_coupon_select2 + _easycom_s_discount_list2 + _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_coupon_select = () => "../../sheep/components/s-coupon-select/s-coupon-select.js";
- const _easycom_s_discount_list = () => "../../sheep/components/s-discount-list/s-discount-list.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_coupon_select + _easycom_s_discount_list + _easycom_su_fixed + _easycom_s_layout)();
- }
- const _sfc_main = {
- __name: "confirm",
- setup(__props) {
- const state = common_vendor.reactive({
- orderPayload: {},
- orderInfo: {
- items: [],
- // 商品项列表
- price: {}
- // 价格信息
- },
- addressInfo: {},
- // 选择的收货地址
- showCoupon: false,
- // 是否展示优惠劵
- couponInfo: [],
- // 优惠劵列表
- showDiscount: false
- // 是否展示营销活动
- });
- function onSelectAddress() {
- common_vendor.index.$once("SELECT_ADDRESS", (e) => {
- changeConsignee(e.addressInfo);
- });
- sheep_index.sheep.$router.go("/pages/user/address/list");
- }
- async function changeConsignee(addressInfo = {}) {
- if (!common_vendor.lodashExports.isEmpty(addressInfo)) {
- state.addressInfo = addressInfo;
- }
- await getOrderInfo();
- }
- async function onSelectCoupon(couponId) {
- state.orderPayload.couponId = couponId || 0;
- await getOrderInfo();
- state.showCoupon = false;
- }
- function onConfirm() {
- if (!state.addressInfo.id) {
- sheep_index.sheep.$helper.toast("请选择收货地址");
- return;
- }
- submitOrder();
- }
- async function submitOrder() {
- const { code, data } = await sheep_api_trade_order.OrderApi.createOrder({
- items: state.orderPayload.items,
- couponId: state.orderPayload.couponId,
- addressId: state.addressInfo.id,
- deliveryType: 1,
- // TODO 芋艿:需要支持【门店自提】
- pointStatus: false,
- // TODO 芋艿:需要支持【积分选择】
- combinationActivityId: state.orderPayload.combinationActivityId,
- combinationHeadId: state.orderPayload.combinationHeadId,
- seckillActivityId: state.orderPayload.seckillActivityId
- });
- 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 { data, code } = await sheep_api_trade_order.OrderApi.settlementOrder({
- items: state.orderPayload.items,
- couponId: state.orderPayload.couponId,
- addressId: state.addressInfo.id,
- deliveryType: 1,
- // TODO 芋艿:需要支持【门店自提】
- pointStatus: false,
- // TODO 芋艿:需要支持【积分选择】
- combinationActivityId: state.orderPayload.combinationActivityId,
- combinationHeadId: state.orderPayload.combinationHeadId,
- seckillActivityId: state.orderPayload.seckillActivityId
- });
- if (code !== 0) {
- return;
- }
- state.orderInfo = data;
- if (state.orderInfo.address) {
- state.addressInfo = state.orderInfo.address;
- }
- }
- async function getCoupons() {
- const { code, data } = await sheep_api_promotion_coupon.CouponApi.getMatchCouponList(
- state.orderInfo.price.payPrice,
- state.orderInfo.items.map((item) => item.spuId),
- state.orderPayload.items.map((item) => item.skuId),
- state.orderPayload.items.map((item) => item.categoryId)
- );
- if (code === 0) {
- state.couponInfo = data;
- }
- }
- common_vendor.onLoad(async (options) => {
- if (!options.data) {
- sheep_index.sheep.$helper.toast("参数不正确,请检查!");
- return;
- }
- state.orderPayload = JSON.parse(options.data);
- await getOrderInfo();
- await getCoupons();
- });
- return (_ctx, _cache) => {
- return common_vendor.e({
- a: common_vendor.p({
- item: state.addressInfo,
- hasBorderBottom: false
- }),
- b: common_vendor.o(onSelectAddress),
- c: common_vendor.f(state.orderInfo.items, (item, k0, i0) => {
- return {
- a: item.skuId,
- b: "324e7894-2-" + i0 + ",324e7894-0",
- c: common_vendor.p({
- img: item.picUrl,
- title: item.spuName,
- skuText: item.properties.map((property) => property.valueName).join(" "),
- price: item.price,
- num: item.count,
- marginBottom: "10"
- })
- };
- }),
- d: common_vendor.o(($event) => state.orderPayload.remark = $event),
- e: common_vendor.p({
- maxlength: "20",
- placeholder: "建议留言前先与商家沟通",
- inputBorder: false,
- clearable: false,
- modelValue: state.orderPayload.remark
- }),
- f: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.price.totalPrice)),
- g: state.orderPayload.order_type === "score"
- }, state.orderPayload.order_type === "score" ? {
- h: common_vendor.unref(sheep_index.sheep).$url.static("/static/img/shop/goods/score1.svg"),
- i: common_vendor.t(state.orderInfo.score_amount)
- } : {}, {
- j: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.price.deliveryPrice)),
- k: state.orderInfo.type === 0
- }, state.orderInfo.type === 0 ? common_vendor.e({
- l: state.orderPayload.couponId > 0
- }, state.orderPayload.couponId > 0 ? {
- m: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.price.couponPrice))
- } : {
- n: common_vendor.t(state.couponInfo.length > 0 ? state.couponInfo.length + " 张可用" : "暂无可用优惠券"),
- o: common_vendor.n(state.couponInfo.length > 0 ? "text-red" : "text-disabled")
- }, {
- p: common_vendor.o(($event) => state.showCoupon = true)
- }) : {}, {
- q: state.orderInfo.price.discountPrice > 0
- }, state.orderInfo.price.discountPrice > 0 ? {
- r: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.price.discountPrice))
- } : {}, {
- s: common_vendor.t(state.orderInfo.items.reduce((acc, item) => acc + item.count, 0)),
- t: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.price.payPrice)),
- v: common_vendor.o(onSelectCoupon),
- w: common_vendor.o(($event) => state.showCoupon = false),
- x: common_vendor.o(($event) => state.couponInfo = $event),
- y: common_vendor.p({
- show: state.showCoupon,
- modelValue: state.couponInfo
- }),
- z: common_vendor.o(($event) => state.showDiscount = false),
- A: common_vendor.o(($event) => state.orderInfo = $event),
- B: common_vendor.p({
- show: state.showDiscount,
- modelValue: state.orderInfo
- }),
- C: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.price.payPrice)),
- D: common_vendor.o(onConfirm),
- E: common_vendor.p({
- bottom: true,
- opacity: false,
- bg: "bg-white",
- placeholder: true,
- noFixed: false,
- index: 200
- }),
- F: common_vendor.p({
- title: "确认订单"
- })
- });
- };
- }
- };
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-324e7894"], ["__file", "/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-app/pages/order/confirm.vue"]]);
- wx.createPage(MiniProgramPage);
|