码迷,mamicode.com
首页 > 其他好文 > 详细

批量修改粉丝分组

时间:2015-07-25 01:48:49      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:公众号-粉丝-分组

1:全选和反选

全选:

<input type="checkbox" id="selectAll">

列表:

<input type="checkbox" name="ids" value="‘+data.openid+‘" >

js效果:

//全选、反选
$(function() {  
  $("#selectAll").click(function() {  
    $("input[name=‘ids‘]").prop("checked", this.checked);  
  });  
  $("input[name=‘ids‘]").click(function() {  
    var $ids = $("input[name=‘ids‘]");  
    $("#selectAll").prop("checked",$ids.length ==$ids.filter(":checked").length ? true :false);  
  });  
});

function _bindCheckboxClick(){
    $("input[name=‘ids‘]").click(function() {  
        var $ids = $("input[name=‘ids‘]");  
        $("#selectAll").prop("checked",$ids.length ==$ids.filter(":checked").length ? true :false);  
    });
}

修改:

function batchMove(){
            //获取最新分组id
             var wxGroupId = $("#groupBathList").val();
             //获取选择的粉丝集合
             var openidArr = new Array; 
             $("input[type=checkbox][name=ids]:checked").each(function(i){ 
                 openidArr[i] = $(this).val(); 
             }); 
             //转换为逗号隔开的字符串 
             var openids = openidArr.join(‘,‘);
             //提交动作
                    var url = "<%=basePath%>";
                    url = url + "fan/op/batchUpdateFan.shtml";
                    var params = {};
                    params.openids = openids;
                    params.wxGroupId = wxGroupId;
                    $.post(url, params,
                            function (data) {
                                if (data.success == 1) {
                                    $(‘#errmsg‘).calert(‘alert‘,"修改成功!");
                                    query();
                                } 
                    },"json"); 

        }

后台处理:

public String batchUpdateFan(){
        try {
            map = new HashMap<String, Object>();
            map.put("success", 1);
            // 需要同步的公众号id
            WxAccount wxAccount_session = getSessUser().getWxAccount_session();
            String access_token =WxConstant.getRealAccessToken(wxAccount_session.getAccountappid());
            if(StringUtils.isNotNull(openids)){
                List<String> openidList  = StringUtils.stringToListStr(openids, ",");
                if(openidList != null && openidList.size() >0){
                    for(String openid :openidList){
                        Fan fan = new Fan();
                        fan.setOpenid(openid);
                        fan = fanService.getFan(fan);
                        if(fan!= null){
                            fan.setWxGroupId(Integer.parseInt(wxGroupId));
                            fanService.updateFan(fan);
                        }


                    }
                }
                // 同步用户分组
                String batchMoveUserToGroupUrl = WxConstant.getBatchMoveUserToGroupUrl(access_token);
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("openid_list", openidList);
                HttpUtils.post(batchMoveUserToGroupUrl, g.toJson(jsonObject));

            }


        } catch (Exception e) {
            e.printStackTrace();
            map.put("success", 0);
            map.put("errMsg", e.getMessage());
        }

        return "toResult";

    }

版权声明:本文为博主原创文章,未经博主允许不得转载。

批量修改粉丝分组

标签:公众号-粉丝-分组

原文地址:http://blog.csdn.net/u013628152/article/details/47049599

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!