1.1.8 • Published 4 years ago

towords-browser v1.1.8

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

towords-browser

usage

  1. ./dist 中带版本号的为浏览器版本
<script src="tbrowser@1.0.26.min.js"></script>
  1. ./dist 中不带版版本号的为ESM版本
import {install} from 'towords-browser'

// vue 全局挂载
Vue.use(install)
Vue.prototype.$tbrowser

// 浏览器script引用
window.$tbrowser

api

环境检测

{Object} $tbrowser.os

{Object} $tbrowser.browser

{Object} $tbrowser.towords

{Object} $tbrowser.thirdParty (mqqbrowser || qq || wechat || weibo)

{Object} $tbrowser.huawei

拓词APP内可调用api

$tbrowser.appapi = {
    downloadApp,
    callApp,
    messageHandler,
    sendSharedPageInfo,
    jumpToExp,
    openWechatMiniProgram,
    openUrl,
    writeExp,
}

{Function} $tbrowser.appapi.downloadApp()

调用后跳转到拓词APP的下载页面

browser.appapi.downloadApp()

{Function} $tbrowser.appapi.callApp(path, isUrl);

在浏览器环境下打开拓词, 失败则下载最新版本的安卓客户端 \ @param {string} path 打开拓词后,会进入到拓词的置顶path路径 \ @param {Boolean} isUrl 如果是真,就打开webview,否则为APP路由路径

$tbrowser.appapi.callApp('external_link=' + encodeURIComponent(location.href) + '&title=' + encodeURIComponent(document.title))

{Function} $tbrowser.appapi.openUrl(path, isUrl);

拓词APP环境下打开指定url的页面 @param {Object} opt {url|webViewUrl} @param {string} opt.url 默认为undefined,如过给出url,则在手机默认浏览器中打开此url @param {string} opt.webViewUrl 默认为undefined,如过给出webViewUrl,则在拓词app内打开此url

$tbrowser.appapi.openUrl('https://www.test.com')

{Function} $tbrowser.appapi.messageHandler(fnName ,msg)

调用App暴露的的api \ @param {string} fnName 由APP端给出回调函数名 \ @param {string} msg 发送给安卓的消息,如果是对象需要转换成JSON字符串

// android
 $tbrowser.appapi.MessageHandler('callbackName',JSON.stringify({
    data:'one message'
}))
// ios
$tbrowser.appapi.MessageHandler('callbackName',{
    data:'one message'
})

{Function} $tbrowser.appapi.sendSharedPageInfo(msg)

分享页 向安卓发送分享信息 @param {Object} msg {标题, 副标题, 图片链接, 分享出去的指定} @param {string} msg.title 标题,默认为“拓词动态” @param {string} msg.subTitle 副标题,默认为“副标题” @param {string} msg.image 图片url,默认为拓词的icon @param {string} msg.linkUrl 指定分享出去的链接,默认为当前页url

$tbrowser.appapi.sendSharedPageInfo({
    title: 'hello world', //分享标题
    subTitle: 'hello subTitel', //分享副标题
    image: 'http://official-web.oss-cn-beijing.aliyuncs.com/towords/moguiying/2/cont/1.png', //分享card的图片链接
    linkUrl: 'http://www.baidu.com' //不写默认为当前页面
})

{Function} $tbrowser.appapi.jumpToExp(expId)

根据expId跳转到拓词指定的心得详情页 \ @param {number} expId 心得的id

$tbrowser.appapi.jumpToExp(100012)

{Function} $tbrowser.appapi.writeExp(topicInfo)

根据给定的话题信息,打开APP到话题id的“写心得页面” \ @param {Number} topicInfo.topicId 话题的id \ @param {string} topicInfo.topicName 话题的名称 \

$tbrowser.appapi.writeExp({
    topicId: 56,
    topicName: '话题的名称'
})

{Function} $tbrowser.appapi.openWechatMiniProgram({ path, miniProgramId })

将path和小程序id,传给客户端,让客户端唤起指定微信小程序 \ @param {String} args.path 小程序path \ @param {String} args.miniProgramId 小程序id

$tbrowser.appapi.openWechatMiniProgram({
    path: 'one path',
    miniProgramId: '微信小程序id'
})

拓词APP 安卓下特有的api

{Function} $tbrowser.appapi.callPay(opt)

调起APP内支付 \ @param {} opt.productId 商品id \ @param {} opt.successRedirectUri 支付成功后将跳转到此链接 \ @param {} opt.couponId 当前商品的一个可用的优惠卷id \ @param {} opt.productContent 商品的一些描述 \ @param {} opt.productPrice 商品的价格 \ @param {} opt.productType 商品的价格,目前有: "AFFIX", "PLUS", "PHVB", "DEVIL"

browser.appapi.callPay({
    
})

{Function} $tbrowser.appapi.callHUAWEIPayment(product_id, success_redirect_uri, coupon_id, product_content, product_price, product_type)

APP内华为支付 @param {} product_id 商品id @param {} success_redirect_uri 支付成功后将跳转到此链接 @param {} coupon_id 当前商品的一个可用的优惠卷id @param {} product_content 商品的一些描述 @param {} product_price 商品的价格 @param {} product_type 商品的类型,目前有: "AFFIX", "PLUS", "PHVB", "DEVIL"

browser.appapi.callHUAWEIPayment(product_id, success_redirect_uri, coupon_id, product_content, product_price, product_type)

{Function} $tbrowser.appapi.noticeUpdateProductStatus(product_type)

通知客户端更新商品的状态 \ @param {String} product_type 商品的类型,目前有: "AFFIX", "PLUS", "PHVB", "DEVIL" \

browser.appapi.noticeUpdateProductStatus("AFFIX")
1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago