AI.connect 连接sdk通用功能封装
 
入参
 
 
 
  
   
   | 参数  |  
   说明  |  
   类型  |  
  
 
  
  
   
   | Vue  |  
   Vue示例  |  
   Vue  |  
  
 
   
   | options  |  
   Vue示例选项  |  
   Object  |  
  
 
  
 
// 页面初始化 在启动页面 main.js 使用
connect(Vue, {
  el: '#app', // 根目录html 的 标签
  router, // router路由
  store, // vuex 状态管理器
  components: { App },
  template: '<App/>',
  deviceConfig
}) 
 
AI.urlParam 获取url中的参数
 
//例子 
链接: http://test.open-iot.tmall.com:8080/#/?productKey=100658&devId=80da07c96a05&_ali_share_button_=false
AI.urlParam();
// 返回 
{
  "urlParamVal": 3,
  "productKey": "100650",
  "devId": "80da07c969e8",
  "_ali_share_button_": "false"
} 
 
AI.goBack() 返回上一个页面
 
AI.goBack()
 
 
AI.hasNetWork 获取是否连接wifi
 
// 在天猫精灵使用  
AI.hasNetWork().then((resp) => {
	console.log(resp) // 如果成功  返回wifi 名称  例:alibaba-inc
}).catch((error) => {
	console.log(error) // 如果在web 浏览器上使用  会报‘ 请在客户端环境调用!’
}) 
 
AI.finishCurrentPage 关闭当前页面
 
AI.finishCurrentPage() // 在天猫精灵APP中使用  web 上无效
 
 
AI.listenPageChange 监听页面改变
 
 
 
  
   
   | 参数  |  
   说明  |  
   类型  |  
  
 
  
  
   
   | Background  |  
   离开页面时回调  |  
   Function  |  
  
 
   
   | Active  |  
   回到页面时回调  |  
   Function  |  
  
 
  
 
 
// 监听页面改变
AI.listenPageChange({
  Background: () => {
    // ... 离开页面
  },
  Active: () => {
    // ... 回到页面
  }
}) 
 
AI.allListenRemove 取消页面所有监听
 
 
beforeDestroy() {
  // 离开页面时 取消页面所有监听
  AI.allListenRemove();
}, 
 
AI.goWeexSetPage 前往设置页面
 
 
入参
 
 
  
   
   | 参数  |  
   说明  |  
   类型  |  
   默认值  |  
  
 
  
  
   
   | title  |  
   设置页面标题  |  
   string  |  
   设置  |  
  
 
   
   | pre  |  
   当前环境 如果是线上环境release 优先线上 如果是预发环境默认预发2  |  
   string  |  
   2  |  
  
 
  
 
 
代码示例
 
// 前往设置页面
AI.goWeexSetPage({
  title: '设置'
}); 
 
AI.setNavbar 设置navbar导航栏
 
 
入参
 
 
  
   
   | 参数  |  
   说明  |  
   类型  |  
   默认值  |  
  
 
  
  
   
   | title  |  
   设置页面标题  |  
   string  |  
   设置  |  
  
 
   
   | mainPageHasSet  |  
   首页是否展示设置按扭 flase / true  |  
   string  |  
   true  |  
  
 
   
   | pre  |  
   点击默认首页右上角设置按扭,进入设备详情页面,内测debug环境 1 - 8 字符串  |  
   string  |  
   ——  |  
  
 
   
   | right  |  
   设置navbar右侧功能  |  
   array  |  
   右侧展示设置按扭,点击前往设备详情页(不需要展示任何,可设置[])  |  
  
 
   
   | right[i].type  |  
   图片/文字 image/text  |  
   string  |  
   ——  |  
  
 
   
   | right[i].content  |  
   图片链接/展示的文字  |  
   string  |  
   ——  |  
  
 
   
   | right[i].eventFunc  |  
   兼听的点击事件  |  
   function  |  
   ——  |  
  
 
  
 
 
代码示例
 
// 设置navbar
created() {
    this.$nextTick(() => {
      this.setNavbar(); // 设置topbar
    });
},
methods: {
  setNavbar(){
      AI.setNavbar({
        title: this.title, 
        // right: [{
        //   type: 'image',
        //   eventFunc: () => {
        //     alert('you clicked on me !')
        //   },
        //   content: 'https://img.alicdn.com/tfs/TB1yOtHB9zqK1RjSZFLXXcn2XXa-40-40.png'
        // }]
      })
   }
} 
 
AI.goTiming 前往定时页面 genie-sdk 1.2.22 以上支持
 
 
代码示例
 
// 前往定时页面
AI.goTiming()
// 注:虚拟设备无法支持该功能
 
获取最近一条定时数据的剩余时间的接口 
 
AI.openExternalLink 前往项目之外的页面 genie-sdk 1.2.22 以上支持
 
代码示例
 
// 打开淘宝页面
AI.openExternalLink('https://www.taobao.com?_ali_nav_title_=新页面的标题')
						
					FAQ
						                        	关于此文档暂时还没有FAQ