npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bsm-sdk

v2.0.2

Published

巴士盟js-sdk

Downloads

187

Readme

巴士盟js-sdk

第一步:在 main.js 中引入并使用

//引入
import {use} from 'bsm-sdk'
//使用
use()

第二步:使用sdk

//引入sdk
import appBridge from 'bsm-sdk'

//使用
async function getAppInfo(){
    try {
        const {data} = await appBridge.ssGetAppInfo()
        appInfo.value = JSON.stringify(data)
    } catch (e) {
        console.error(e)
    }
}

sdk列表

从相册选择图片或者拍照

const imgs = ref([])
async function onChoose() {
    try {
        const {data} = await appBridge.ssTakePhotos()
        if (data != null) {
            // 显示原生传过来的图片
            const bytes = new Uint8Array(data)
            const blob = new Blob([bytes], { type: 'image/png' })
            imgs.value.push({
                //本地路径
                url: URL.createObjectURL(blob),
                //图片内容
                blob
            })
        }
    } catch (e) {
        console.error(e)
    }
}

获取当前GPS

/*国测局坐标转百度坐标*/
/*BMap自己引入百度地图的js*/
function transGPStoBPointsByGcj02(Point) {
  return new Promise((resolve, reject) => {
    try {
      const convertor = new BMap.Convertor()
      const pointArr = []
      pointArr.push(Point)
      /*
      from----------------------
      1:GPS设备获取的角度坐标,WGS84坐标;
      2:GPS获取的米制坐标、sogou地图所用坐标;
      3:google地图、soso地图、aliyun地图、mapabc地图和amap地图所用坐标,国测局(GCJ02)坐标;
      4:3中列表地图坐标对应的米制坐标;
      5:百度地图采用的经纬度坐标;
      6:百度地图采用的米制坐标;
      7:mapbar地图坐标;
      8:51地图坐标
      * */


      /*
      to----------------------
      3:国测局(GCJ02)坐标;
      4:3中对应的米制坐标;
      5:bd09ll(百度经纬度坐标);
      6:bd09mc(百度米制经纬度坐标)
      * */
      convertor.translate(pointArr, 3, 5, data => {
        data.status === 0 ? resolve(data.points[0]) : reject('转换失败')
      })
    } catch (e) {
      reject(e.toString())
    }
  })
}

async function getGeo() {
    try {
        const location = await appBridge.ssGetLocation()
        const {lng, lat} = await transGPStoBPointsByGcj02(new BMap.Point(location.data.longitude, location.data.latitude))
        info.value = `从手机获取的GPS:${location.data.longitude},${location.data.latitude}<br/>转换成百度坐标:${lng},${lat}`
    } catch (e) {
        console.error(e)
    }
}

设置导航标题

async function onSet() {
    try {
        await appBridge.ssAppBarTitle({title:'巴士盟123'})
    } catch (e) {
        console.error(e)
    }
}

扫二维码

async function onScan() {
    try {
        const {data} = await appBridge.ssOpenScanCode('')
        alert(`扫码出来的内容是:${JSON.stringify(data)}`)
    } catch (e) {
        console.error(e)
    }
}

分享给微信联系人

async function onShare() {
    try {
        await appBridge.ssOpenShare({
            title: '标题,非必传',
            image: '图片URL,非必传',
            link: '跳转链接,必填',
            desc: '描述,必填'
        })
    } catch (e) {
        console.error(e)
    }
}

获取用户信息

async function getUserInfo() {
    try {
        const {data} = await appBridge.ssGetUserInfo()
        console.log(JSON.stringify(data))
    } catch (e) {
        console.error(e)
    }
}

获取app信息

async function getAppInfo(){
    try {
        const {data} = await appBridge.ssGetAppInfo()
        console.log(JSON.stringify(data))
    } catch (e) {
        console.error(e)
    }
}

支付

async function openPay() {
    try {
        await appBridge.ssOpenPay({
            appCode: '应用CODE',
            tenantId: '租户id',
            groupOrderNo: '组合订单号',
            payAmount: '应付款'
        })
    } catch (e) {
        console.error(e)
    }
}

跳转小程序

async function openMiniprogram() {
    try {
        await appBridge.ssOpenMiniprogram({
            appid:'小程序APPID',
            path:'指定小程序的页面路径,可以带参数',
            params:'额外参数:根据需要,可能还需要传递其他参数,如跳转时携带的数据等'
        })
    } catch (e) {
        console.error(e)
    }
}

跳转其他APP

async function openApp() {
    try {
        await appBridge.ssOpenApp({
            scheme:'APP的scheme'
        })
    } catch (e) {
        console.error(e)
    }
}

关闭应用(整个关闭)

async function onBack() {
    try {
        await appBridge.ssExitApp()
    } catch (e) {
        console.error(e)
    }
}

退出webview

async function backApp() {
    try {
        await appBridge.ssBack()
    } catch (e) {
        console.error(e)
    }
}

隐藏、显示导航栏 1.1.0+

async function hideNav() {
    try {
        //隐藏
        await appBridge.ssHideNav(false)
        //显示
        // await appBridge.ssHideNav(true)
    } catch (e) {
        console.error(e)
    }
}

跳转APP内部某个页面 1.2.0+

async function jumpToAppPage() {
    try {
        await appBridge.ssJumpToPage()
    } catch (e) {
        console.error(e)
    }
}

打开、关闭loading 1.2.0+

async function toggleLoading() {
    try {
        //打开
        await appBridge.ssToggleLoading(true)
        //关闭
        // await appBridge.ssToggleLoading(false)
    } catch (e) {
        console.error(e)
    }
}