在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML5  HTML/ 使用React-Native-Wechat組件時(shí),分享無反應(yīng)

使用React-Native-Wechat組件時(shí),分享無反應(yīng)

問題描述

APP項(xiàng)目使用React Native,需要使用微信分享接口,就用到react-native-wechat組建。項(xiàng)目中兩個(gè)模塊,一個(gè)產(chǎn)品列表模塊,一個(gè)文檔列表模塊,都可以分享,現(xiàn)在出現(xiàn)很奇怪的問題,就是文檔模塊的分享是可以打開微信并分享的,但是產(chǎn)品模塊的分享卻老是沒有反應(yīng)

相關(guān)代碼

分享操作的代碼如下:

WeChat.isWXAppInstalled().then((isInstalled) => {
    console.log("微信isInstalled:" + isInstalled);
    //是否安裝微信
    if(isInstalled){
        WeChat.isWXAppSupportApi().then((isSupportApi) => {
            console.log("微信分享isSupportApi:" + isSupportApi);
            //是否支持微信開放接口
            if(isSupportApi){
                var shareData = {
                    type: 'news',
                    title: Share_reducers.ShareName,
                    description: Share_reducers.description?Share_reducers.description:'來自'+Login_reducers.userInfo.CompanyName+'的分享',
                    webpageUrl: Share_reducers.emailUrl+'&logId='+res+'&shareType=1',
                    thumbImage: thumb,
                };
                console.log("----------------------------------微信分享-------------------------------");
                console.log(JSON.stringify(shareData));
                console.log("----------------------------------微信分享-------------------------------");
                //分享到好友
                WeChat.shareToSession(shareData).then(res=>{
                    console.log("......shared........");
                    dispatch({
                        type: 'hide',
                    });
                    msg('分享成功');
                }).catch(res=>{
                    console.log("......error........");
                    console.log(JSON.stringify(res));
                    msg('分享取消');
                    dispatch({
                        type: 'hide',
                    });
                }).finally(function() {
                    console.log("finally..................................");
                    console.log(JSON.stringify(arguments));
                });
            }else{
                msg( '不支持微信開放接口' );
                dispatch({
                    type: 'hide',
                });
            }
        });
    }else{
        msg( '沒有安裝微信軟件,請(qǐng)您安裝微信之后再試' );
        dispatch({
            type: 'hide',
        });
    }
});

使用安卓調(diào)試時(shí),文檔分享打印日志如下:

07-11 14:45:31.926: I/ReactNativeJS(10950): 微信isInstalled:true
07-11 14:45:31.965: I/ReactNativeJS(10950): 微信分享isSupportApi:true
07-11 14:45:31.965: I/ReactNativeJS(10950): ----------------------------------微信分享-------------------------------
07-11 14:45:31.965: I/ReactNativeJS(10950): {"type":"news","title":"制藥&醫(yī)療","description":"來自高怡機(jī)械的分享","webpageUrl":"http://admin.zsgc.online/zhizaohui/file_list.html?shareId=B504144231070969&id=298&shareFileType=1&platform=app&logId=1958&shareType=1","thumbImage":"http://console.zsgc.online/static/web/img/ic_launcher.png"}
07-11 14:45:31.965: I/ReactNativeJS(10950): ----------------------------------微信分享-------------------------------
07-11 14:46:24.131: I/ReactNativeJS(10950): ......shared........
07-11 14:46:24.167: I/ReactNativeJS(10950): finally..................................
07-11 14:46:24.167: I/ReactNativeJS(10950): {}

產(chǎn)品分享日志如下:

07-11 14:46:56.919: I/ReactNativeJS(10950): 微信isInstalled:true
07-11 14:46:56.958: I/ReactNativeJS(10950): 微信分享isSupportApi:true
07-11 14:46:56.959: I/ReactNativeJS(10950): ----------------------------------微信分享-------------------------------
07-11 14:46:56.959: I/ReactNativeJS(10950): {"type":"news","title":"Dyson","description":"來自高怡機(jī)械的分享","webpageUrl":"http://admin.zsgc.online/zhizaohui/product_center.html?shareId=B504144231070969&id=171&type=1&platform=app&logId=1959&shareType=1","thumbImage":"http://zsgcapp.oss-cn-hongkong.aliyuncs.com/2018/05/10/54a2f55d5b10e147a6df99a1cec7339e.png"}
07-11 14:46:56.959: I/ReactNativeJS(10950): ----------------------------------微信分享-------------------------------

求大神幫忙看看如何解決

回答
編輯回答
黑與白

找到原因了,原來是因?yàn)榉窒淼臅r(shí)候thumbImage過大,基本上都在700KB以上,使用nginx的http_image_filter_module在分享的時(shí)候處理一下圖片即可,如果使用第三方的圖片存儲(chǔ),如阿里云OSS,有提供相應(yīng)的處理功能如:域名/sample.jpg?x-oss-process=style/stylename,這些都是可以在阿里云控制臺(tái)配置即可

2017年3月29日 09:47