Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

可以增加一个分享前的事件,用来阻止用户分享 #45

Open
keepeye opened this issue Jan 8, 2015 · 6 comments
Open

可以增加一个分享前的事件,用来阻止用户分享 #45

keepeye opened this issue Jan 8, 2015 · 6 comments

Comments

@keepeye
Copy link

keepeye commented Jan 8, 2015

有个特殊的需求,某些页面不想隐藏右上角,但同时需要阻止用户的分享行为。
以前是这么写的

WeixinJSBridge.on('menu:share:timeline',function(){
    alert('私有页面,不要分享哦');
    return false;
})

我觉得大神你的api也可以增加一个前置事件以便实现这样的需求,在下先自己动手改改了:

    //WexinApi.js  129行左右
    // 监听分享操作
    WeixinJSBridge.on(cmd.menu, function (argv) {
        //增加前置回调before
        if(callbacks.before && callbacks.before(argv,data) == false){
            return false;
        }
        //over
        callbacks.dataLoaded = callbacks.dataLoaded || new Function();

调用:

   // 分享的回调
    var wxCallbacks = {
        //分享之前
        before : function(){
            alert('禁止分享本页面');
            return false;
        },
        ......
@zxlie
Copy link
Owner

zxlie commented Jan 8, 2015

感谢你的反馈,已采纳。
https://github.com/zxlie/WeixinApi#user-content-11%E7%A6%81%E6%AD%A2%E7%94%A8%E6%88%B7%E5%88%86%E4%BA%AB

另外,官方的Api应该是开放了。

原始邮件
发件人:Xian Zhaonotifications@github.com
收件人:zxlie/WeixinApiWeixinApi@noreply.github.com
发送时间:2015年1月8日(周四) 16:17
主题:[WeixinApi] 可以增加一个分享前的事件,用来阻止用户分享 (#45)

有个特殊的需求,某些页面不想隐藏右上角,但同时需要阻止用户的分享行为。
以前是这么写的
WeixinJSBridge.on('menu:share:timeline',function(){ alert('私有页面,不要分享哦'); return false; })
我觉得大神你的api也可以增加一个前置事件以便实现这样的需求,在下先自己动手改改了:
//WexinApi.js 129行左右 // 监听分享操作 WeixinJSBridge.on(cmd.menu, function (argv) { //增加前置回调before if(callbacks.before callbacks.before(argv,data) == false){ return false; } //over callbacks.dataLoaded = callbacks.dataLoaded || new Function();
调用:
// 分享的回调 var wxCallbacks = { //分享之前 before : function(){ alert('禁止分享本页面'); return false; }, ......

Reply to this email directly or view it on GitHub.

@raywill
Copy link

raywill commented Jan 8, 2015

alert('当前页面禁止分享!');
不推荐用这么简单的方法,原因是:部分情况下,用户可能希望定制自己的提示框,alert太丑了。

正确的处理方法:
建议增加callback,在没有callback的时候默认使用alert。

@raywill
Copy link

raywill commented Jan 8, 2015

抱歉,我看错了。已经加了callback。忽略我的上一条。

@Zeeging
Copy link

Zeeging commented Jan 8, 2015

“另外,官方的Api应该是开放了。”
确有此事?

@zxlie
Copy link
Owner

zxlie commented Jan 8, 2015

来自某位热心网友的消息:
http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html?pass_ticket=33tt8DVSi3G1Iq8PZNKVzbM9Ixs9gb8r2XcxReImgSzPHJmzgjV0pwDV8FPbrSVgfontScale=100plg_auth=1

应该还没正式开放;大家都等等吧,到时候就不需要用WeixinApi这个Hack模式,直接切换到官方版本。
祝大家使用愉快~~~

原始邮件
发件人:Zeegingnotifications@github.com
收件人:zxlie/WeixinApiWeixinApi@noreply.github.com
抄送:Alienxianliezhao@foxmail.com
发送时间:2015年1月8日(周四) 16:59
主题:Re: [WeixinApi] 可以增加一个分享前的事件,用来阻止用户分享 (#45)

“另外,官方的Api应该是开放了。”
确有此事?

Reply to this email directly or view it on GitHub.

@subying
Copy link

subying commented Jan 9, 2015

看了一下那个文档,觉得调用起来挺麻烦的,不知道大神有没有再次封装的想法

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants