生活服务小程序,使用 plugin.createOrder 下单报错:
115 浏览2026年04月26日作者:dengshui
plugin.createOrder({
    goodsList: [
        {
            goodsId: "234234",
            // 购买数量
            quantity: 1,
            // 商品价格
            price: 20,
            //商品名称
            goodsName: "234234",
            // 商品图片
            goodsPhoto: "https://example.com/image.jpg",
            // 商品是否入库 1:商品库商品  2:非商品库商品
            goodsType: 1,

        }
    ],
    payment: {
        // 订单总价
        totalAmount: 22,
        //  订单总折扣
        totalDiscountAmount: 0,
        //  费用明细列表
        feeDetailsList: [{
            // 费用类型 1: 配送费 2: 包装费 18:基建费 19:燃油费 20:税费 22:预约加价费(仅预约品支持使用)
            feeType: 1,
            // 费用总金额
            feeAmount: 10,
            // 费用总优惠金额
            feeDiscountAmount: 20,
            // 费用描述
            feeDesc: "234234"
        }],
        // 可选值 alipay wx dy
        limitPay: ["alipay", "wx"],
    },
    // // 外卖
    businessLine: 3,
    contactInfo: {
        phoneNumber: "12345678901", // 手机号 非必传
        contactName: "test name", // 姓名 非必传
        gender: 1,
    },
    // 配送信息
    deliveryInfo: {
        // 门店的poiId
        poiId: "234234",
        // 订单类型 1: 实时单 2: 预约单
        bookType: 1,
        // 配送类型 1: 同城配送 2: 到店自提
        deliveryType: 1,
        //  收货信息
        receiptInfo: {
            // 预计收货开始时间(ms),13位毫秒时间戳
            startTime: 1776430965000,
            // 预计收货结束时间(ms),13位毫秒时间戳
            endTime: 1777175374000
        },
    },
    // 地址信息
    addressInfo: {
        // 地理位置信息
        locationInfo: {
            // 省编码
            provinceCode: "234234",
            // 省名称
            provinceName: "234234",
            // 市编码
            cityCode: "234234",
            // 市名称
            cityName: "234234",
            // 区编码
            districtCode: "234234",
            // 区名称
            districtName: "234234",
            // 街道/镇编码
            townCode: "234234",
            // 街道/镇名称
            townName: "234234",
            // 具体位置地址
            locationAddress: "234234"

        },
        // 门牌号
        doorNumber: "234234"
    },
    success: (res) => {
        const {orderId, outOrderNo} = res;
        console.log("success res", res);
        console.log("orderId", orderId, "outOrderNo", outOrderNo);
        this.setData({orderId, outOrderNo});
    },
    fail: (res) => {
        tt.showToast({
            title: JSON.stringify(res),
        })
        const {orderId, outOrderNo, errNo, errMsg, errLogId} = res;
        if (errLogId) {
            console.log("预下单失败", errNo, errMsg, errLogId);
        }
        if (orderId || outOrderNo) {
            this.setData({orderId, outOrderNo});
            console.log("支付失败", errNo, errMsg, orderId, outOrderNo);
        }
        console.log(errNo, errMsg);
    },
})


在测试 plugin.createOrder 时,模拟器中调试会报错:预下单失败 21517 createOrder:fail data should be object, but got ""
最后一次编辑于 2026 年 04 月 26 日
共 2 条评论

相关问答

专题推荐

热门文章

热门问答