1. 程式人生 > >ajax提交和動態重新整理

ajax提交和動態重新整理

      $.get('http://52ivi.sh.1251443851.clb.myqcloud.com/chatman/msg_viewThis.do', {fid:dt[0],owner:dt[1],sort:dt[2],search:$('.search_input').val()}, function(res) {
                    var content = '';
                    var data = JSON.parse(res);
                    if (data == null) {
                        content = content + '<span style="color: green;"><h2>無記錄</h2></span>'
                    } else {
                        $.each(data, function(i, n) {
                            var m_id = n.m_id != 'undefined' ? n.m_id : '';
                            var msg_pic_path = n.msg_pic_path != 'undefined' ? n.msg_pic_path : '';
                            var msg_title = n.msg_title != 'undefined' ? n.msg_title : '';
                            var create_user_name = n.create_user_name != 'undefined' ? n.create_user_name : '';
                            var msg_type_des = n.msg_type_des != 'undefined' ? n.msg_type_des : '';
                            var msg_address = n.msg_address != 'undefined' ? n.msg_address : '';
                            var create_time = n.create_time != 'undefined' ? n.create_time : '';
                            var countck = n.countck != 'undefined' ? n.countck : '0';
                            var countsc = n.countsc != 'undefined' ? n.countsc : '0';
                            var countpl = n.countpl != 'undefined' ? n.countpl : '0';
                            var url = 'http://52ivi.sh.1251443851.clb.myqcloud.com/chatman/msg_detail.do?m_id=' + m_id;
                            var src = "http://52ivi.sh.1251443851.clb.myqcloud.com/images/xxfw/" + msg_pic_path;
                            content = content + '<li>'
                            content = content + '<div class="wrap">'
                            content = content + ' <a class="alist" href=' + url + '>'
                            content = content + ' <div class="list_litpic fl"><img src=' + src + '></div>'
                            content = content + ' <div class="list_info">'
                            content = content + '<h4>' + msg_title + '</h4>'
                            content = content + '<h5><em>'+msg_address+'</em></h5>'
                            content = content + ' <h5><span>' + create_user_name + ' &nbsp;&nbsp;' + create_time
                            content = content + ' </span></h5>'
                            content = content + '<div class="list_info_i">'
                            content = content + ' <dl class="list_info_views">'
                            content = content + ' <dt></dt>'
                            content = content + ' <dd>'+countck+'</dd>'
                            content = content + ' <div class="clear"></div>'
                            content = content + '</dl>'
                            content = content + '<dl class="list_info_comment">'
                            content = content + '<dt></dt>'
                            content = content + '<dd>'+countpl+'</dd>'
                            content = content + '<div class="clear"></div>'
                            content = content + '</dl>'
                            content = content + '<dl class="list_info_like">'
                            content = content + '<dt></dt>'
                            content = content + '<dd>'+countsc+'</dd>'
                            content = content + '<div class="clear"></div>'
                            content = content + '</dl>'
                            content = content + '<div class="clear"></div>'
                            content = content + '</div>'
                            content = content + '</div>'
                            content = content + '<div class="clear"></div>'
                            content = content + '</a>'
                            content = content + '</div>'
                            content = content + '</li>'
                        });
                    }
                    $("#list").html(content);
                    dd.trigger('click');
                    tcst();
                    $('.alist').openNewFrame();
                });

    public ModelAndView viewThis(HttpServletRequest request, HttpServletResponse response) throws Exception {
        String sd_id = request.getParameter("fid");
        String owner = request.getParameter("owner");
        String sort = request.getParameter("sort");
        String search = request.getParameter("search");
        String result = "";
        Msg msg = new Msg();
        List<Msg> msgList = new ArrayList<Msg>();
        /*
      <li <#--class="a_selected"--> s_data="jrzx"><i class="s"></i><span>今日最新</span><i class="e"></i></li>
                    <li s_data="zrjl"><i class="s"></i><span>昨日記錄</span><i class="e"></i></li>
                    <li s_data="stjl"><i class="s"></i><span>近3天記錄</span><i class="e"></i></li>
                    <li s_data="bzjl"><i class="s"></i><span>本週記錄</span><i class="e"></i></li>
                    <li s_data="bztt"><i class="s"></i><span>本週頭條</span><i class="e"></i></li>
                    <li s_data="bytt"><i class="s"></i><span>本月頭條</span><i class="e"></i></li>
                    <li s_data="bjdtt"><i class="s"></i><span>本季度頭條</span><i class="e"></i></li>
                    <li s_data="wdfb"><i class="s"></i><span>我的釋出</span><i class="e"></i></li>
        */
        if (!StringUtil.isEmpty(sd_id)) {
            msg.setMode("msg_type");
            msg.setMsg_type(sd_id);
            msg.setOrder("create_time desc");
            msgList = msgService.list(msg);
        }

        if (!StringUtil.isEmpty(sort)) {
            if ("jrzx".equals(sort)) {    //今日最新
                // msgList = msgService.todaylist(new Msg());
                msg.setMode("today");
                msgList = msgService.timelist(msg);
            } else if ("zrjl".equals(sort)) {   //昨日記錄
                msg.setMode("yesterday");
                msgList = msgService.timelist(msg);
            } else if ("stjl".equals(sort)) {       //近3天頭條
                msg.setMode("3day");
                msgList = msgService.timelist(msg);
            } else if ("bzjl".equals(sort)) {       //本週記錄
                msg.setMode("week");
                msgList = msgService.timelist(msg);
            }/*else {
              msgList = null;  //TODO 統計頭條
            }*/
        }

        if (!StringUtil.isEmpty(owner)) {
            msg.setMode("create_user");
            msg.setCreate_user(owner);
            msgList = msgService.list(msg);
        }
        if (!StringUtil.isEmpty(msgList)) {
            result = BeanUtil.toJsonString(msgList);
        }
        // System.out.println(result);
        return responseText(response, result);

    }
                $.post("http://52ivi.sh.1251443851.clb.myqcloud.com/ivi/fdinfo_FBinfo.do", {openid:$('#openid').val(),f_type:$('#type').val(),postid:$('#m_id').val(),content:$('.newpost_w_t textarea').val()}, function(data) {
                   var c = "";


                           c=c+'<li postdata="'+data.f_id+'" usdata="'+data.f_wid+'">'
                            c=c+'<div class="pd5">'
                                c=c+'<a class="avt fl" target="_blank" href="#"><img src="'+data.f_wxuserpic+'"></a>'
                                c=c+'<div class="comment_content">'
                                    c=c+'<h5>'
                                        c=c+'<div class="fl"><a class="comment_name" href="#">'+data.f_wxusername+'</a><span>'+data.f_time+'</span></div>'
                                       /* //c=c+'<div class="fr reply_this">[回覆]</div>'*/
                                        c=c+'<div class="clear"></div>'
                                    c=c+'</h5>'
                                    c=c+'<div class="comment_p">'
                                        c=c+'<div class="comment_pct">'+data.f_info+'</div>'
                                    c=c+'</div>'
                                c=c+'</div>'
                                c=c+'<div class="clear"></div>'
                                c=c+'<div class="comment_reply"></div>'
                            c=c+'</div>'
                        c=c+'</li>'


//                    alert(c);
                    $('#fdinfo').prepend(c);
                    document.getElementById('container').scrollTop = cmofsT;
                    $('#add_newpost').removeClass('show');
                    $('.us_panel_post').find('span em').html(parseInt($('.us_panel_post').find('span em').html()) + 1);
                    replyThis();
                }, 'json');

//評論或回覆資訊
    public ModelAndView FBinfo(HttpServletRequest request, HttpServletResponse response) throws Exception {
        String g_id = request.getParameter("postid");//需要回復或評論的id
        String g_wid = request.getParameter("openid");//發表人
        String f_type = request.getParameter("f_type");  //所屬型別
        String content = request.getParameter("content");  //內容
        Fdinfo fdinfo = new Fdinfo();
            fdinfo.setF_wid(g_wid);
            fdinfo.setF_gid(g_id);
            fdinfo.setF_type(f_type);  //設定反饋資訊所屬為收藏
            fdinfo.setF_info(content);
            fdinfo.setF_time(new Date());
            String f_id = fdinfoService.create2(fdinfo);
//        }

       Fdinfo f = fdinfoService.query(f_id);    //統計所屬型別
//       f.setF_time(DateUtil.strToDate(DateUtil.formatDateYMD(f.getF_time())));
        String result = BeanUtil.toJsonString(f);
        return responseText(response, result);
    }