文档中心 > 智能硬件

贩卖机/派样机api

更新时间:2018/09/13 访问次数:1968

所有贩卖机/派样机api均收敛到vendor域下

vendor

Arguments

所有API的入参如果没有特殊说明,均为必选参数

Returns

所有API均返回Promise。返回数据通过thensuccessCallback返回;错误通过thenfailCallback返回。
注:以下API的Data章节描述的是successCallback返回的数据

cancelPayByQRCode

取消扫码支付轮询。通常在关闭扫码界面时调用

Arguments

Data

Example

Tida.rop.call('vendor.cancelPayByQRCode').then(function () {
  console.log('call vendor.cancelPayByQRCode success');
}, function (err) {
  console.log(err);
});

getItemList

获取商品列表

Arguments

Data

{
  "items": [{ // 商品列表
    "title": string // 商品名称
    "url": string // 商品图片URL
    "id": string // 商品ID
    "price": string // 商品价格
    "memberPrice": string // 会员价
    "promotionPrice": string // 特别价
    "promotionTag": string // 特别价名称
    "storeName": string // 商品关联店铺名称
    "storeIcon": string // 商品关联店铺图片URL,
    "remain": string // 剩余库存
  }]
}

Example

Tida.rop.call('vendor.getItemList').then(function (data) {
  console.log(data);
  // console output:
  // {
  //   "items": [
  //     {
  //       "title": "兰蔻菁纯柔润丝缎唇膏口红",
  //       "url": "https://img.alicdn.com/bao/uploaded/i1/2360209412/TB1x8eskHSYBuNjSspfXXcZCpXa_!!0-item_pic.jpg_240x240.jpg",
  //       "id": "12313123210",
  //       "price": "270.00",
  //       "memberPrice": "250.50",
  //       "promotionPrice": "0.01",
  //       "promotionTag": "体验价",
  //       "storeName": "天猫大家庭",
  //       "storeIcon": "https://gw.alicdn.com/tfs/TB19EAZmL1TBuNjy0FjXXajyXXa-126-126.png",
  //       "remain": "10",
  //       "channels": [
  //         {
  //           "channel": "11",
  //           "remain": "0"
  //         },
  //         {
  //           "channel": "12",
  //           "remain": "3"
  //         },
  //         {
  //           "channel": "13",
  //           "remain": "7"
  //         }
  //       ]
  //     },
  //     ...
  //   ]
  // }
}, function (err) {
  console.log(err);
});

manage

打开设备管理页面

Arguments

Data

Example

Tida.rop.call('vendor.manage');

payByFace

人脸支付。用户成功识别并确认支付后,会自动跳转到官方的确认支付页。
启动过程会比较长(1~2s)建议增加加载过渡效果

Arguments

  1. itemId: 商品ID
  2. theme: 确认支付页的主题色,目前可选值为:red(默认), gray, dark

Data

如果用户确认支付,则调用成功回调并返回true;
如果用户取消,则调用成功回调并返回undefined;
如果库存不足或其他错误,则会调用失败回调并返回Error对象

Example

Tida.rop.call('vendor.payByFace', {
  itemId: '12313123210',
  theme: 'red'
}).then(function (data) {
  console.log(data);
  // console output
  // true
}, function (err) {
  console.log(err);
});

payByQRCode

创建支付二维码并轮询。在轮询时,会检查用户的支付状态。用户扫码支付时,会跳转到官方的支付结果页完成下单并出货。
创建的二维码会挂载到container对应的DOM节点上;
如果关闭了二维码的展示,建议调用cancelPayByQRCode()关闭轮询

Arguments

  1. itemId: 商品ID
  2. container: 用来承载二维码图片的DOM节点,生成的二维码图片大小会拉伸到该DOM节点的宽度
  3. qrCodeOption: 二维码图片选项
  4. width: 图片清晰度,通常默认值即可
  5. margin: 二维码的边界留白宽度(单位:px),默认值为4;
  6. theme: 确认支付页的主题色,目前可选值为:red(默认), gray, dark
  7. mockDuration: (仅debug模式下有效)设置debug模式下,页面的跳转延时。0表示不跳转

Data

Example

Tida.rop.call('vendor.payByQRCode', {
  itemId: '12313123210',
  container: document.getElementById('qr-code-container'),
  qrCodeOption: {
    margin: 2,
  },
  theme: 'red'
}).then(function () {
  console.log('call vendor.payByQRCode success');
}, function (err) {
  console.log(err);
});

FAQ

关于此文档暂时还没有FAQ
返回
顶部