Show/hide sharing button in DingTalk navigation bar

Show/hide sharing button in DingTalk navigation bar

hide

After the development of Dingding, there will be three small dots "..." in the upper right corner when opening the application. After opening, some sharing functions or viewing links will be displayed. This is a hidden danger to the security of the application, so how to block these button functions It.

According to the Dingding document, the mobile js api needs to be introduced

<script src="//g.alicdn.com/dingding/dingtalk-jsapi/2.0.8/dingtalk.open.js"></script>

Here is the usage of vue, if you use jq students to change the function

  dingLogin: function () {
    
    
                    if (dd.ios || dd.android||dd.pc) {
    
    ///如果是钉钉客户端进入
                    
                        dd.biz.navigation.setRight({
    
    
                            show: false, //控制按钮显示, true 显示, false 隐藏, 默认true
                        })
                    }
                },

After this code setting, the sharing button of the navigation is gone, and the application security is also increased.
Insert picture description here

display

Customize content and title when sharing

// 根据钉钉文档说明,移动端 js api需要引入
<script src="//g.alicdn.com/dingding/dingtalk-jsapi/2.0.8/dingtalk.open.js"></script>
dingLogin: function () {
    
    
                    var self = this;
                    if (dd.ios || dd.android||dd.pc) {
    
    ///如果是钉钉客户端 进入
                        dd.biz.navigation.setRight({
    
    
                            show: true, //控制按钮显示, true 显示, false 隐藏, 默认true
                            control: true, //是否控制点击事件,true 控制,false 不控制, 默认false
                            showIcon: true, //是否显示icon,true 显示, false 不显示,默认true; 注:具体UI以客户端为准
                            onSuccess: () => {
    
    
                                //如果control为true,则onSuccess将在发生按钮点击事件被回调
                                dd.biz.util.share({
    
    
                                    type: 0, //分享类型,0:全部组件 默认; 1:只能分享到钉钉;2:不能分享,只有刷新按钮
                                    url: window.location.href,
                                    content: '我是分享的内容!',
                                    title: '我是分享的标题',
                                    image: 'http://pic24.nipic.com/20120906/2786001_082828452000_2.jpg',
                                    onSuccess: function () {
    
    
                                        //onSuccess将在分享完成之后回调
                                        alert('偶哟分享成功了', window.location.href);
                                        /**/
                                    },
                                    onFail: function (err) {
    
    
                                        alert('好遗憾,分享失败了');
                                    }
                                })
                            },
                            onFail: () => {
    
     },
                        });
                    }
                },

For more custom navigation, please refer to the official website API: https://open-doc.dingtalk.com/microapp/dev/pqgdu0#a-nameescmqqa Set multiple buttons on the right side of the navigation bar

Guess you like

Origin blog.csdn.net/weixin_38179690/article/details/109387621