zoukankan      html  css  js  c++  java
  • 2015-11-16工作日志

    1,给页面中的标签增加css的样式

     <script type="text/javascript">
              var url = window.location.href;
              var ss = "house_list";
              var rr = "rent_list";
              var nn = "new_list";
              var mm = "map";
    
              if (url.indexOf(ss) > -1) {           
                  $("#hh a").addClass("selecets");            
                
              }
     </script>
    View Code

    2,使用jsrender 进行页面渲染 前台页面写法

     1   <ul id="top_zuhouse">
     2                 </ul>
     3                 <script type="text/x-jsrender" id="topzuhouse">
     4                    <li class="slsiede_s"><a href="/rent/show/{{:HOUSE_CODE_URL}}.html">
     5                         <div class="tupians_z">
     6                             <img src="{{:PIC_SHOW_PATH}}">
     7                             <div class="postoins_weiz">
     8                                 <i>{{:RENT_PRI}}</i>元/月</div>
     9                         </div>
    10                         <div class="conts_you clearis">
    11                             <div class="lefts">
    12                                 {{:ESTATE_NAME}}</div>
    13                             <div class="rights">
    14                                 {{:ROOM_NUM}}室{{:HALL_NUM}}厅丨{{:PROPORTION}}㎡丨{{:AT_FLOOR}}层/{{:SUM_FLOOR}}层</div>
    15                         </div>
    16                     </a></li>
    17 
    18                 </script>
    View Code

    3,后台常用分页

      1    #region 替换指定的字符串
      2         /// <summary>
      3         /// 替换指定的字符串
      4         /// </summary>
      5         /// <param name="originalStr">原字符串</param>
      6         /// <param name="oldStr">旧字符串</param>
      7         /// <param name="newStr">新字符串</param>
      8         /// <returns></returns>
      9         public static string ReplaceStr(string originalStr, string oldStr, string newStr)
     10         {
     11             if (string.IsNullOrEmpty(oldStr))
     12             {
     13                 return "";
     14             }
     15             return originalStr.Replace(oldStr, newStr);
     16         }
     17         #endregion
     18 
     19 
     20 
     21 
     22 
     23 /// 返回分页页码
     24         /// </summary>
     25         /// <param name="pageSize">页面大小</param>
     26         /// <param name="pageIndex">当前页</param>
     27         /// <param name="totalCount">总记录数</param>
     28         /// <param name="linkUrl">链接地址,__id__代表页码</param>
     29         /// <param name="centSize">中间页码数量</param>
     30         /// <returns></returns>
     31         public static string OutPageList2(int pageSize, int pageIndex, int totalCount, string linkUrl, int centSize)
     32         {
     33             //计算页数
     34             if (totalCount < 1 || pageSize < 1)
     35             {
     36                 return "";
     37             }
     38             int pageCount = totalCount / pageSize;
     39             if (pageCount < 1)
     40             {
     41                 return "";
     42             }
     43             if (totalCount % pageSize > 0)
     44             {
     45                 pageCount += 1;
     46             }
     47             if (pageCount <= 1)
     48             {
     49                 return "";
     50             }
     51             StringBuilder pageStr = new StringBuilder();
     52             string pageId = "__id__";
     53             string firstBtn = "<a  href="" + ReplaceStr(linkUrl, pageId, (pageIndex - 1).ToString()) + "">«上一页</a>";
     54             string lastBtn = "<a  href="" + ReplaceStr(linkUrl, pageId, (pageIndex + 1).ToString()) + "">下一页»</a>";
     55             string firstStr = "<a  href="" + ReplaceStr(linkUrl, pageId, "1") + "">1</a>";
     56             string lastStr = "<a  href="" + ReplaceStr(linkUrl, pageId, pageCount.ToString()) + "">" + pageCount.ToString() + "</a>";
     57 
     58             if (pageIndex <= 1)
     59             {
     60                 firstBtn = "<span class="disabled">«上一页</span>";
     61             }
     62             if (pageIndex >= pageCount)
     63             {
     64                 lastBtn = "<span class="disabled">下一页»</span>";
     65             }
     66             if (pageIndex == 1)
     67             {
     68                 firstStr = "<span class="current">1</span>";
     69             }
     70             if (pageIndex == pageCount)
     71             {
     72                 lastStr = "<span class="current">" + pageCount.ToString() + "</span>";
     73             }
     74             int firstNum = pageIndex - (centSize / 2); //中间开始的页码
     75             if (pageIndex < centSize)
     76                 firstNum = 2;
     77             int lastNum = pageIndex + centSize - ((centSize / 2) + 1); //中间结束的页码
     78             if (lastNum >= pageCount)
     79                 lastNum = pageCount - 1;
     80             pageStr.Append("<span>共" + totalCount + "记录</span>");
     81             pageStr.Append(firstBtn + firstStr);
     82             if (pageIndex >= centSize)
     83             {
     84                 pageStr.Append("<span>...</span>
    ");
     85             }
     86             for (int i = firstNum; i <= lastNum; i++)
     87             {
     88                 if (i == pageIndex)
     89                 {
     90                     pageStr.Append("<span  class="current">" + i + "</span>");
     91                 }
     92                 else
     93                 {
     94                     pageStr.Append("<a  href="" + ReplaceStr(linkUrl, pageId, i.ToString()) + "">" + i + "</a>");
     95                 }
     96             }
     97             if (pageCount - pageIndex > centSize - ((centSize / 2)))
     98             {
     99                 pageStr.Append("<span>...</span>");
    100             }
    101             pageStr.Append(lastStr + lastBtn);
    102 
    103             return "<div class="fenyesse">" + pageStr.ToString()+"</div>";
    104         }
    105         #endregion
    View Code

    4,dtcms 后台,加载详情页,可以写你想要的任何的东西,之后前台绑定

      1  /// 显示房源详情
      2     /// </summary>
      3     public partial class house_show : Web.UI.BasePage
      4     {
      5         protected string id;
      6         protected string house_type = "0";
      7         /// <summary>
      8         /// 热门搜索
      9         /// </summary>
     10         /// 
     11 
     12         
     13         protected List<string> hot_words = new List<string>();
     14 
     15         protected EFModel.trm_f_house model = new EFModel.trm_f_house();
     16         protected EFModel.tsm_b_estate_dict dict = new EFModel.tsm_b_estate_dict();
     17         /// <summary>
     18         /// 图片列表
     19         /// </summary>
     20         protected List<string> pic_paths = new List<string>();
     21         /// <summary>
     22         /// 房源标签
     23         /// </summary>
     24         protected List<string> sell_points = new List<string>();
     25         /// <summary>
     26         /// 房屋配套
     27         /// </summary>
     28         protected List<string> house_matchings = new List<string>();
     29         /// <summary>
     30         /// 同小区房源
     31         /// </summary>
     32         protected List<EFModel.trm_f_house> estate_houses = new List<EFModel.trm_f_house>();
     33         /// <summary>
     34         /// 小区成交历史
     35         /// </summary>
     36         protected List<EFModel.trm_f_house> dealed_houses = new List<EFModel.trm_f_house>();
     37         /// <summary>
     38         /// 浏览过的房源
     39         /// </summary>
     40         protected List<EFModel.trm_f_house> browsed_houses = new List<EFModel.trm_f_house>();
     41         /// <summary>
     42         /// 猜您喜欢的房源
     43         /// </summary>
     44         protected List<EFModel.trm_f_house> like_houses = new List<EFModel.trm_f_house>();
     45 
     46         protected override void ShowPage()
     47         {
     48             id = DTRequest.GetString("id");
     49             id = id.Replace("_", "-");
     50             EFModel.ChlWebEntities ent = new EFModel.ChlWebEntities();
     51 
     52             model = ent.trm_f_house.SingleOrDefault(w => w.HOUSE_CODE == id && w.STATUS == "A");
     53             if (model == null)
     54             {
     55                 HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的房源不存在或已删除!")));
     56                 return;
     57             }
     58             else 
     59             {
     60                 ChlWebEntities efmodel = new ChlWebEntities();
     61 
     62               
     63 
     64               //model 的看过的次数加一
     65                 if (model.HOUSE_CLICK_NUM == null)
     66                 {
     67                     model.HOUSE_CLICK_NUM = 1;
     68                 }
     69                 else
     70                 {
     71                     model.HOUSE_CLICK_NUM += 1;
     72                 }
     73 
     74                // efmodel.Attach(model);
     75                 //efmodel.ObjectStateManager.ChangeObjectState(model, EntityState.Modified);
     76                 efmodel.SaveChanges();
     77                
     78             
     79             }
     80 
     81 
     82             //增加点击量 HOUSE_CLICK_NUM
     83             //保存用户查看记录trm_f_house_view 用于统计用户浏览量及喜欢的房源
     84             //记录用户查看的房源的关键信息trm_f_cust_like,用于统计用户浏览量及喜欢的房源 
     85 
     86             //列出热门搜索
     87             hot_words = ent.tsm_b_keywrod.Where(w => w.HOUSE_TYPE == "1").OrderByDescending(w => w.SEARCH_SUM).Select(w => w.KEYWORDS).Take(3).ToList();
     88 
     89             //列出房源的图片列表
     90             var list = from r in ent.tpm_s_pic_rel
     91                        join p in ent.tpm_s_pic
     92                        on r.PICTURE_CODE equals p.PICTURE_CODE
     93                        where r.STATUS == "A" && p.STATUS == "A" && r.CODE == model.HOUSE_CODE
     94                        select new
     95                        {
     96                            PIC_PATH = p.PICTURE_PATH
     97                        };
     98             pic_paths = list.Select(w => w.PIC_PATH).ToList<string>();
     99 
    100             //列出房源的卖点特色
    101             string[] arrs = null;
    102             if (!String.IsNullOrEmpty(model.SELL_POINTS))
    103             {
    104                 arrs = model.SELL_POINTS.Split(new char[] { ',' });
    105                 if (arrs != null)
    106                 {
    107                     foreach (string item in arrs)
    108                     {
    109                         var pmodel = ent.tpm_s_param.SingleOrDefault(w => w.TAB_NAME == "TRM_F_HOUSE" && w.COL_CODE == "SELL_POINTS" && w.COL_VALUE_CODE == item);
    110                         if (pmodel != null)
    111                             sell_points.Add(pmodel.COL_VALUE_NAME);
    112                         if (sell_points.Count > 4)
    113                             break;
    114                     }
    115                 }
    116             }
    117             //列出房源的配套
    118             if (!String.IsNullOrEmpty(model.HOUSE_MATCHING))
    119             {
    120                 arrs = model.HOUSE_MATCHING.Split(new char[] { ',' });
    121                 if (arrs != null)
    122                 {
    123                     foreach (string item in arrs)
    124                     {
    125                         var pmodel = ent.tpm_s_param.SingleOrDefault(w => w.TAB_NAME == "TRM_F_HOUSE" && w.COL_CODE == "HOUSE_MATCHING" && w.COL_VALUE_CODE == item);
    126                         if (pmodel != null)
    127                             house_matchings.Add(pmodel.COL_VALUE_NAME);
    128                         if (house_matchings.Count > 5)
    129                          break;
    130                     }
    131                 }
    132             }
    133             //列出同小区房源(除本身外)
    134             if (!String.IsNullOrEmpty(model.ESTATE_CODE))
    135             {
    136                 dict = ent.tsm_b_estate_dict.SingleOrDefault(w => w.ESTATE_CODE == model.ESTATE_CODE);
    137                 estate_houses = ent.trm_f_house.Where(w => w.ESTATE_CODE == model.ESTATE_CODE && w.STATUS == "A" && w.HOUSE_TYPE == "1" && w.PIC_SHOW_PATH != "" && w.HOUSE_CODE != model.HOUSE_CODE).OrderByDescending(w => w.UPDATE_TIME).Take(5).ToList();
    138             }
    139             //列出已成交房源
    140             dealed_houses = ent.trm_f_house.Where(w => w.ESTATE_CODE == model.ESTATE_CODE && w.HOUSE_STATUS == "2" && w.HOUSE_TYPE == "1").OrderByDescending(w => w.UPDATE_TIME).Take(12).ToList();
    141             //浏览过的房源(需要处理)
    142             browsed_houses = estate_houses;
    143             //喜欢的房源
    144             like_houses = estate_houses;
    145         }
    146 }
    147 }
    View Code

    5,dtcms 前台数据绑定

    {model.AREA_CODESTR}


    <!--foreach循环标签-->
    <%foreach(string pic_pathitem in pic_paths)%>
    <div class="item">
    <img src="{pic_pathitem}" /></div>
    <%/foreach%>

  • 相关阅读:
    1-wire单总线DS18B20
    开漏输出
    拉电流(source current)与灌电流(sink current)
    高阻态;什么是三态门? 三态逻辑与非门电路以及三态门电路
    小电流MOS管
    DS18B20 CRC8分析
    go hmac使用
    gin入门
    go web框架推荐
    Go语言入门系列2 基本语法
  • 原文地址:https://www.cnblogs.com/flyfengling/p/4969878.html
Copyright © 2011-2022 走看看