bindDevice static method

Future<String> bindDevice(
  1. String userId,
  2. String barcode, {
  3. String? barcodeType,
})

APP扫码绑定设备 userId app用户id barcode 二维码内容 barcodeType 1或者不传表示扫码绑定设备;2表示输入设备码(即序列号)绑定设备

Implementation

static Future<String> bindDevice(String userId,String barcode,{String? barcodeType}) async {
  Map<String,String> headers = {
    'tenantId': '10002',
    'token': SpUtil().getString(SpUtil.SP_KEY_ACCESS_TOKEN) ?? '',
    'appSource': 'Maxims',
    'reqSource': '1',
  };
  int timestamp = DateTime.now().millisecondsSinceEpoch;

  Map<String,dynamic> params = {
    'userId': userId,
    'barcode': barcode,
    'barcodeType': barcodeType,
    'timestamp': timestamp,
    'appKey': BaseHttpConstant.APP_BIND_SERVER_KEY,
  };
  String sign = CipherUtil.generateSignature2(params, barcodeType == null ? ["barcodeType"] : [], BaseHttpConstant.APP_BIND_SERVER_SECRET);
  params['sign'] = sign;
  Options options = Options(
    headers: headers,
    contentType: Headers.multipartFormDataContentType,
  );
  var result = await HttpUtils.post(true, Api.PATH_DEVICE_BIND,
      data: FormData.fromMap(params),
      options: options);
  return formatResponse(result);
}