js分享1

/*
** Author : hzhang.Ashe
** Date   : 2014.12.11
** Descri : 报告管理
*/
var ReportManager = (function () {

    //获取数据
    function InitGrid(searchCondition) {
        //获取表格高度
        var _height = getGridHeight();
        var setLoading = setTimeout(function () {
            showLoading();
        }, 1000);

        var parameterArray = [searchCondition];
        var dataParameters = { MethodAlias: "MFRB_GetReportList", Parameter: parameterArray };
        var colOpt = [[{ display: ‘序号‘, name: ‘Index‘, width: ‘20px‘, align: "center", render: displayIndexRow }
                        , { display: ‘报告名‘, name: ‘Name‘, width: ‘180px‘, align: "left", render: displayNameRow }
                        , { display: ‘作者‘, name: ‘Author‘, width: ‘40px‘, align: "left", render: displayAuthorRow }
                        , { display: ‘修改日期‘, name: ‘UpdateTime‘, width: ‘60px‘, align: ‘left‘, render: displayUpdateTimeRow }
                        , { display: ‘描述‘, name: ‘Description‘, width: ‘260px‘, align: "left", render: displayDescriptionRow }
                      ]];

        var option = {
            url: ajaxSecureUnlockHandler,
            method: "POST",
            colModel: colOpt,
            height: _height,
            fixTableHead: true,
            showTableToggleBtn: true,
            resizable: false,
            showPercent: false,
            params: dataParameters,
            preProcess:function(data){
                clearTimeout(setLoading);   //清理loading事件
                $(".table-panel").unblock({fadeOut:  0});    //关闭loading
                return data;
            },
            onComplete: function (grid) {
                $(".table-panel .line").show(); //解决下边线的问题
                if (grid.d && grid.d.length == 0) {
                    $(".sflexigrid .divB").find("table").hide();
                    var msg;
                    if (searchCondition) {
                        msg = "未查询到匹配报告。";
                    } else {
                        msg = "您暂时没有报告,点击“新建报告”开始体验吧~";
                    }
                    $(".sflexigrid .divB").append("<div class=‘notfindDiv‘><div class=‘floater‘></div><div class=‘msgDiv‘><span>" + msg + "</span></div></div>")
                } else {
                    $(".sflexigrid .divB").find("table").show();
                    $(".sflexigrid .divB").find(".notfindDiv").remove();
                }
                InitSelectedEvent();
            }
        };
        $(".div_table").sflexigrid(option);

        function displayIndexRow(name, index, data) {
            var html = "";
            html += "<label class=‘s-index‘ >" + (index + 1).toString() || "" + "</label>";
            return html;
        }

        function displayNameRow(name, index, data) {
            var _name = (data[index][‘Name‘] || "");
            var html = "";
            html += "<input type=hidden  columnname=‘ReportId‘ value=‘" + (data[index][‘ReportId‘] || "") + "‘  />";
            html += "<input type=hidden  columnname=‘ShareId‘ value=‘" + (data[index][‘ShareId‘] || "") + "‘  />";
            html += "<input type=hidden  columnname=‘Author‘ value=‘" + (data[index][‘Author‘] || "") + "‘  />"
            html += "<a class=‘name‘ columnname=‘Name‘ columnvalue=‘" + _name + "‘>" + _name + "</a>";
            return html;
        }

        function displayAuthorRow(name, index, data) {
            var l = (data[index][‘Author‘] || "");
            return "<label columnname=‘Author‘ columnvalue=‘" + l + "‘>" + l + "</label>";
        }

        function displayUpdateTimeRow(name, index, data) {
            var l = data[index][‘UpdateTime‘] ? data[index][‘UpdateTime‘].substr(0, 10) : "";
            return "<label columnname=‘UpdateTime‘  columnvalue=‘" + l + "‘>" + l + "</label>";
        }

        function displayDescriptionRow(name, index, data) {
            var l = data[index][‘Description‘] || "";
            var __description = l;
            if (l.length > 25) {
                __description = l.substr(0, 25) + "...";
            }
            return "<div class=‘description‘><label columnname=‘Description‘ columnvalue=‘" + l + "‘>" + __description + "</label></div>";
        }
    };

    var flag;
    function InitSearchEvent() {
        $("#reportname").focus(function () {
            var $input = $(this);
            if ($input.val() == $input.attr("placeholder")) {
                $input.val(‘‘);
                $input.removeClass(‘placeholder‘);
            }
        }).blur(function () {
            var $input = $(this);
            if ($input.val() == ‘‘ || $input.val() == $input.attr("placeholder")) {
                $input.val($input.attr("placeholder"));
                $input.addClass(‘placeholder‘);
                $(".clearSearchReport").hide();
            }
        }).blur();

        $("#reportname").keyup(function () {
            var _self = this;
            if (!$(_self).val() || $(_self).val() == $(_self).attr("placeholder")) {
                $(".clearSearchReport").hide();
            } else {
                $(".clearSearchReport").show();
            }

            clearTimeout(flag);
            flag = setTimeout(function () {
                InitGrid($(_self).val());
            }, 500)
        });

        //绑定查询框的hover效果
        $(".operate-panel .search-panel-fields").hover(function () {
            $(this).addClass("ui-state-hover");
        }).mouseleave(function () {
            $(this).removeClass("ui-state-hover");
        });
    }

    function InitClearEvent() {
        $(".clearSearchReport").click(function () {
            $("#reportname").val("").blur();
            InitGrid("");
        });
    }

    function InitSelectedEvent() {
        //鼠标划过事件
        $(".sflexigrid .divB tr").mouseenter(function () {
            var $optDiv = $(".operateDiv");
            if ($optDiv.length == 0) {
                $optDiv = $("<div class=‘operateDiv‘><a href=‘javascript:void(0)‘ onclick=‘openContactPanel(this)‘ class=‘iconfont‘ title=‘分享‘></a><a href=‘javascript:void(0)‘ onclick=‘openEditPanel(this)‘ class=‘iconfont‘ title=‘编辑‘></a><a href=‘javascript:void(0)‘ onclick=‘openDeletePanel(this)‘ class=‘iconfont‘ title=‘删除‘></a></div>")
            }
            $optDiv.show();
            $(this).addClass("ui-state-hover");
            $(this).find(".description").append($optDiv);
        }).mouseleave(function () {
            $(this).removeClass("ui-state-hover");
            $(".operateDiv").hide();
        });
        //鼠标点击事件
        $(".sflexigrid .divB tr").click(function () {
            $(".sflexigrid tr.ui-state-active").removeClass("ui-state-active");
            $(this).addClass("ui-state-active");
        });
        //打开报告事件
        $(".sflexigrid .divB tr td a.name").click(function () {
            openReport(this);
        });
    }

    function DeleteRow(selTr) {
        var $selTr = $(selTr);
        if ($selTr) {
            $selTr.remove();
        }
        //重排序号
        var $tdIndexs = $(".sflexigrid .divB tr td label.s-index");
        if ($tdIndexs.length > 0) {
            for (var i = 0; i < $tdIndexs.length; i++) {
                $tdIndexs.eq(i).text(i + 1);
            }
        } else {
            var searchCondition = $("#reportname").val();
            if (searchCondition && searchCondition !== $("#reportname").attr("placeholder")) {
                msg = "未查询到匹配报告。";
            } else {
                msg = "您暂时没有报告,点击“新建报告”开始体验吧~";
            }
            $(".sflexigrid .divB").append("<div class=‘notfindDiv‘><div class=‘floater‘></div><div class=‘msgDiv‘><span>" + msg + "</span></div></div>")
            $(".sflexigrid .divB table").hide();
        }
    }

    function UpdateRow(obj, selTr) {
        var $selTr = $(selTr);
        var _name = obj.Name || "";
        $selTr.find("a[ columnname=‘Name‘]").attr("columnvalue", _name).text(_name);

        var _updatetime = obj.UpdateTime ? obj.UpdateTime.substr(0, 10) : "";
        $selTr.find("label[columnname=‘UpdateTime‘]").attr("columnvalue", _updatetime).text(_updatetime);

        var _author = obj.Author || "";
        $selTr.find("label[columnname=‘Author‘]").attr("columnvalue", _author).text(_author);
        //描述
        var _description = obj.Description || "";
        $selTr.find("label[columnname=‘Description‘]").attr("columnvalue", _description);
        if (_description.length > 25) {
            _description = __description.substr(0, 25) + "...";
        }
        $selTr.find("label[columnname=‘Description‘]").text(_description);
    }

    //loading
    function showLoading() {
        $(".table-panel").block({
            message: (‘<span class="blockMsg">正在努力加载中...</span>‘),
            baseZ: 900,
            css: {
                padding: 0,
                margin: 0,
                textAlign: ‘center‘,
                color: ‘#fff‘,
                width: ‘80%‘,
                fontSize: ‘20px‘,
                cursor: ‘default‘
            },
            overlayCSS: {
                backgroundColor: ‘#282828‘,
                opacity: 1,
                cursor: ‘default‘
            }
        });
    }

    window.onresize = function () {
        $(".div_table").sflexResize({
            height: getGridHeight()
        });
    };

    function getGridHeight() {
        var panelHeight = $(".content").height() - $(".warpper").outerHeight(true) - 10;
        $(".reporttable").height(panelHeight);
        var _temp = (panelHeight - $(".operate-panel").outerHeight() - 10) || 600;
        //此处根据每一列计算表格高度,以便刚好最底部的列和边框重合
        _temp = (parseInt(_temp / 31) * 31) + 1;
        $(".table-panel").height(_temp);
        return _temp;
    }

    return {
        Init: function (searchCondition) {
            InitGrid(searchCondition);
            //initMyContact();
            InitSearchEvent();
            InitClearEvent();
        },
        UpdateRow: function (obj, selTr) {
            UpdateRow(obj, selTr);
        },
        DeleteRow: function (selTr) {
            DeleteRow(selTr);
        }
    }
})();

//加载共享报告
function isShareReportAndCreate(selTr, dosomething) {
    var _reportid = $(selTr).find("input[columnname=‘ReportId‘]").val();
    var _shareid = $(selTr).find("input[columnname=‘ShareId‘]").val();
    //若不存在报告Id则说明该共享报告尚未创建,先创建再执行其他操作
    if (!_reportid && _shareid) {
        ajaxForCreateShareReport(selTr,_shareid, dosomething);
    } else {
        dosomething();
    }
}

function ajaxForCreateShareReport(selTr,shareId, dosomething) {
    var parameters = [shareId];
    var dataParameters = { MethodAlias: "MFRB_CreateReportByShareReportId", Parameter: parameters };
    AjaxRequest(ajaxSecureUnlockHandler, dataParameters, function (result) {
        if (result.State === 0) {
            $(selTr).find("input[columnname=‘ReportId‘]").val(result.Data.ReportId);
            dosomething();
        }
    });
}
//共享报告给他人
function openContactPanel(selTd) {
    var $selTr = $(selTd).closest("tr");
    if (!isImFriendsLoaded) {
        isImFriendsLoaded = true;
        initMyContact();
    }
    else {
        //重置共享界面
        $(".ContactPanel tr.ui-state-active").find("input:checkbox").attr("checked", false); //复选框
        $(".ContactPanel tr.ui-state-active").removeClass("ui-state-active");   //选中列
        $(".ContactPanel tr td.shareState").text("");   //分享标识
    }

    $(".ContactPanel").dialog({
        title: ‘分享报告‘,
        resizable: false,
        width: 380,
        modal: true,
        buttons: [
                    {
                        text: "确定",
                        click: function () {
                            var $selUsers = $(".contactTable tr.ui-state-active");
                            if($selUsers.length==0){
                                showAlert("未选择分享好友。");
                                return;
                            }
                            isShareReportAndCreate($selTr, function () {
                                ajaxForShareReport($selTr,$selUsers);
                            });
                            $("#ContactPanel").dialog(‘close‘);
                        }
                    }
                ]
        , open: function (event, ui) {
            //取消dialog自动focus(在终端中ie11下会有绿色边框)
            $(this).parent(‘.ui-dialog‘).find(‘.ui-state-focus‘).blur();
        }
    });
}

function ajaxForShareReport(selTr,selUsers) {
    var _reportid = $(selTr).find("input[columnname=‘ReportId‘]").val();
    var _userIds = "";
    for (var i = 0; i < selUsers.length; i++) {
        _userIds += selUsers.eq(i).attr("crmuserid");
        if (i !== selUsers.length - 1) {
            _userIds += ",";
        }
    }
    var parameters = [_reportid, _userIds];
    var dataParameters = { MethodAlias: "MFRB_ShareReport", Parameter: parameters };
    AjaxRequest(ajaxSecureUnlockHandler, dataParameters, function (result) {
        if (result.State === 0) {
            $(".ContactPanel").dialog("close");
            showAlert("恭喜分享成功!请联系对方查看报告。","分享报告","info");
        } else {
            showAlert("共享出现错误。","分享报告","warning");
        }
    });
}
//编辑
function openEditPanel(selTd) {
    var $selTr = $(selTd).closest("tr");
    var _name = $selTr.find("a[columnname=‘Name‘]").attr("columnvalue");
    var _author = $selTr.find("label[columnname=‘Author‘]").attr("columnvalue");
    var _description = $selTr.find("label[columnname=‘Description‘]").attr("columnvalue");

    //绑定编辑前的值
    $("#editPanel .s-name").val(_name);
    $("#editPanel .s-author").val(_author);
    $("#editPanel .s-description").val(_description);

    //弹出编辑框
    $("#editPanel").dialog({
        title: ‘报告编辑‘,
        resizable: false,
        width: 364,
        modal: true,
        buttons: [
                    {
                        text: "确定",
                        click: function () {
                            if(!validateReport()){
                                return;
                            }
                             $("#editPanel").dialog(‘close‘);
                             isShareReportAndCreate($selTr,function () {
                                 ajaxForSaveReport($("#editPanel .s-name").val(), $("#editPanel .s-author").val(), $("#editPanel .s-description").val(), $selTr);
                             });
                        }
                    }
                ]
         , open: function (event, ui) {
             //取消dialog自动focus(在终端中ie11下会有绿色边框)
             $(this).parent(‘.ui-dialog‘).find(‘.ui-state-focus‘).blur();
         }
    });
}

function ajaxForSaveReport(name, author, descri, selTr) {
    var _reportid = $(selTr).find("input[ columnname=‘ReportId‘]").val();
    var parameters = [_reportid, name, author, descri];
    var dataParameters = {
        MethodAlias: "MFRB_UpdateReportBasicInfo",
        Parameter: parameters
    };
    AjaxRequest(ajaxSecureUnlockHandler, dataParameters, function (result) {
        if (result.State === 0) {
            ReportManager.UpdateRow(result.Data, selTr);
        } else {
            showAlert(getResultMsg(result));
        }
    });
}
//删除
function openDeletePanel(selTd) {
    var $selTr = $(selTd).closest("tr");
    showConfirm("你确定要永久删除该报告吗?", "删除报告", function () {
        isShareReportAndCreate($selTr, function () {
            ajaxForDeleteReport($selTr);
        });
        $("#DeleteTip").dialog(‘close‘);
    });
}

function ajaxForDeleteReport(selTr) {
    var $selTr = $(selTr);
    var _reportid = $selTr.find("input[ columnname=‘ReportId‘]").val();
    var parameters = [_reportid];
    var dataParameters = { MethodAlias: "MFRB_DeleteReport", Parameter: parameters };
    AjaxRequest(ajaxSecureUnlockHandler, dataParameters, function (result) {
        if (result.State === 0) {
            ReportManager.DeleteRow(selTr);
        } else {
            showAlert(getResultMsg(result));
        }
    });
}
//打开报告
function openReport(selTd) {
    var $selTr = $(selTd).closest("tr");
    isShareReportAndCreate($selTr, function () {
        var _reportid = $selTr.find("input[columnname=‘ReportId‘]").val();
        window.location.href = "/WealthManagement/MFRB/Frame/ReportPage.aspx?reportId=" + _reportid;
    });
}

function validateReport(){
    var _name=$("#editPanel .s-name").val();
    var _author=$("#editPanel .s-author").val();
    var _description=$("#editPanel .s-description").val();
    var msg="";
    if(!_name){
        msg += "名称必须填写。";
    }
    if(_name&&_name.length>50){
        msg += "名称不能超过50字。";
    }
    if(_author&&_author.length>20){
         msg += "作者不能超过20字。";
    }
    if(_description&&_description.length>200){
         msg += "描述不能超过200字。";
    }
    if(msg.length>0){
        showAlert(msg);
        return false;
    }
    return true;
}

/*************加载共享用户列表*****************/
var userIdList = "";
var isImFriendsLoaded = false;
function initMyContact() {
    getMyContact();
}

function getMyContact() {
    var parameterArray = [];
    var dataParameters = { MethodAlias: "MFRB_GetMyContactList", Parameter: parameterArray };
    AjaxRequest(ajaxSecureUnlockHandler, dataParameters, bindMyContact);
}

function bindMyContact(xmlhttp) {
    xmlhttp = $.extend({ Data: [], ErrorCode: "", ErrorMessage: "", State: "", Page: {} }, xmlhttp);
    if (xmlhttp != null) {
        if (xmlhttp.State == 0) {
            var data = xmlhttp.Data;
            var content = "";
            $.each(data, function (i, n) {
                 var isShow="display:none";
                if(i===0){
                    isShow="";
                }
                content = content + "<tbody onclick=‘groupOperate(this)‘ >"
                        + "<tr><td class=‘ui-state-default groupTitle‘ style=‘border-top:0;border-left:0;border-right:0;‘><span class=‘ui-accordion-header-icon ui-icon ui-icon-triangle-1-e‘></span>" + data[i].Key + "(" + data[i].UserList.length + ")</td></tr>"
                    + "</tbody>"
                    + "<tbody style=‘"+isShow+"‘><tr><td>";
                $.each(data[i].UserList, function (j, m) {
                    if (data[i].UserList[j].IsShare == 1) {
                        content = content + "<table cellpadding=‘0‘ cellspacing=‘0‘ cellpadding=‘0‘ style=‘width:100%;table-layout:fixed;‘>"
                        + "<tr IMID=‘" + data[i].UserList[j].IMID + "‘ CRMUserId=‘" + data[i].UserList[j].CRMUserId + "‘ name=‘" + data[i].UserList[j].UserId + "‘ onclick=‘checkShare(this)‘ class=‘friendRow ui-state-active isShared‘>"
                        + "<td class=‘friendName‘ style=‘width:60px;‘>" + data[i].UserList[j].UserName + "</td>"
                        + "<td class=‘userId‘ style=‘width:70px;text-align:left;‘>" + data[i].UserList[j].UserId + "</td>"
                        + "<td style=‘overflow: hidden;text-overflow:ellipsis;word-break:keep-all;white-space:nowrap;‘>" + data[i].UserList[j].Company + "</td>"
                        //+ "<td class=‘shareState‘>共享</td>"
                        + "</tr></table>";

                        if (userIdList.indexOf(data[i].UserList[j].CRMUserId + ",") < 0)
                            userIdList = userIdList + data[i].UserList[j].CRMUserId + ",";
                    }
                    else {
                        content = content + "<table cellpadding=‘0‘ cellspacing=‘0‘ cellpadding=‘0‘ style=‘width:100%;table-layout:fixed;‘>"
                        + "<tr IMID=‘" + data[i].UserList[j].IMID + "‘ CRMUserId=‘" + data[i].UserList[j].CRMUserId + "‘ name=‘" + data[i].UserList[j].UserId + "‘ class=‘friendRow‘>"
                        + "<td class=‘friendName‘ style=‘width:20px;‘><input type=‘checkbox‘ onclick=‘checkShare(this)‘ /></td>"
                        + "<td class=‘friendName‘ style=‘width:60px;‘>" + data[i].UserList[j].UserName + "</td>"
                        + "<td class=‘userId‘ style=‘width:70px;text-align:left;‘>" + data[i].UserList[j].UserId + "</td>"
                        + "<td style=‘overflow: hidden;text-overflow:ellipsis;word-break:keep-all;white-space:nowrap;‘>" + data[i].UserList[j].Company + "</td>"
                        //+ "<td class=‘shareState‘></td>"
                        + "</tr></table>";
                    }
                });
                content = content + "</td></tr></tbody>"

            });

            $(".contactTable").show();
            $(".contactTable").append(content);
            $(".contactTable  .friendRow").mouseenter(function () {
                $(this).addClass("ui-state-hover");
            }).mouseleave(function () {
                $(this).removeClass("ui-state-hover");
            });
        }
        else {
            //showAlert(GetResultMsg(xmlhttp), "错误");
        }
    }
}

//用户组单击操作
function groupOperate(obj) {
    if ($(obj).next("tbody").is(":visible")) {
        $(obj).next("tbody").hide();
        $(obj).find(".ui-icon").removeClass("ui-icon-triangle-1-s");
    }
    else {
        $(obj).next("tbody").show();
        $(obj).find(".ui-icon").addClass("ui-icon-triangle-1-s");
    }
}

var $tr;
//用户单击操作
function checkShare(obj) {
    $tr=$(obj).closest("tr");
    //$tr = $("tr[IMID=‘" + $(obj).attr("IMID") + "‘]");
    if ($tr.hasClass("ui-state-active")) {
        $tr.removeClass("ui-state-active");
        clearState($tr.attr("CRMUserId"));
        if ($tr.hasClass("isShared")) {
            setUnsharedState();
        }
    }
    else {
        $tr.addClass("ui-state-active");
        if ($tr.hasClass("isShared")) {
            setGoodState();
        }
        else {
            if ($tr.attr("CRMUserId").length > 0)
                setGoodState();
            else
                setBadState();
        }
    }
}

//可共享设置
function setGoodState() {
    //$tr.children(".shareState").text("共享");
    userIdList = userIdList + $tr.first().attr("CRMUserId") + ",";
}

//不可共享设置
function setBadState() {
    $tr.children(".shareState").text("不可共享");
}

//取消共享
function setUnsharedState() {
    $tr.children(".shareState").text("");
}

//清除设置样式
function clearState() {
    $tr.children(".shareState").text("");
    var userID = $tr.first().attr("CRMUserId");
    if (userID.length > 0) {
        if (userIdList.indexOf(userID + ",") >= 0)
            userIdList = userIdList.replace(userID + ",", "");
    }
}

function shareProd() {
    if (userIdList.length > 0) {
        var parameterArray = [productId, windCode, userIdList, imUserName];
        var dataParameters = { MethodAlias: "AddUserShareProduct", Parameter: parameterArray };
        AjaxRequest(ajaxSecureUnlockHandler, dataParameters, closeWindow);
    }
    else {
        var parameterArray = [productId, windCode];
        var dataParameters = { MethodAlias: "UnshareProduct", Parameter: parameterArray };
        AjaxRequest(ajaxSecureUnlockHandler, dataParameters, unshareCloseWindow);

    }
}

function closeWindow(xmlhttp) {

    xmlhttp = $.extend({ Data: [], ErrorCode: "", ErrorMessage: "", State: "", Page: {} }, xmlhttp);
    if (xmlhttp != null) {
        if (xmlhttp.State == 0) {
            window.parent.$(".selectedRow").closest("td").prev().html("已共享");
        }
        else
            showAlert(getResultMsg(xmlhttp), "错误");
    }
}

function unshareCloseWindow(xmlhttp) {
    xmlhttp = $.extend({ Data: [], ErrorCode: "", ErrorMessage: "", State: "", Page: {} }, xmlhttp);
    if (xmlhttp != null) {
        if (xmlhttp.State == 0) {
            window.parent.$(".selectedRow").closest("td").prev().html("");
        }
        else if (xmlhttp.ErrorCode && xmlhttp.ErrorMessage) {
            showAlert(getResultMsg(xmlhttp), "错误");
        }
    }
}

  

时间: 2024-10-16 00:27:42

js分享1的相关文章

自己封装的一个JS分享组件

因为工作的需求之前也封装过一个JS分享插件,集成了我们公司常用的几个分享平台. 但是总感觉之前的结构上很不理想,样式,行为揉成一起,心里想的做的完美,实际上总是很多的偏差,所以这次我对其进行了改版. 这次的核心就是:JS只负责事件+结构,也就是把功能实现出来,具体的外观样式,则使用者自己进行定义. 以下是新版分享插件的代码: 1 (function(root){ 2 'use strict'; 3 function share(params){ 4 5 this.params = params;

js 分享到按钮

基础的思路,可以在此基础加强 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv

js“分享到”侧边框伸缩实现

思路: 1,临界值是 -150 和 0 如果大于临界值,就要隐藏 2,隐藏:速度为负 显示:速度为正 3,如果与临界值相等,就清空定时器 否则,就运动 --------------------------------html <div id="div1"><span>分享到</span></div> <style> #div1 { position:absolute; left:-150px; width:150px; hei

微信6.0.2 js 分享

12月25日 微信更新到6.0.2版本,此次对开发者影响比较大的就是原来微信分享的JS 将不再对开发者开发,对此官方的解释是: 旧版的获取分享状态及设置分享内容的JS接口一直用于内部业务,并未对外开放,在微信公开的开放文档里面并没有此接口. 某些第三方借助微信客户端漏洞在未获得权限的情况下使用接口,微信6.0.2版本对此漏洞做了修复以确保用户分享内容的准确性,避免诱导分享. 另外,不久将向广大公众号开放正式分享接口供开发者使用. 根据今天我们公司跟腾讯交涉的反馈是腾讯将对此接口进行白名单验证,相

学习js分享

购物车怎么做见代码 /购物车 (数组版本)(function ($) { $.fn.TaShopCartArray = function (setting) { //初始化配置 var opts = $.extend({}, $.fn.TaShopCartArray.defaults, setting); //读取cookeie信息 var _initdata = []; if (opts.savecookie && $.cookie(opts.cookiename) != null &a

iShare.js分享插件

iShare.js是一个小巧的分享插件,纯JS编写,不依赖任何第三方库,使用简便.为啥写这个插件? 因为在搭建个人blog时(还没有搭建好(¯﹃¯)),对目前国内比较受欢迎的分享插件都不太满意,主要如下几点: 不太喜欢官方提供的样式,想重新定制,但又不太方便 提供的大部分接口都没用到,真正用到就那么几个,显得有点冗余 没有进行更新维护,部分接口都是挂掉 另外,工作中,有时想要一个可以自定义样式.支持常用的分享接口.使用方便.不依赖于第三库的独立库.比如写活动页面时(⊙﹏⊙) 基于上述原因自己就创

js分享功能实现

分享功能初步测试,title为当前页面的title. 其他详见注释!!! <!doctype html> <html> <head> <meta http-equiv="Content-Type" Content="text/html; charset=utf-8;"> <title>分享代码测试</title> <meta name="author" content=

微信Js分享朋友接口invalid signature解决方法

导致这个错误是因为签名算法错误 签名需要 noncestr timestamp(因为变量长度限制,不能直接使用毫秒时间戳,要除以1000) jsapi_ticket url 根据微信的文档说明做的话 最容易出错的地方是url 文档上对url的描述反正我是没怎么看懂~ 好了吐槽完毕,是时候上代码了 Java代码:         @RequestMapping("share2Firend")         //from.isappinstalled参数是自定义分享接口时 微信服务器带过

自己动手写js分享插件 [支持https] (可以分享QQ空间,微信,新浪微博。。。)

由于百度分享,jiathis 等分享插件在https下均会报错,就萌生了自己动手写一个分享插件的念头,其实实现起来一点都不难,以下代码都已在https网站运行通过,特附上以下代码:还请各位看官不吝赐教: 附上演示效果网址:https://www.aishandian.com/jiekuan_zhishi-979.html 动画实现效果代码 $(document).on("click", ".msb_main", function() { if($(this).has

微信js分享朋友圈

1.绑定域名 先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”. 备注:登录后可在“开发者中心”查看对应的接口权限. 2.引入js文件 <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> <script type="text/javascript" src=