Giter VIP home page Giter VIP logo

dx-sdk's Introduction

dx-js-SDK构建工程

一个简单的鼎信sdk, sdk依赖于promise,如果在不支持Promise的环境中使用该库,可能需要引入相应的pollyfill

运行方法

npm i #安装相关依赖包
npm run build #构建dx-sdk.js

npm run dev 可以打开一个简单的测试页面

接口

  • 获取定位
dx.getLocation({
  coorType: 'wgs84' //坐标系,wgs84/bd09/gcj02
}).then(result=>{
  let {
    accuracy,
    altitude,
    altitudeAccuracy,
    coorType,
    heading,
    latitude,
    longitude,
    timestamp,
    velocity
  } = result
  // more code
}).catch(e=>{
  
})
  • 关闭窗口
dx.closeWindow()
  • 选择多张图片
dx.chooseImage({
  count:1,
  sourceType:'album' // album 相册,camera 相机
}).then(result=>{
  // more code
}).catch(e=>{
  
})
  • 选择文件
dx.chooseFile({
  sourceType:'netDisk' // 从网盘选择,从本地选择
}).then(result=>{
  
}).catch(e=>{
  
})
  • 扫描二维码
dx.scanQRCode().then(result=>{
  // more code
}).catch(e=>{
  
})
  • 预览图片
dx.previewImage({
  url:'aa' // 图片地址
})
  • 人员选择
dx.selectPeoples().then(result=>{
  let [{
        avatarUrl,
        nickname,
        orgId,
        userNo
      }]= result
  // more code
}).catch(e=>{
  
})

引入方法

npm 引入(推荐)

npm i -S dx-sdk

全量引入

import * as dx from 'dx-sdk' // 全量引入,es方式
const dx = require('dx-sdk') // commonjs模式
 dx.getLocation().then(res => {
   // more code       
 })

按需引入--推荐 这种引入模式会减小打包文件的体系(虽然本身提交就不大)

 import getLocation from 'dx-sdk/dist/lib/getLocation' // es方式引入
 const getLocation = require('dx-sdk/dist/lib/getLocation') // commonjs模式引入
 
 getLocation().then(res => {
 
 })

script引入(不推荐)

首先需要构建项目。运行npm run build 会在目录下生成dist/dx-sdk.js 即可在项目中引入该js

<html>
<script src="dist/dx-sdk.js"></script>
<script>
    dx.getLocation().then(rsp=>{
      // more code
    })
</script>
</html>

dx-sdk's People

Contributors

ldwqh0 avatar

Watchers

xuqm avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.