最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

thinkPHP商城公告功能開發(fā)問題分析

 更新時間:2016年12月01日 11:10:45   作者:牛逼的霍嘯林  
這篇文章主要介紹了thinkPHP商城公告功能開發(fā)問題,結(jié)合實例形式分析了基于thinkPHP實現(xiàn)商城公告功能所涉及的ajax交互及數(shù)據(jù)庫操作相關(guān)技巧,需要的朋友可以參考下

本文實例分析了thinkPHP商城公告功能開發(fā)問題。分享給大家供大家參考,具體如下:

效果如下

1.定在頭部

position: fixed;
z-index: 999;
top: 0;
opacity:1;

2.ajax處理json數(shù)據(jù)

// 獲取商城公告
function getNotice() { // 獲取公告函數(shù)
  var res;
  $.ajax({
    type: "POST",
    url: "{sh::U('Store/Mall/ajaxGetNotice',array('mid'=>$mid))}",
    dataType:'json', // 設(shè)為json之后,就能夠很好的處理獲取的json數(shù)據(jù),json.status
    async: false,
    success: function(json){
      res = json;
    }
  });
  return res;
}

設(shè)置dataType:'json'之后,json數(shù)據(jù)就直接可以通過json.的方式處理了。

3.最后加載,頁面更好看。

$(document).ready(function(e) { // 主函數(shù)
  // 獲取公告
  var action_name = "{sh::ACTION_NAME}"; // 頁面使用thinkphp常量
  var json = getNotice();
  if ( action_name == 'index' && json.status == 1) { // 首頁并且公告存在
    $(".top").css("margin-top", "70px"); // jquery設(shè)置css
    $(".main-sidebar").css("top" ,"70px");
    var html = '';
    $.each(json.info, function(i, n){ // n為文本內(nèi)容
      html += "<li><strong>"+n.content+"</strong></li>"
    });
    $(".top-notice").show();
    $('#notice ul').html(""+html);
    $('#notice').unslider(); // 輪播
  }
});

4.獲取sql語句的thinkphp處理

// 獲取公告
function ajaxGetNotice() {
    if (IS_AJAX) {
      $this->mid;
      // 獲取有效的,且結(jié)束時間大于當(dāng)前時間的,或者日期等于0的公告
      $mallNoticeModel = M('Mall_notice');
      $where['mall_id'] = $this->mid;
      $where['status'] = 1;
      $where['endtime'] = array(array('eq',0),array('gt',time()), 'or') ;
      //SELECT * from sh_mall_notice where mall_id = 9 and status = 1 and (endtime = 0 or endtime>1458354366);
      $notice = $mallNoticeModel->where($where)->order('sort desc')->select();
      if (!empty($notice)) {
        $this->ajaxReturn(array('status'=>'1','info'=>$notice,'msg'=>"獲取成功"),'JSON');
      } else {
        $this->ajaxReturn(array('status'=>'2','info'=>$notice,'msg'=>"公告不存在"),'JSON');
      }
    }
}

$where['endtime'] = array(array('eq',0),array('gt',time()), 'or') ;

巧妙的處理了這種邏輯關(guān)系。

更多關(guān)于thinkPHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《ThinkPHP入門教程》、《thinkPHP模板操作技巧總結(jié)》、《ThinkPHP常用方法總結(jié)》、《codeigniter入門教程》、《CI(CodeIgniter)框架進(jìn)階教程》、《Zend FrameWork框架入門教程》、《smarty模板入門基礎(chǔ)教程》及《PHP模板技術(shù)總結(jié)》。

希望本文所述對大家基于ThinkPHP框架的PHP程序設(shè)計有所幫助。

相關(guān)文章

最新評論

东莞市| 辽阳县| 昌江| 百色市| 留坝县| 沽源县| 卢氏县| 日喀则市| 西充县| 新丰县| 茂名市| 常山县| 平和县| 惠水县| 宽甸| 怀宁县| 永泰县| 罗源县| 浮山县| 昌宁县| 唐山市| 南华县| 望都县| 全南县| 甘孜县| 鄂温| 册亨县| 天峻县| 蒙阴县| 重庆市| 南皮县| 扎赉特旗| 徐汇区| 中江县| 惠东县| 高安市| 塔河县| 昌乐县| 武陟县| 安吉县| 鱼台县|