云函数:
const result = await cloud.openapi.logistics.addOrder({ // openapi.
openid: wxContext.OPENID, //用户openid
addSource: event.addSource, //订单来源0为小程序
orderId: event.orderId,//订单ID
deliveryId: event.deliveryId, //快递公司ID
bizId: event.bizId, //快递客户编码
customRemark:event.customRemark, //备注信息
"sender": {
"name": event.name, //发件人姓名
"tel": event.tel, //固话
"mobile": event.mobile,//手机号
"company": event.company,//公司名
"country":event.country,//国家
"province": event.province,//省份
"city":event.city, //城市
"area": event.area, //区
"address": event.address,//详细地址
"postCode": event.postCode//区号
},
"receiver": {
"name": event.name, //收件人姓名
"tel": event.tel, //固话
"mobile": event.mobile,//手机号
"company": event.company,//公司名
"country": event.country,//国家
"province": event.province,//省份
"city":event.city, //城市
"area": event.area, //区
"address": event.address,//详细地址
"postCode": event.postCode//区号
},
"shop": {
"wxaPath": event.wxaPath,
"imgUrl": event.imgUrl,
"goodsName": event.goodsName,
"goodsCount": event.goodsCount,
},
"cargo": {
"count": event.count,
"weight":event.weight,
"spaceX": event.spaceX,
"spaceY": event.spaceY,
"spaceZ": event.spaceZ,
"detailList": [
{
"name": event.name,
"count": event.count
},
{
"name": event. name,
"count": event.count
}
]
},
"insured": {
"useInsured":event.useInsured,
"insuredValue": event.insuredValue,
},
"service": {
"serviceType": event.serviceType,
"serviceName": event.serviceName
},
})
return result
}
catch(err){
return err
}
小程序:
data:{
addSource: 0,
orderId: that.data.timeStamp, //订单id that.data.timeStamp
deliveryId: "TEST", //快递公司id:"SF",沙盒测试(TEST)
bizId: "test_biz_id", // 快递客户编码,沙盒测试(test_biz_id)
customRemark: "易碎物品",
"sender":{
"name":"张三", //发件人信息
"tel": "020-88888888",
"mobile": "13074754578",
"company": "公司名",
"postCode": "123456",
"country": "中国",
"province": "广东省",
"city": "广州市",
"area": "海珠区",
"address": "XX路XX号XX大厦XX栋XX"
},
"receiver": {
"name": that.data.receiver.name, //收货人详细信息
"tel": that.data.receiver.tel,
"mobile": that.data.receiver.mobile,
"company": that.data.receiver.company,
"postCode": that.data.receiver.postCode,
"country": that.data.receiver.country,
"province": that.data.receiver.province,
"area": that.data.receiver.area,
"address": that.data.receiver.address
},
"shop": {
"wxaPath":"/pages/OrderPage/OrderPage?id="+that.data.timeStamp, //订单详情页
"imgUrl":"cloud://xcx-16888-2go48vd360242d28.7863-xcx-16888-2go48vd360242d28-1304305727/1608343196467.jpeg",
//"https://7863-xcx-16888-2go48vd360242d28-1304305727.tcb.qcloud.la/1608343196467.jpeg?sign=830e6dcd2ff8b3fee27c7d301fa49e6e&t=1615460661", //that.data.product[0].src[0],
"goodsName":"微信气泡狗抱枕&微信气泡狗钥匙扣",
"goodsCount":2 , //这个订单几件货物
},
" cargo": {
"count": 2,
"weight": 5.5, //需要计算物品体积
"spaceX": 30.5,
"spaceY": 20,
"spaceZ": 20,
"detailList": [
{
"name": "微信气泡狗抱枕",
"count": 1
},
{
"name": "微信气泡狗钥匙扣",
"count": 1
}
] },
"insured": {
"useInsured": 1,
"insuredValue": 10000 },
"service": {
"serviceType":1, //0,
"serviceName":"test_service_name" //"标准快递"(沙盒测试)
}
},
- result: {errCode: 9300535, errMsg: "openapi.logistics.addOrder:fail invalid shop args rid: 604b0674-3e08c0c7-7cc83734"}
- __proto__: Object