1.0.1 • Published 2 years ago

tw-bridge v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

天蛙bridge js-sdk

说明: 天蛙移动端端bridge,方便H5、原生、微信环境下调用类似功能,统一接口

安装:

npm install tw-bridge

使用: import 'tw-bridge'

var wx = window.TwBridge;
wx.share(param).then((res)=>{ console.log(res) })

获取运行环境

  window.TwBridge.env
  // env:'native'、'weixin'、'h5'

获取签名图片地址

  window.TwBridge.signActivity().then((result) => {
    console.log(result)
  })

获取当前经纬度

  window.TwBridge.getLocation().then((result) => {
    // result:{ latitude: string,longitude: string }
    // latitude(经度)
    // longitude(纬度)
    console.log(result)
  })

获取当前设备UUID

  window.TwBridge.deviceId().then((result) => {
    // result:'uuid字符串'
    console.log(result)
  })

调用手机扫码功能

  // QrCodeScanParam:{ actionType:'read',title:'' }
  window.TwBridge.qrCodeScan(param:QrCodeScanParam).then((result) => {
    // result:'url字符串'
    console.log(result)
  })

上传文件

  // UploadParam:{ uuid: string,fileSrc: string,limit?:number }
  // fileSrc(文件存放路径,一般用应用名); limit(图片数量限制)
  window.TwBridge.upload(param:UploadParam).then((result) => {
    console.log(result)
  })

上传视频文件

  // UploadParam:{ uuid: string,fileSrc: string,limit?:number }
  // fileSrc(文件存放路径,一般用应用名); limit(图片数量限制)
  window.TwBridge.uploadVideo(param:UploadParam).then((result) => {
    // result:{ fileName: string,fileSize: string,filePath: string,coverUrl: string,id: string }
    console.log(result)
  })

上传多图片文件

  // UploadParam:{ uuid: string,fileSrc: string,limit?:number }
  // fileSrc(文件存放路径,一般用应用名); limit(图片数量限制)
  window.TwBridge.uploadImages(param:UploadParam).then((result) => {
    // result:{ fileName: string,fileSize: string,filePath: string,coverUrl: string,id: string }
    console.log(result)
  })

附件查看

  // param:'url地址'
  window.TwBridge.preview(param:string)

视频播放

  // UploadParam:{ resId: string,resType: string,videos:Array<Videos> }
  // resId(资源id);
  // resType(资源类型(classCombine:三个课堂;niceClass:精品课堂;commonPlay:网红素材))
  // videos(视频资源列表,包含视频名称,地址,大小) [{ name:'名称',url:'地址',size:100 }]
  window.TwBridge.videoPlay(param:VideoParam)

视频编辑

  window.TwBridge.videoEdit(param:VideoEdit).then((result) => {
    console.log(result)
  })

选择人员(新)

  // param:{ id:'视频Id' }
  window.TwBridge.selectExecutor(param:SelectExecutor).then((result) => {
    // result:{ id: string,name: string }
    // id(人员id);
    // name(人员名称)
    console.log(result)
  })

设置个人资料

  window.TwBridge.setProfile(param:any)

绑定消息事件监听

  // MessageType= { messageType: 'SOURCE_CLASS_COMBINE' | 'SOURCE_CQES' }
  // 业务类型  SOURCE_CLASS_COMBINE(三个课堂)、SOURCE_CQES(综合素质评价)
  window.TwBridge.bindMessageListener(param:MessageType).then((result) => {
    // result:{ event: string }
    console.log(result)
  })

关闭当前WebView

  window.TwBridge.webViewClose()

设置当前页面标题(只有在显示手机端标题下生效)

  window.TwBridge.setTitle(param:string)

设置当前页面头部颜色(只有在显示手机端标题下生效)

  //  ToolbarColor:{ statusBarColor:'#F2F2F2',toolBarColor:'#F2F2F2',titleColor:'#000000',backIconColor:'1' }
  //  toolBarColor(标题栏背景颜色:"#000000")
  //  statusBarColor(状态栏背景颜色:"#000000")
  //  titleColor(标题文字颜色)
  //  backIconColor(返回的icon的颜色:0是白色,1是黑色)
  window.TwBridge.setToolbarColor(param:ToolbarColor)

获取天蛙云平台请求头

  window.TwBridge.getHeader().then((result) => {
    // result:{ AccessToken:'',AppKey:'' }
    console.log(result)
  })

退出登录

  window.TwBridge.logout()

分享

  // ShareParam:{ title:'',desc:'',content:'',url:'',link:'',type:'link',icon:'' }
  window.TwBridge.share(param:ShareParam)

绑定生命周期监听

  //
  window.TwBridge.bindWebViewLifecycle(param?:string).then((result) => {
    console.log(result)
  })

跳转一个全新页面,无底部tab栏

  // ToActivityParam:{ url:'',name:'' }
  // url(跳转地址全路径)
  // name(新页面名称)
  window.TwBridge.toActivity(param:ToActivityParam).then((result) => {
    console.log(result)
  })
1.0.1

2 years ago

1.0.0

3 years ago

0.1.0

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago