1.Overview
Third-party program plug-in to provide Bluetooth lock door service, users in accordance with the requirements of ginseng, to achieve Bluetooth unlock
2.Parameter Description
Small program developers call plug-in for Bluetooth lock door, use the method see the program official APIwidget Guide
QR Keymini programapp-id:wxbe18a842c8d14445
3.Parameter Description
Required parameters Explanation
accountSid The Account SID for the Lock Cabinet Developer Account
token The Auth Token for the Lock Cabinet Developer Account
mobile Mobile
communityNo QR Master community
cardNo Please refer to Generate cards
areaCode Mobile phone area code
4.Sample
4.1 Add plug-ins in the background of small program management
Small program developers can find the required plug-ins based on the AppID and request to use them in ‘Small Program Management Back-Settings-Third-Party Service-Plug-in Management’.
After the plug-in developer passes within 24 hours, the small program developer can use the plug-in within the small program
4.2 To use a plug-in in a small program code that must declare the plug-in you need in app.json's plugins, please refer to the following code:
<!--app.json-->
{
  "plugins": {
    "yaoshibang": {
      "version": "1.0.4",
      "provider": "wxbe18a842c8d14445"
    }
  }
}
4.3 Use the plug-in in the wxml file on the target page, or customize the component style (so you don't have to copy the code in wxss)
<!--index.wxml-->
<button bindtap="openapi" class="yaoshibang">调用api</button>
<!--index.wxss-->
.yaoshibang{
    width:80%;
    border-radius: 15rpx;
    margin-top: 100rpx;
    background-color: #1B82D2;
    color:#fff;
    font-size: 40rpx;
    height: 100rpx;
    line-height: 100rpx;
}
4.4 In the js of the target page, the plug-in can be obtained using the plug-in interface, the full call api example is as follows:
<!--index.js-->
<!--Add the first of the js file of the called component-->
let yaoshibang = requirePlugin("yaoshibang");
<!--Add this segment to the onShow function of the js file of the called component to turn off The Code for Bluetooth-->
wx.closeBLEConnection({
  deviceId: [],
  complete(res) {
    wx.closeBluetoothAdapter({
      success(res) {
        console.log('Disconnect Bluetooth');
      }
    });
  }
});
<!--The following paragraph can be placed in any of the custom function bodies (in this case, the openapi function) to call the api-->
openapi: function(){
  let apiParam = {
    "accountSid": '98651082ab89c3f1b50f35caf794179f',
    "token": 'd7ca4ca93c1e809b96ce30acf0a9a9',
    "mobile": '10000000000',
    "communityNo": '1316879946',
    "cardNo": 'd4JYo5DmvRYApL2l',
    "areaCode": '86'
  }
  let url = 'plugin://yaoshibang/yaoshibang?accountSid=' + apiParam.accountSid + '&token=' + apiParam.token + '&mobile=' + apiParam.mobile + '&communityNo=' + apiParam.communityNo + '&cardNo=' + apiParam.cardNo + '&areaCode=' + apiParam.areaCode;   yaoshibang.getFlag(apiParam).then(res => {
<!--If the info returnvalue is 1, page jump-->
    if (res.info === 1) {
      wx.navigateTo({
        url: url
      })
    }
<!--If the return value of info is 0, the json data results are displayed, the following res and err junctions are the result of processing, the user can take the next step after obtaining, such as pop-up window display to the user (not demonstrated here)-->
    if (res.info === 0) {
      let result = yaoshibang.getResult(apiParam);
      result.then(res => {
        console.log(res)
      }).catch(err => {
        console.log(err)
      })
    } else {
<!--info is not 0 or -1, return supramail information directly -->
      console.log(res)
    }
  })
}