# 9.28 IFTTT 按钮(Midea IFTTT Button)

Ifttt Connection Button 是原生引入IFTTT SDK后二次封装的IFTTT连接按钮,点击后跳转IFTTT App或web端进行授权&场景创建

# 实例

IFTTT组件

# 基础用法

<template>
    <midea-ifttt-button
        :style="style"
        :connectionId="connectionId"
        @connectIftttCallback="connectCallback"
    ></midea-ifttt-button>
</template>
<script>
export default {
    data() {
        return {
            connectionId: '', // String: IFTTT关联ID,由云端三方生态接口获取
            style: {
                width: '750px', // 按钮组件宽度,原生实现居中效果
                height: '210px', // 高度按实际情况调整,ios和Android上存在差异
            }
        }
    },
    methods: {
        connectCallback(event) {
            /* connectInfo: {
                connectionData: {
                    status: "enable", // IFTTT场景关联状态,enable:存在关联关系,服务启用;disable:存在关联关系,服务失效
                    
                }
            } */
            console.log('connectInfo', JSON.stringify(event)); // 注意:event对象体量大,必须先stringify后再打印,否则会引起App假死
        }
    }
}
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

# Attributes

Prop Type Required Default Description
connectionId String Y IFTTT关联ID,由云端三方生态接口获取
style Object Y 组件大小样式,具体见上述代码

# Events

事件名称 说明 回调参数
connectIftttCallback IFTTT SDK授权回调事件 注1
  • 注1 connectIftttCallback 回调参数
const event = {
    "connectionData": Object, // 回调信息对象
    "currentTarget": Object, // 组件元素信息
    "target": Object, // 组件元素信息
    "timestamp": Number, // 时间戳
    "type": "connectIftttCallback", // 常量
}

const connectionData = {
    "id": String, // 关联id
    "status": String, // 当前链接状态:enable:已连接;disabled:未连接(不存在关联关系/存在关联关系但未启用)
    "name": String, // 连接服务名称
    "description": String, // 连接服务描述
    "features": Array, // 连接服务功能,目前为空
    "services": Array, // 连接服务功能,目前为空
    "primaryService": Object, // 连接服务对象,目前为空
    "connectingService": Object, // 连接服务对象,目前为空
    "url": Object, // 目前为空
    "worksWithServices": Array,
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20