detailmobile.php 6.96 KB
<?php $this->_extends('layout/default_layout_mobile');?>
<?php $this->_block('main');?>
<div class="detail-title">
    <h2 class="title"><?php echo $this->view->info['title']?></h2>
    <h3 class="subtitle"><?php echo date('m月d日  H:i', $this->view->info['create_time'])?></h3>
</div>
<?php if(!empty($this->view->info['pics'])):?>
<div class="slide-main detail-slide">
    <div class="slide-box">
        <div class="slide-wrap clearfix">
        <?php foreach($this->view->info['pics'] as $pic):?>
            <div class="box">
                <a href="javascript:;">
                     <img src="<?php echo Lib_Images::getImageUrl($pic, 'source','fragmentimg');?>" alt=""/>
                </a>
            </div>
      <?php endforeach;?>
        </div>
    </div>
    <div class="slide-navigator">
        <div class="dib clearfix">
            <?php echo '<a href="javascript:;" class="on"></a>'.str_repeat('<a href="javascript:;"></a>', count($this->view->info['pics']) - 1);?>
        </div>
    </div>
</div>
<?php endif;?>
<div class="detail-article">
<?php 
     $temps = $videoMatches = array();
     @preg_match_all("@<embed([^>]*)\s*src=\"http:\/\/res\.yoho\.cn\/res\/yohood\/swf\/YohoodPlayer\.swf\?url=(.+\.mp4|.+)\"@iU", $this->view->info['content'], $videoMatches1);
     @preg_match_all("@<embed([^>]*)\s*src=\"http:\/\/res\.yohood\.test\.yoho\.cn\/swf\/YohoodPlayer\.swf\?url=(.+\.mp4|.+)\"@iU", $this->view->info['content'], $videoMatches2);
     @preg_match_all("@<embed([^>]*)\s*src=\"http:\/\/res\.yohood\.cn\/swf\/YohoodPlayer\.swf\?url=(.+\.mp4|.+)\"@iU", $this->view->info['content'], $videoMatches3);
     $temps[] = $videoMatches1;
     $temps[] = $videoMatches2;
     $temps[] = $videoMatches3;
     foreach($temps as $temp)
     {
         if(!empty($temp[2]))
         {
             $videoMatches = $temp;
         }
     }
     if(!empty($videoMatches[2]))
     {
     	$video = current($videoMatches[2]);
     	$videoHtml = '<video controls="controls" preload="auto" poster="'.Lib_Images::getImageUrl($this->view->info['thumb'],'0300x0300','fragmentimg','autoCrop').'" width="300" height="300" style="width:300px;height:300px;display:block;margin:auto;"><source src="'.$video.'" type="video/mp4" /></video>';
     	$this->view->info['content'] = preg_replace('@<(object.*?)>(.*?)<(\/object.*?)>@si',$videoHtml, $this->view->info['content']);
     	$this->view->info['content'] = preg_replace('@<(embed.*?)>@si', $videoHtml, $this->view->info['content']);
     }
     echo $this->view->info['content'];
?>
</div>
<div class="related-post">
    <h2>相关推荐</h2>
    <ul>
    <?php foreach($this->view->news as $news):?>
        <li>
            <a class="clearfix" href="<?php echo url('news/detail' ,array('id' => $news['id']))?>">
                <div class="image-box">
                    <img src="<?php echo Lib_Images::getImageUrl($news['thumb'], 'source','fragmentimg');?>" alt="">
                </div>
                <div class="content"><?php echo $news['title'];?></div>
            </a>
        </li>
    <?php endforeach;?>
    </ul>
</div>
<br/>
<br/>
<div id="share" class="share" cover-url="<?php 
    $thumb = empty($this->view->info['client_thumb']) ? $this->view->info['thumb'] : $this->view->info['client_thumb'];
    echo Lib_Images::getImageUrl($thumb, 'source','fragmentimg');?>" 
    desc="<?php echo Lib_Utils_StringHelper::substr_full_en(Lib_Utils_StringHelper::stripTags($this->view->info['content']), 200);?>"
    data-link="<?php echo SITE_MAIN.'/news/detail/id/'.$this->view->info['id'];?>">
    <ul class="clearfix">
        <li class="yohoo-share-button-sina"><a href="javascript:;"></a></li>
        <li class="yohoo-share-button-qq"><a href="javascript:;"></a></li>
        <li class="yohoo-share-button-facebook"><a href="javascript:;"></a></li>
    </ul>
</div>
<script type="text/javascript" charset="utf-8" src="http://staticzine.myoho.net/download/jquery.min.js?v=20150429"></script>
<script type="text/javascript" charset="utf-8" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<?php $this->_endblock();?>
<?php $this->_block('js');?>
<script type="text/javascript">
    //初始化config信息
    var _weChatInterface = '<?php echo SITE_MAIN;?>/news/getwechatsignpackage';//签名等相关配置,yoho公众号
    $.getJSON(_weChatInterface + "?pageurl=" + encodeURIComponent(location.href.split('#')[0]) + "&callback=?", function (json) {
        if (json !== undefined && json !== '') {
            var _appId = json.appId.toString();
            var _timestamp = json.timestamp;
            var _nonceStr = json.nonceStr.toString();
            var _signature = json.signature.toString();
            wx.config({
                debug: false,
                appId: _appId,
                timestamp: _timestamp,
                nonceStr: _nonceStr,
                signature: _signature,
                jsApiList: [
                    'checkJsApi',
                    'onMenuShareTimeline',
                    'onMenuShareAppMessage',
                    'onMenuShareQQ',
                    'onMenuShareWeibo',
                    'hideMenuItems',
                    'showMenuItems',
                    'hideAllNonBaseMenuItem',
                    'showAllNonBaseMenuItem',
                    'translateVoice',
                    'startRecord',
                    'stopRecord',
                    'onRecordEnd',
                    'playVoice',
                    'pauseVoice',
                    'stopVoice',
                    'uploadVoice',
                    'downloadVoice',
                    'chooseImage',
                    'previewImage',
                    'uploadImage',
                    'downloadImage',
                    'getNetworkType',
                    'hideOptionMenu',
                    'showOptionMenu',
                    'closeWindow',
                    'scanQRCode',
                    'chooseWXPay',
                    'openProductSpecificView',
                    'addCard',
                    'chooseCard',
                    'openCard'
                ]
            });
        }
        else {

        }
    });
    //构造分享信息
    var shareTitle = $('.title').text();
    var shareImg = $(".share").attr("cover-url");
    var shareDesc = $(".share").attr("desc");
    var shareLink = $(".share").attr("data-link");
    /*
     * 微信分享 
     */
    wx.ready(function () {
        var shareData = {
            title: shareTitle,
            desc: shareDesc,
            imgUrl: shareImg,
            link: shareLink
        };
        // 2.1 “分享给朋友”
        wx.onMenuShareAppMessage(shareData);
        // 2.2 “分享到朋友圈”
        wx.onMenuShareTimeline(shareData);
        // 2.3 “分享到QQ”
        wx.onMenuShareQQ(shareData);
        // 2.4 “分享到微博”
        wx.onMenuShareWeibo(shareData);

    });
//     wx.error(function (res) {
//         alert(res.errMsg);
//     });
    seajs.use('mobile',function(mobile) {
        mobile.detail();
    });
</script>
<?php $this->_endblock();?>