0.8.1 • Published 6 years ago

newsapp-protocol v0.8.1

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

客户端与前端交互协议wiki

demo

API Usage

import newsappAPI from 'newsapp-protocol'

open

* 打开网易新闻
 * @param  path
 * 首页: /startup
 * 文章: /doc/951C0KA70001124J
 * 专题: /topic/S1385797470941
 * 网页: /web/http%3A%2F%2Fwww.163.com
 * 图集: /photo/0096/32491
 * 跟贴: /tie/C44U3PJ700097U7S
 * 直播: /live/55474
 * 视频: /video/VBV126LCH
 * 问吧: /expert/EX4064892651204023641
 * 话吧: /subject/SJ3699667062136051057
 * 萝卜: /luobo/123123
 * 新闻栏目: /channel/T1348649580692
 * 订阅(网易号): /reader/T1374482883888
 * ...
 */
 
newsappAPI.open(path)

share

// 设置分享配置
newsappAPI.share.setShareData({
      wxUrl: 'http://m.163.com',
      wxImg: '',
      wxTitle: '标题',
      wxText: '描述',
      wbImg: '',
      wbText: '',
      shareDone: function() {}
    })

//调起分享菜单
newsappAPI.share.openShareMenu()

//如果是图片分享 wxUrl参数设为空即可

userinfo

 newsappAPI.userinfo(function (info) {
      alert(JSON.stringify(info))
 })

login

 newsappAPI.login(function (info) {
      alert(JSON.stringify(info))
 })

device

 newsappAPI.device(function (info) {
      alert(JSON.stringify(info))
 })

encrypt 加密

var data = {
      a: 1,
      b: 2,
      c: 3
    }
 // 数据无需做stringify处理,协议中会处理
 newsappAPI.encrypt(data, function (encryText) {
      alert(encryText)
 })

杭研防刷trashID

newsappAPI.trash(function (trashid) {
      alert(trashid)
 })

工具栏UI相关

// 隐藏工具栏
newsappAPI.ui.hideToolbar()

// 修改标题
newsappAPI.ui.modifyTitle('修改标题')

// 定制右上角文字
newsappAPI.ui.button('刷新', function () {
  alert('回调')
})

copy

// 复制文字
newsappAPI.copy('点击复制按纽文本')

location

// 获取当前位置信息
newsappAPI.location('current', function (info) {
      alert(JSON.stringify(info))
})
// 切换位置
newsappAPI.location('switch', function (info) {
      alert(JSON.stringify(info))
})

setting

// 获取客户端设置信息
newsappAPI.setting(function (info) {
      alert(JSON.stringify(info))
})

pushview

// 反馈界面
newsappAPI.pushview.feedback()
// 优惠券界面
newsappAPI.pushview.coupon()
// 个人中心
newsappAPI.pushview.personalcenter()
// 我的任务
newsappAPI.pushview.mytask()
// 内购支付页面
newsappAPI.pushview.inapppurchase()
// 钱包
newsappAPI.pushview.wallet('coupon')
// 系统设置
newsappAPI.pushview.applicationsettings()
// app设置
newsappAPI.pushview.settings()
// 扫一扫
newsappAPI.pushview.qrcode()

单次提醒

// type 为 add remove check enable 中任一
newsappAPI.alarm({
      url:'http://163.com',
      date: '2017-07-13 21:30:00',
      title: '啦啦啦',
      message: 'push来咯',
      type: 'add',
    }, function (bool) {
    alert(bool)
})

多次提醒

// type 为 add remove check change enable 中任一
newsappAPI.remind({
      id: 'test20170712',
      url:'http://m.163.com',
      start: '2017-07-12 18:30:00',
      end: '2017-07-13 18:30:00',
      pattern: 'daily',
      title: '啦啦啦',
      message: 'push来啦',
      type: 'add',
    }, function (bool) {
    alert(bool)
})

下载图片

var url = 'http://cms-bucket.nosdn.127.net/4e6098a83e5f4bd7854fd31d2fc1738d20170620100645.jpeg'
newsappAPI.downloadImage(url, function (imgurl) {
   alert('图片下载成功' + imgurl)
})

上传图片

newsappAPI.uploadimage({ type: 'album' }, function (url) {
  alert(url)
})

写跟贴

newsappAPI.comment({
  boardid: '',
  docid: '',
  replyid: ''
 }, function (text) {
  alert(text)
})

兑奖成功更新

newsappAPI.updateprofile()
0.8.1

6 years ago

0.7.6

6 years ago

0.7.5

6 years ago

0.7.4

6 years ago

0.6.4

7 years ago

0.6.3

7 years ago

0.6.2

7 years ago

0.6.1

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.9

7 years ago

0.4.8

7 years ago

0.4.7

7 years ago

0.4.5

7 years ago

0.3.5

7 years ago

0.3.4

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago