3DTouch

一、模块介绍

 代码如下

<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="./css/api.css" />
    <style type="text/css">

    </style>
</head>

<body class="wrap">
    <header>APICloud</header>
</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/javascript">
    apiready = function() {
        var systemType = api.systemType;
        if (systemType == 'ios') {
            //监听3DTouch
            var Touch3D = api.require('3DTouch');
            Touch3D.setListener(
                function(ret, err) {
                    var type = ret.type;
                    console.log(JSON.stringify(ret));
                    // if (type == 'com.mycompany.myapp.openfavorites') {
                    //
                    // }
                }
            );
            // //设置3DTouch的菜单列表
            Touch3D.setShortcutItems({
                items: [{
                    type: 'com.api.icpntoa.addCustomer',
                    title: '添加新客户',
                    icon: {
                        type: 3
                    },
                    userInfo: {
                        'name': 'addCustomer'
                    }
                }, {
                    type: 'com.api.icpntoa.viewMoney',
                    title: '查看工资单',
                    icon: {
                        type: 16
                    },
                    userInfo: {
                        'name': 'viewMoney'
                    }
                }, {
                    type: 'com.api.icpntoa.viewTask',
                    title: '查看待办事项',
                    icon: {
                        type: 22
                    },
                    userInfo: {
                        'name': 'viewTask'
                    }
                }]
            });
        }
    }
</script>

</html>

效果如下:

原文地址:https://www.cnblogs.com/fger/p/13163817.html