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

{{昨夜雨疏风骤----致那些年码过的码}}

时间:2015-05-17 09:15:35      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:

又在被小伙伴嫌弃了,一句“你都毕业两年了”就已经够摧残我了,所以我没有跟他纠正 他说错了其实是三年。。。。

说到最后我急了,只当回过去一句“姐不差钱”,然后再脑补上“谢了你们的关心”。。。。。

然后我就又陷入了晚上深度失眠早上极度早醒的亢奋状态。。。然后特别想追忆当年的我和码过的码。。。

微礼物--当时公司有N个团队在做这个类似的系统,当然这是被毙掉的一版。。。此情可待成追忆 

技术分享
/**
 * 礼物操作
 * @id $.pl.gift.nav.source.sent
 * @param {Object} node 组件最外节点
 * @return {Object} 实例
 * @author gaohan5@staff.sina.com.cn
 *
 */
$Import(‘kit.dom.parseDOM‘);
$Import(‘common.dialog.receiveShare‘);
$Import(‘common.dialog.sendGift‘);
$Import(‘ui.alert‘);
$Import(‘common.trans.picshow‘);
STK.register(‘pl.gift.show.source.picShow‘, function($) {



    //+++ 常量定义区 ++++++++++++++++++
    var TPL = ‘<#et giftinfo data>‘ +
                    ‘<div>‘+
                        ‘<span class="the_time">‘+
                            ‘<#if (data.ispublic == 2)><a class="friend_name">${data.screen_name}</a>‘+
                            ‘<#else><a class="friend_name" target="_blank" href="http://weibo.com/u/${data.uid}">${data.screen_name}</a></#if>‘+
                                ‘<#if (data.status == 1)>‘+
                                    ‘<a target="_blank" href="http://verified.weibo.com/verify"><img src="http://img.t.sinajs.cn/t5/style/images/common/transparent.gif" title="新浪个人认证" alt="新浪个人认证" class="approve"></a>‘+
                                ‘<#elseif (data.status == 2)>‘+
                                    ‘<a target="_blank" href="http://verified.weibo.com/verify"><img src="http://img.t.sinajs.cn/t5/style/images/common/transparent.gif" title="新浪机构认证" alt="新浪机构认证" class="approve_co"></a>‘+
                                ‘<#elseif (data.status == 3)>‘+
                                    ‘<a target="_blank" href="http://club.weibo.com/intro"><img src="http://img.t.sinajs.cn/t5/style/images/common/transparent.gif" title="微博达人" alt="微博达人" class="ico_club" node-type="daren"></a>‘+
                                ‘<#elseif (data.status == 4)>‘+
                                    ‘<a target="_blank" href="http://vgirl.weibo.com/"><img src="http://img1.app.wcdn.cn/ops/vgirl/style/images/common/vg_trans.gif" title="微博女郎" alt="微博女郎" class="ico_vlady"></a>‘+
                                ‘</#if>‘+
                                ‘<#if (data.isvip == 1)>‘+
                                    ‘<a target="_blank" href="http://vip.weibo.com/personal?from=main"><img src="http://img.t.sinajs.cn/t5/style/images/common/transparent.gif" title="微博会员" alt="微博会员" class="ico_member"></a>‘+
                                ‘</#if>‘+
                                ‘<em class="time">${data.date}</em> ‘+
                                ‘<#if (data.ispublic == 1)><em class="send_way S_txt2">悄悄赠送</em>‘+
                                ‘<#elseif (data.ispublic == 3)><em class="send_way S_txt2">公开赠送</em>‘+
                                ‘<#elseif (data.ispublic == 2)><em class="send_way S_txt2">匿名赠送</em></#if>‘+
                                ‘<#if (data.type == 2)><a href="javascript:void(0);" class="del_this" action-type="delgift" action-data="id=${data.onlyid}&page=${data.page}">删除</a></#if>‘ +
                        ‘</span>‘+
                    ‘</div>‘+
                        ‘<#if (data.gift_status != 3)><#if (data.ispublic != 1)><#if (data.type != 1)><a href="javascript:void(0);" class="W_btn_e" action-type="sharenode" style="display:" action-data="${data.alldata}"><span>分享</span></a></#if></#if></#if>‘+
                        ‘<#if (data.gift_status != 3)><a href="javascript:void(0);" class="W_btn_e" action-type="sentnode" style="display:" action-data="${data.alldata}"><span>转赠</span></a></#if>‘+
                        ‘<#if (data.gift_status != 3)><#if (data.ispublic != 2)><#if (data.type != 1)><a href="javascript:void(0);" class="W_btn_e" action-type="thxnode" style="display:" action-data="${data.alldata}"><span>答谢</span></a></#if></#if></#if>‘+
                ‘</#et>‘;
    var vipTag = ‘<span node-type="vipTag" class="gift_icon corner_ico_vip_b"></span>‘;
    var insertHTML = $.core.dom.insertHTML;
    var setStyle = $.core.dom.setStyle;
    var parseURL = $.kit.extra.parseURL;
    var L = $.kit.extra.language;
    var jsonToQuery = $.core.json.jsonToQuery;
    
    //-------------------------------------------

    return function(node) {
        var argsCheck, parseDOM, initPlugins, bindDOM, bindCustEvt, bindListener, destroy, init, that = {};
        var thxNode, shareNode, sentNode,userid;
        var url, sentDia, thxDia, fullTpl, simpleTpl;
        var dEvent = $.core.evt.delegatedEvent(node);
        var getTrans = $.common.trans.picshow.getTrans;
        var dia, giftDia;
        var giftShowNormal;

        //+++ 变量定义区 ++++++++++++++++++
        var _this = {
            DOM : {}, //节点容器
            objs : {}, //组件容器
            DOM_eventFun : {//DOM事件行为容器
                sharenodeClick : function(spec) {
                    setTimeout(function () {
                        dia.show({
                            ‘cid‘ : spec.data.cid,
                            ‘gid‘ : spec.data.gid,
                            ‘content‘ : spec.data.share_content,
                            ‘imgSrc‘ : spec.data.url,
                            ‘simg‘ : spec.data.simg
                        });
                    }, 0);
                },
                sentnodeClick : function(spec){
                    if(giftShowNormal.value == 1) {
                        var data = spec.data;
                        data.bimg && (data.url = data.bimg);
                        giftDia(simpleTpl).show(data);
                    } else if(giftShowNormal.value == 0){
                        $.ui.alert(L(‘#L{当前系统繁忙,稍等一下再来看看哦!}‘));
                    }
                },
                thxnodeClick:function(spec){
                    if(giftShowNormal.value == 1) {
                        var data = spec.data;
                        data.users = [{screen_name : data.screen_name, uid : data.uid}];
                        delete data[‘show_vip‘];
                        giftDia(fullTpl).show(data);
                    } else if(giftShowNormal.value == 0) {
                        $.ui.alert(L(‘#L{当前系统繁忙,稍等一下再来看看哦!}‘));
                    }
                },
                lastPic : function() {
                    $.listener.fire(‘scan‘, ‘pre‘);
                },
                nextPic : function() {
                    $.listener.fire(‘scan‘, ‘next‘);
                },
                clickDelGiftfn : function (spec) {
                    //$.listener.fire(‘scan‘,‘del‘);
                    $.ui.alert(L(‘#L{是否删除礼物?}‘),{
                        ‘OK‘ : function() {
                            trans.delGift.request(spec.data);
                        }
                    });
                }
            }
        };
        var openDialog = function(tpl, data){
            
        };

        var trans = {
            ‘delGift‘ : getTrans("delGift", {
                "onSuccess" : function(ret,data) {
                    //alert(‘ok‘);
                    $.listener.fire(‘scan‘,‘del‘,ret.data);
                },
                "onError" : function(ret,data) {
                    if(ret.msg){
                        $.ui.alert(ret.msg);
                    }
                }
            })
        };
        //----------------------------------------------
        
        //+++ 参数的验证方法定义区 ++++++++++++++++++
        argsCheck = function() {
            if(!node) {
                throw new Error(‘[pl.gift.show.source.picShow] node没有定义‘);
            }
        };
        //-------------------------------------------

        //+++ Dom的获取方法定义区 ++++++++++++++++++
        parseDOM = function() {
            //内部dom节点
            _this.DOM = $.kit.dom.parseDOM($.builder(node).list);
            fullTpl = $.E(‘full‘) && $.E(‘full‘).innerHTML;
            simpleTpl = $.E(‘simple‘) && $.E(‘simple‘).innerHTML;
            thxNode = $.sizzle(‘[action-type="thxnode"]‘,node)[0];
            shareNode = $.sizzle(‘[action-type="sharenode"]‘,node)[0];
            sentNode = $.sizzle(‘[action-type="sentnode"]‘,node)[0];
            giftShowNormal = $.sizzle(‘[node-type="gift_show_normal"]‘,$.E(‘plc_layer‘))[0];
        };
        //-------------------------------------------

        //+++ 模块的初始化方法定义区 ++++++++++++++++++
        initPlugins = function() {
            _this.DOM[‘picture‘] && (_this.DOM[‘picture‘].style.display = ‘‘);
            _this.DOM[‘imgloading‘] && (_this.DOM[‘imgloading‘].style.display = ‘none‘);
            dia = $.common.dialog.receiveShare();
            giftDia = $.common.dialog.sendGift;
            userid = $.E(‘getoid‘);
        };
        //-------------------------------------------
        //+++ DOM事件绑定方法定义区 ++++++++++++++++++
        bindDOM = function() {
            $.addEvent(_this.DOM[‘prepic‘], ‘click‘, _this.DOM_eventFun.lastPic);
            $.addEvent(_this.DOM[‘nextpic‘], ‘click‘, _this.DOM_eventFun.nextPic);
            dEvent.add(‘sharenode‘, ‘click‘, _this.DOM_eventFun.sharenodeClick);
            dEvent.add(‘sentnode‘, ‘click‘, _this.DOM_eventFun.sentnodeClick);
            dEvent.add(‘thxnode‘, ‘click‘, _this.DOM_eventFun.thxnodeClick);
            dEvent.add(‘delgift‘, ‘click‘, _this.DOM_eventFun.clickDelGiftfn);
        };
        //-------------------------------------------

        //+++ 自定义事件绑定方法定义区 ++++++++++++++++++
        bindCustEvt = function() {
        };
        //-------------------------------------------

        //+++ 广播事件绑定方法定义区 ++++++++++++++++++
        bindListener = function() {
            $.listener.register(‘point‘, ‘scanpoint‘, function(data) {
                var alldata = jsonToQuery(data);
                !data.alldata &&(data.alldata = alldata);
                
                !data.type && (data.type = ‘‘);
                if($CONFIG[‘uid‘] != userid.value){
                    data.type = 1;
                } else if ($CONFIG[‘uid‘] == userid.value) {
                    data.type = 2;
                }
                _this.DOM[‘inner‘].innerHTML = L($.core.util.easyTemplate(TPL,data).toString());
                
                //增加图片onload的回调 add by mabo
                
                _this.DOM[‘picture‘].onload = function(){
                    _this.DOM[‘picture‘].style.display = ‘‘;
                    _this.DOM[‘imgloading‘].style.display = ‘none‘;
                };
                if(_this.DOM[‘picture‘].src != data.url) {
                    _this.DOM[‘picture‘].style.display = ‘none‘;
                        _this.DOM[‘imgloading‘].style.display = ‘‘;
                        _this.DOM[‘picture‘].src = data.url;
                } 
                
                //end

                
                var vipNode = $.sizzle(‘[node-type="vipTag"]‘,node)[0];
                var beforeVipTag = $.kit.dom.children($.E(pl_gift_show_index))[0];
                if (data.isvgift == 2 && !vipNode){
                
                    insertHTML(beforeVipTag,vipTag);
                    
                }else if(data.isvgift == 0 && vipNode){
                    
                    $.core.dom.removeNode(vipNode);
                    
                }
            });
        };
        //-------------------------------------------

        //+++ 组件销毁方法的定义区 ++++++++++++++++++
        destroy = function() {
            if(_this) {

                $.foreach(_this.objs, function(o) {
                    if(o.destroy) {
                        o.destroy();
                    }
                });
                _this = null;
            }
            dEvent.remove(‘sharenode‘,‘click‘);
            dEvent.remove(‘sentnode‘,‘click‘);
            dEvent.remove(‘thxnode‘,‘click‘);
        };
        //-------------------------------------------

        //+++ 组件的初始化方法定义区 ++++++++++++++++++
        init = function() {
            argsCheck();
            parseDOM();
            initPlugins();
            bindDOM();
            bindCustEvt();
            bindListener();
        };
        //-------------------------------------------
        //+++ 执行初始化 ++++++++++++++++++
        init();
        //-------------------------------------------

        //+++ 组件公开属性或方法的赋值区 ++++++++++++++++++
        that.destroy = destroy;

        //-------------------------------------------

        return that;
    };

});
View Code
技术分享
/**
 * 礼物操作
 * @id $.pl.gift.show.source.scanall
 * @param {Object} node 组件最外节点
 * @return {Object} 实例
 * @author gaohan5@staff.sina.com.cn
 *
 */
$Import(‘kit.dom.parseDOM‘);
$Import(‘common.trans.picshow‘);
$Import(‘kit.dom.children‘);
$Import(‘kit.dom.next‘);
$Import(‘ui.alert‘);
STK.register(‘pl.gift.list.source.scanall‘, function($) {

    //+++ 常量定义区 ++++++++++++++++++
    
    //-------------------------------------------

    return function(node) {
        var argsCheck, parseDOM, initPlugins, bindDOM, bindCustEvt, bindListener, destroy, init, that = {};
        //+++ 变量定义区 ++++++++++++++++++
        var dEvent = $.core.evt.delegatedEvent(node);
        var getTrans = $.common.trans.picshow.getTrans;
        var vipTag = ‘<span class="gift_icon corner_ico_vip_s" name="viptag"></span>‘;
        var userid,allgifts,length,giftcount,giftpage,selected;
        
        var _this = {
            DOM : {}, //节点容器
            objs : {}, //组件容器
            DOM_eventFun : {//DOM事件行为容器

                //请求礼物数据
                changePage : function(spec) {
                    
                    getNewGifts(spec.data.page);

                },
                changeStyle : function(spec) {
                    if($.hasClassName(spec.el, ‘cur‘)) return;
                    //data = spec.data;
                    transToShow(spec.data);
                    //清除黄框样式
                    var current = $.sizzle(‘[action-type="point"].cur‘,node)[0];
                    $.removeClassName(current, ‘cur‘);
                    //给选看的礼物增加样式
                    $.addClassName(spec.el, ‘cur‘);

                },
                lastPic : function() {

                    //清除黄框样式
                    var current = $.sizzle(‘[action-type="point"].cur‘,node)[0];

                    var data = current.getAttribute("action-data");
                    data = $.queryToJson(data);
                    var id = data.id;
                    //临街判断  是否请求新的数据
                    if(id == 1) {

                        selected = 9;
                        var currentpage = $.sizzle(‘[class="page S_txt1"]‘,node)[0];
                        var data = currentpage.getAttribute("action-data");
                        data = $.queryToJson(data);
                        var page = data.page;
                        page--;
                        if(page != 0) {

                            getNewGifts(page);

                        }

                    } else {

                        $.removeClassName(current, ‘cur‘);
                        var prev = $.core.dom.prev(current);
                        var beforedata = prev.getAttribute("action-data");
                        beforedata = $.queryToJson(beforedata);
                        var id = beforedata.id;
                        transToShow(beforedata);
                        $.addClassName(prev, ‘cur‘);

                    }
                },
                nextPic : function() {
                    //清除黄框样式
                    var current = $.sizzle(‘[action-type="point"].cur‘,node)[0];
                    
                    var data = current.getAttribute("action-data");
                    data = $.queryToJson(data);
                    var id = data.id;
                    //临街判断  是否请求新的数据
                    if(id == 9) {

                        selected = 1;
                        var currentpage = $.sizzle(‘[class="page S_txt1"]‘,node)[0];
                        var data = currentpage.getAttribute("action-data");
                        data = $.queryToJson(data);
                        var page = data.page;
                        page++;
                        if (page <= giftpage){
                            getNewGifts(page);
                        }
                    } else {
                        
                        if(allgifts[length-1] != current){
                            
                            $.removeClassName(current, ‘cur‘);
                            var next = $.kit.dom.next(current);
                            var data = next.getAttribute("action-data");
                            data = $.queryToJson(data);
                            var id = data.id;
                            transToShow(data);
                            $.addClassName(next, ‘cur‘);
                            
                        }
                    }
                }
            }

        };

        //----------------------------------------------

        var trans = {
            ‘profShow‘ : getTrans("profShow", {
                "onSuccess" : function() {
                    //alert(‘ok‘);
                },
                "onError" : function(ret) {
                    //if(ret.msg){
                    // $.ui.alert(ret.msg);
                    // }
                }
            }),
            ‘picShow‘ : getTrans("picShow", {
                "onSuccess" : function(ret, para) {
                    _this.DOM.list.innerHTML = ret.data.html;
                    var data = getCurrent();
                    transToShow(data);
                    sentActive();
                    giftpage = ret.data.page;
                    giftcount = ret.data.gift_total;
                    $.listener.fire(‘point‘, ‘giftcount‘, giftcount);
                    allgifts = $.sizzle(‘[action-type="point"]‘,node);
                    length = allgifts.length;
                },
                "onError" : function(ret, para) {
                    if(ret.msg) {
                        $.ui.alert(ret.msg);
                    }
                }
            })
        };
        var getNewGifts = function(page) {
            if(page == ‘...‘)return;
            trans.picShow.request({
                ‘page‘ : page,
                ‘oid‘ : userid.value
            });

        };
        var sentActive = function() {

            var inputefuid = $.sizzle(‘[node-type="userfuid"]‘,node)[0];
            var inputeid = $.sizzle(‘[node-type="userid"]‘,node)[0];
            var inputegid = $.sizzle(‘[node-type="usergid"]‘,node)[0];
            var inputedellist = $.sizzle(‘[node-type="dellist"]‘,node)[0];
            //if(inputefuid.value && inputegid.value) {
                trans.profShow.request({
                    ‘fuid‘ : inputefuid.value,
                    ‘tuid‘ : $CONFIG[‘uid‘],
                    ‘id‘ : inputeid.value,
                    ‘gid‘ : inputegid.value,
                    ‘dellist‘ : inputedellist.value
                });

            //}

        };
        var getCurrent = function() {

            if (selected == 1){
                var current = $.sizzle(‘[action-type="point"].cur‘,node)[0];
                selected = 0;
            }else if (selected == 9){
                var current = $.sizzle(‘[action-type="point"].cur‘,node)[0];
                $.removeClassName(current, ‘cur‘);
                current = $.sizzle(‘[action-type="point"]‘,node)[8];
                $.addClassName(current, ‘cur‘);
                selected = 0;
            }else{
                var current = $.sizzle(‘[action-type="point"].cur‘,node)[0];
            }
            var data = current.getAttribute("action-data");
            data = $.queryToJson(data);
            return data;

        };
        var transToShow = function(data) {
            var page;
            var pageDOM = $.sizzle(‘[class="page S_txt1"]‘,node)[0];
            if(pageDOM){
                page = $.queryToJson(pageDOM.getAttribute(‘action-data‘)).page;
            } else {
                page = 1;
            }
            var obj = $.kit.extra.merge({
                page : page
            },data);
            $.listener.fire(‘point‘, ‘scanpoint‘, obj);

        };
        //+++ 参数的验证方法定义区 ++++++++++++++++++
        argsCheck = function() {
            if(!node) {
                throw new Error(‘node没有定义‘);
            }
        };
        //-------------------------------------------

        //+++ Dom的获取方法定义区 ++++++++++++++++++
        parseDOM = function() {
            //内部dom节点
            _this.DOM = $.kit.dom.parseDOM($.builder(node).list);
            allgifts = $.sizzle(‘[action-type="point"]‘,node);
            length = allgifts.length;
            giftpage = _this.DOM[‘gift_page‘].value;
        };
        //-------------------------------------------

        //+++ 模块的初始化方法定义区 ++++++++++++++++++
        initPlugins = function() {
            userid = _this.DOM[‘getoid‘];
            //userid = _this.DOM[‘getoid‘];
            //userid = _this.DOM[‘getoid‘];
        };
        //-------------------------------------------

        //+++ DOM事件绑定方法定义区 ++++++++++++++++++
        bindDOM = function() {
            dEvent.add(‘point‘, ‘click‘, _this.DOM_eventFun.changeStyle);
            dEvent.add(‘page‘, ‘click‘, _this.DOM_eventFun.changePage);
        };
        //-------------------------------------------

        //+++ 自定义事件绑定方法定义区 ++++++++++++++++++
        bindCustEvt = function() {
        };
        //-------------------------------------------

        //+++ 广播事件绑定方法定义区 ++++++++++++++++++
        bindListener = function() {
            $.listener.register(‘scan‘, ‘pre‘, function() {
                return _this.DOM_eventFun.lastPic();
            });
            $.listener.register(‘scan‘, ‘next‘, function() {
                return _this.DOM_eventFun.nextPic();
            });
            $.listener.register(‘scan‘, ‘del‘ ,function(data) {
                if(data.page == 0){
                    window.location.reload();
                } else {
                    getNewGifts(data.page);
                }
            });
        };
        //-------------------------------------------

        //+++ 组件销毁方法的定义区 ++++++++++++++++++
        destroy = function() {
            if(_this) {

                $.foreach(_this.objs, function(o) {
                    if(o.destroy) {
                        o.destroy();
                    }
                });
                _this = null;
            }
            dEvent.remove(‘point‘,‘click‘);
            dEvent.remove(‘page‘,‘click‘);
            $.listener.remove(‘scan‘,‘pre‘);
            $.listener.remove(‘scan‘,‘next‘);
        };
        //-------------------------------------------

        //+++ 组件的初始化方法定义区 ++++++++++++++++++
        init = function() {
            argsCheck();
            parseDOM();
            initPlugins();
            bindDOM();
            sentActive();
            bindCustEvt();
            bindListener();
        };
        //-------------------------------------------
        //+++ 执行初始化 ++++++++++++++++++
        init();
        //-------------------------------------------

        //+++ 组件公开属性或方法的赋值区 ++++++++++++++++++
        that.destroy = destroy;

        //-------------------------------------------

        return that;
    };

});
View Code
技术分享
/**
 * 礼物操作
 * @id $.pl.gift.nav.source.sent
 * @param {Object} node 组件最外节点
 * @return {Object} 实例
 * @author gaohan5@staff.sina.com.cn
 * @data 2012.10.26
 *
 */
$Import(‘kit.dom.parseDOM‘);
$Import(‘common.dialog.sendGift‘);
$Import(‘kit.extra.language‘);
STK.register(‘pl.gift.empty.source.sendGift‘, function($) {

    //+++ 常量定义区 ++++++++++++++++++
    var sendGiftDia = $.common.dialog.sendGift;
    var L = $.kit.extra.language;
    //-------------------------------------------

    return function(node) {
        var argsCheck, parseDOM, initPlugins, bindDOM, bindCustEvt, bindListener, destroy, init, that = {};
        var giftShowNormal;
        //+++ 变量定义区 ++++++++++++++++++
        var fullTpl;
        var _this = {
            DOM : {}, //节点容器
            objs : {}, //组件容器
            DOM_eventFun : {//DOM事件行为容器
                ‘clickPresentfn‘ : function () {//送礼
                    if(giftShowNormal.value == 1) {
                        var el = _this.DOM[‘present‘], user = {};
                        if(el && el.getAttribute(‘data‘)){//如果是来访者,将主人默认选中
                            user = $.queryToJson(el.getAttribute(‘data‘));
                            user = {
                                users : [{‘screen_name‘ : user.oname, ‘uid‘ : user.oid}]
                            };
                        }
                        sendGiftDia(fullTpl).show(user);
                    } else if( giftShowNormal.value == 0) {
                        $.ui.alert(L(‘#L{当前系统繁忙,稍等一下再来看看哦!}‘));
                    }
                }
            }
        };
        //----------------------------------------------

        //+++ 参数的验证方法定义区 ++++++++++++++++++
        argsCheck = function() {
            if (!node) {
                throw new Error(‘[pl.gift.empty.source.sendGift] node没有定义‘);
            }
        };
        //-------------------------------------------

        //+++ Dom的获取方法定义区 ++++++++++++++++++
        parseDOM = function() {
            //内部dom节点
            _this.DOM = $.kit.dom.parseDOM($.builder(node).list);
            fullTpl = $.E(‘full‘) && $.E(‘full‘).innerHTML;
            giftShowNormal = $.sizzle(‘[node-type="gift_show_normal"]‘,$.E(‘plc_layer‘))[0];
        };
        //-------------------------------------------

        //+++ 模块的初始化方法定义区 ++++++++++++++++++
        initPlugins = function() {
        };
        //-------------------------------------------

        //+++ DOM事件绑定方法定义区 ++++++++++++++++++
        bindDOM = function() {
            _this.DOM[‘present‘] && $.addEvent(_this.DOM[‘present‘],‘click‘,_this.DOM_eventFun.clickPresentfn);
        };
        //-------------------------------------------

        //+++ 自定义事件绑定方法定义区 ++++++++++++++++++
        bindCustEvt = function() {
        };
        //-------------------------------------------

        //+++ 广播事件绑定方法定义区 ++++++++++++++++++
        bindListener = function() {
            
        };
        //-------------------------------------------

        //+++ 组件销毁方法的定义区 ++++++++++++++++++
        destroy = function() {
            _this.DOM[‘present‘] && $.removeEvent(_this.DOM[‘present‘], _this.DOM_eventFun.clickPresentfn, ‘click‘);
            sendDia && sendDia.destroy && sendDia.destroy();
            if (_this) {
                $.foreach(_this.objs, function(o) {
                    if (o.destroy) {
                        o.destroy();
                    }
                });
                _this = null;
            }
        };
        //-------------------------------------------

        //+++ 组件的初始化方法定义区 ++++++++++++++++++
        init = function() {
            argsCheck();
            parseDOM();
            initPlugins();
            bindDOM();
            bindCustEvt();
            bindListener();
        };
        //-------------------------------------------
        //+++ 执行初始化 ++++++++++++++++++
        init();
        //-------------------------------------------

        //+++ 组件公开属性或方法的赋值区 ++++++++++++++++++
        that.destroy = destroy;

        //-------------------------------------------

        return that;
    };

});
View Code
技术分享
/**
 * 礼物操作
 * @id $.pl.gift.nav.source.sent
 * @param {Object} node 组件最外节点
 * @return {Object} 实例
 * @author gaohan5@staff.sina.com.cn
 * @data 2012.10.26
 *
 */
$Import(‘kit.dom.parseDOM‘);
$Import(‘kit.extra.parseURL‘);
$Import(‘common.dialog.sendGift‘);
$Import(‘ui.alert‘);
$Import(‘kit.extra.language‘);
STK.register(‘pl.gift.nav.source.sent‘, function($) {

    //+++ 常量定义区 ++++++++++++++++++
    //var sendDia;
    var sendGiftDia = $.common.dialog.sendGift;
    var L = $.kit.extra.language;
    //-------------------------------------------

    return function(node) {
        var argsCheck, parseDOM, initPlugins, bindDOM, bindCustEvt, bindListener, destroy, init, that = {};
        var fullTpl;
        var giftShowNormal;

        //+++ 变量定义区 ++++++++++++++++++
        var _this = {
            DOM : {}, //节点容器
            objs : {}, //组件容器

            DOM_eventFun : {//DOM事件行为容器
                alertSent : function() {
                    if(giftShowNormal.value == 1) {
                        var el = _this.DOM[‘present‘], user = {};
                        if(el && el.getAttribute(‘data‘)){//如果是来访者,将主人默认选中
                            user = $.queryToJson(el.getAttribute(‘data‘));
                            user = {
                                users : [{‘screen_name‘ : user.oname, ‘uid‘ : user.oid}]
                            };
                        }
                        sendGiftDia(fullTpl).show(user);
                    } else if( giftShowNormal.value == 0) {
                        $.ui.alert(L(‘#L{当前系统繁忙,稍等一下再来看看哦!}‘));
                    }
                    
                }
            }

        };
        //----------------------------------------------

        //+++ 参数的验证方法定义区 ++++++++++++++++++
        argsCheck = function() {
            if(!node) {
                throw new Error(‘node没有定义‘);
            }
        };
        //-------------------------------------------

        //+++ Dom的获取方法定义区 ++++++++++++++++++
        parseDOM = function() {
            //内部dom节点
            _this.DOM = $.kit.dom.parseDOM($.builder(node).list);
            fullTpl = $.E(‘full‘) && $.E(‘full‘).innerHTML;
            giftShowNormal = $.sizzle(‘[node-type="gift_show_normal"]‘,$.E(‘plc_layer‘))[0];
        };
        //-------------------------------------------

        //+++ 模块的初始化方法定义区 ++++++++++++++++++
        initPlugins = function() {
            if(_this.DOM[‘showid‘] && _this.DOM[‘showid‘].value == 1) {
                _this.DOM_eventFun.alertSent();
            }
        };
        //-------------------------------------------

        //+++ DOM事件绑定方法定义区 ++++++++++++++++++
        bindDOM = function() {
            $.addEvent(_this.DOM[‘present‘], ‘click‘, _this.DOM_eventFun.alertSent);
        };
        //-------------------------------------------

        //+++ 自定义事件绑定方法定义区 ++++++++++++++++++
        bindCustEvt = function() {
        };
        //-------------------------------------------

        //+++ 广播事件绑定方法定义区 ++++++++++++++++++
        bindListener = function() {
            $.listener.register(‘point‘, ‘giftcount‘, function(giftcount) {
            
                _this.DOM[‘giftcount‘].innerHTML = ‘(共‘+ giftcount + ‘件)‘;
                
            });
        };
        //-------------------------------------------

        //+++ 组件销毁方法的定义区 ++++++++++++++++++
        destroy = function() {
            sendDia && sendDia.destroy && sendDia.destroy();
            if(_this) {

                $.foreach(_this.objs, function(o) {
                    if(o.destroy) {
                        o.destroy();
                    }
                });
                _this = null;
            }
            $.listener.remove(‘point‘,‘giftcount‘);
        };
        //-------------------------------------------

        //+++ 组件的初始化方法定义区 ++++++++++++++++++
        init = function() {
            argsCheck();
            parseDOM();
            initPlugins();
            bindDOM();
            bindCustEvt();
            bindListener();
        };
        //-------------------------------------------
        //+++ 执行初始化 ++++++++++++++++++
        init();
        //-------------------------------------------

        //+++ 组件公开属性或方法的赋值区 ++++++++++++++++++
        that.destroy = destroy;

        //-------------------------------------------

        return that;
    };

});
View Code

会员--圣诞节

技术分享
/**
 *
 * @id comp.chrisEvent.lottery
 * @param {Object} node 组件最外节点
 * @return {Object} 实例
 * @author gaohan5@staff.sina.com.cn
 * @example
 *
 */
$Import(‘common.channel.christmas‘);
$Import(‘common.extra.timeCountDown‘);
$Import(‘common.trans.christmas‘);
$Import(‘common.dialog.publish‘);
$Import(‘kit.extra.swfobject‘);
$Import(‘kit.dom.parseDOM‘);
$Import(‘kit.extra.language‘);
$Import(‘ui.confirm‘);
$Import(‘ui.alert‘);
STK.register(‘comp.chrisEvent.lottery‘, function($) {

    //+++ 常量定义区 ++++++++++++++++++
    //-------------------------------------------

    return function(node) {
        var argsCheck, parseDOM, initPlugins, bindDOM, bindCustEvt, bindListener, destroy, init, that = {};
        var lang = $.kit.extra.language;
        var publish = $.common.dialog.publish;
        var getTrans = $.common.trans.christmas.getTrans;
        var isWin, count, level, name, argslevel, isWin_al, finish;
        var canClick = 1, run = 1;
        
        /*
         canClick 为1时按钮可点 为0时按钮不可点
         run run为1时转盘是停止转动状态  为0时转盘是转动状态
         * */
        //+++ 变量定义区 ++++++++++++++++++
        var _this = {
            DOM : {}, //节点容器
            objs : {}, //组件容器
            DOM_eventFun : {//DOM事件行为容器
            }
        };

        //----------------------------------------------

        //+++ 参数的验证方法定义区 ++++++++++++++++++
        argsCheck = function() {
            if(!node) {
                throw new Error(‘node没有定义‘);
            }
        };
        //-------------------------------------------

        //+++ Dom的获取方法定义区 ++++++++++++++++++
        parseDOM = function() {
            //内部dom节点
            _this.DOM = $.kit.dom.parseDOM($.builder(node).list);
        };
        //-------------------------------------------

        //+++ 模块的初始化方法定义区 ++++++++++++++++++
        initPlugins = function() {
            //var dia = $.comp.chrisEvent.share();
            var FLASH_VERSION = $.kit.extra.swfobject.getFlashPlayerVersion(); 
            if(FLASH_VERSION && FLASH_VERSION[‘major‘]<10){
                $.core.dom.setStyle(_this.DOM["lottery"],‘background‘,‘white‘);
                _this.DOM["lottery"].innerHTML = ‘<p  style="text-align:center;padding-top:50px;" class="noflash" >‘+lang(‘#L{抱歉,您当前Flash版本过低,<a href="http://get.adobe.com/cn/flashplayer/">请升级后再试</a></p>}‘)
                timeCount();
                return;
            }


            //$.kit.extra.swfobject.embedSWF();

            var obj = $.core.util.swf.create(_this.DOM["lottery"], "http://js.t.sinajs.cn/t4/apps/vip/static/comingsoon/SignInWheel.swf", {
                ‘width‘ : 290,
                ‘height‘ : 290,
                ‘id‘ : "swf_2463",
                ‘paras‘ : {
                    "wmode" : "transparent",
                    "allowScriptAccess" : "always"
                },
                ‘flashvars‘ : {
                    ‘js_handler‘ : "STK.common.channel.christmas.fire", //全局的句柄
                    ‘channel‘ : "swf", //频道
                    ‘init_fun‘ : "initFinish", //          //flash初始化完成时回调
                    ‘getaward‘ : "getAward", //通知js取数据时,调用
                    ‘finish_fun‘ : "playFinish"  //转盘转动结束时,通知js调用

                }
            });
            timeCount();
        };
        //-------------------------------------------
        
        var timeCount = function(){
            $.common.extra.timeCountDown(_this.DOM, {
                sec : true,
                endFn:function(){
                    $.E(‘endtime‘) && ($.E(‘endtime‘).value = ‘0‘);
                    $.common.channel.christmas.fire(‘gameover‘);
                }
            });
        }
        
        var noticeCount = function() {
            $.common.channel.christmas.fire(‘lotteryCount‘);
        }
        var getFlash = function() {
            return document.getElementById("swf_2463");
        };
        var setButton = function(num) {
            var flash = getFlash();
            if(num == 0) {
                //canClick = 0;
                flash && flash.btnEnable(false);//按钮变灰
            } else {
                //canClick = 1;
                flash && flash.btnEnable(true);//按钮变亮
            }
        }
        //-------------------------------------------

        var flashFuncs = {
            initFinish : function() {
                //当活动结束后,转盘按钮置灰
                if($.E(‘endtime‘).value != 1) {
                    setButton(0);
                    canClick = 0;
                }
                if(_this.DOM.finish.value == 1) {
                    setButton(0);
                    canClick = 1;
                    return;
                }
                if(_this.DOM.is_take.value == 1) {
                    setButton(0);
                    canClick = 1;
                    return;
                }
                if(_this.DOM.gameover && (_this.DOM.gameover.value == 1)) {
                    setButton(0);
                    canClick = 1;
                    return;
                }
            },
            getAward : function() {
                if(canClick == 0){
                    return;
                }
                //当前用户没有袜子
                if(_this.DOM.is_take.value == 1) {
                    $.ui.alert("你还没有抽奖机会 快去收集袜子来抽奖吧!", {
                        ‘title‘ : ‘抽奖结果‘,
                        ‘icon‘ : ‘warn‘,
                        ‘OKText‘ : ‘现在就去‘,
                        ‘OK‘:function(){
                            $.core.util.scrollTo($.E(‘pl_chrisEvent_profile‘));
                        }
                    });
                    //setButton(0);
                    return;
                }
                //游戏结束
                if(_this.DOM.gameover && (_this.DOM.gameover.value == 1)) {
                    $.ui.alert("你今天已经抽了很多次了,不能再抽了,明天再来吧!", {
                        ‘title‘ : ‘抽奖结果‘,
                        ‘icon‘ : ‘warn‘,
                        ‘textSmall‘ : ‘你还有0次抽奖机会‘,
                        ‘OKText‘ : ‘确定‘
                    });
                    //setButton(0);
                    return;
                }
                //当用户用完了抽奖机会 且没有刷页情况下
                if(count == 0) {
                    $.ui.alert("你没有抽奖机会了,快去收集更多袜子,再来抽奖吧!", {
                        ‘title‘ : ‘抽奖结果‘,
                        ‘icon‘ : ‘warn‘,
                        ‘textSmall‘ : ‘你还有0次抽奖机会‘,
                        ‘OKText‘ : ‘现在就去‘,
                        ‘OK‘:function(){
                            $.core.util.scrollTo($.E(‘pl_chrisEvent_profile‘));
                        }
                    });
                    //setButton(0);
                    return;
                }
                //当用户用完抽奖机会 刷页后
                if(_this.DOM.finish.value == 1) {
                    $.ui.alert("你没有抽奖机会了,快去收集更多袜子,再来抽奖吧!", {
                        ‘title‘ : ‘抽奖结果‘,
                        ‘icon‘ : ‘warn‘,
                        ‘textSmall‘ : ‘你还有0次抽奖机会‘,
                        ‘OKText‘ : ‘现在就去‘,
                        ‘OK‘:function(){
                            $.core.util.scrollTo($.E(‘pl_chrisEvent_profile‘));
                        }
                    });
                    //setButton(0);
                    return;
                }
                //正常的简单抽奖
                if(run == 1) {
                    run = 0;
                    var flash = getFlash();
                    setButton(0);
                    canClick = 0;
                    getTrans("chrisStatus", {
                        "onSuccess" : function(ret, para) {
                            
                            count = ret.data.count;
                            isWin = ret.data.isWin;
                            level = ret.data.level;
                            name = ret.data.name;

                            if(isWin == null || isWin == undefined){
                                $.ui.alert(lang("#L{服务器繁忙,请重试}"), {
                                    ‘OK‘ : function() {
                                        window.location.reload();
                                    }
                                });
                                return;
                            }

                            flash.startPlay({
                                "is_win" : isWin,
                                "level" : level
                            });
                            
                            noticeCount();
                        },
                        "onError" : function(ret, para) {
                            $.ui.alert(ret.msg || lang("#L{服务器繁忙,请稍后再试}"), {
                                ‘OK‘ : function() {
                                    window.location.reload();
                                }
                            });
                        }
                    }).request({
                        ‘action‘ : "christmas_prize"
                    });
                }
            },
            playFinish : function() {
                    run = 1;
                    if(count != 0){
                        setTimeout(function(){
                            setButton(1);
                            canClick = 1;
                        },1000);
                    }
                    if(count == 0){
                        setTimeout(function(){
                            canClick = 1;
                        },1000);
                    }
                    argslevel = level;
                    if(isWin == 0) {
                        $.ui.alert("你没有抽中礼物,攒攒手气再试一次吧!", {
                            ‘title‘ : ‘抽奖结果‘,
                            ‘icon‘ : ‘warn‘,
                            ‘textSmall‘ : ‘你还有‘ + count + ‘次抽奖机会‘,
                            ‘OKText‘ : ‘确定‘
                        });
                    } else {
                        $.ui.confirm("恭喜你中奖啦,抽到了" + name, {
                            ‘title‘ : ‘抽奖结果‘,
                            ‘icon‘ : ‘success‘,
                            ‘textSmall‘ : ‘你还有‘ + count + ‘次抽奖机会‘,
                            ‘OK‘ : function() {
                                $.common.dialog.pubwithface({
                                    ‘level‘ : level,
                                    ‘argslevel‘ : argslevel,
                                    ‘name‘ : name,
                                    ‘lottery‘ : true
                                }).show();
                            },
                            ‘OKText‘ : lang(‘#L{分享给好友}‘),
                            ‘cancelText‘ : lang(‘#L{继续抽奖}‘),
                            ‘cancel‘ : function() {
                                $.ui.confirm(lang("请完善你的抽奖地址,以便奖品寄送给你"), {
                                    ‘title‘ : lang(‘#L{完善地址}‘),
                                    ‘icon‘ : ‘warn‘,
                                    ‘textSmall‘ : lang(‘温馨提示:你也可以在中奖公告下方填写收货地址‘),
                                    ‘OK‘ : function() {
                                        window.open("http://account.weibo.com/set/address");
                                        dialog.hide();
                                    },
                                    ‘OKText‘ : lang(‘#L{现在就去}‘)
                                })
                            }
                        });
                    }

                    isWin = 0;
                    level = 0;
                
            }
        };
        //+++ DOM事件绑定方法定义区 ++++++++++++++++++
        bindDOM = function() {

        };
        //-------------------------------------------

        //+++ 自定义事件绑定方法定义区 ++++++++++++++++++
        bindCustEvt = function() {

        };
        //+++ 广播事件绑定方法定义区 ++++++++++++++++++
        bindListener = function() {
            $.common.channel.christmas.register("swf", function(oData) {
                oData = oData || {};
                //获取执行的指令
                var action = oData.action;
                //调用的参数
                var args = oData.args;
                if(!action) {
                    return;
                }
                args = args || [];
                //派发到执行函数执行
                var hashMap = flashFuncs;
                hashMap[action] && hashMap[action].apply(window, args);
            });
        };
        //-------------------------------------------

        //+++ 组件销毁方法的定义区 ++++++++++++++++++
        destroy = function() {
            if(_this) {

                $.foreach(_this.objs, function(o) {
                    if(o.destroy) {
                        o.destroy();
                    }
                });
                _this = null;
            }
        };
        //-------------------------------------------

        //+++ 组件的初始化方法定义区 ++++++++++++++++++
        init = function() {
            argsCheck();
            parseDOM();
            initPlugins();
            bindDOM();
            bindCustEvt();
            bindListener();
        };
        //-------------------------------------------
        //+++ 执行初始化 ++++++++++++++++++
        init();
        //-------------------------------------------
        //window.startPlay = startPlay;
        //+++ 组件公开属性或方法的赋值区 ++++++++++++++++++
        that.destroy = destroy;

        //-------------------------------------------

        return that;
    };
}); 
View Code
技术分享
/**
 *2012圣诞节——参与人数动画
 * @id $.comp.chrisEvent.counter
 * @created 2012.12.05
 * @author Wang Lingfei | @mayloveless
 * 
 * 2012.12.21 给新增分享按钮绑定分享发布器弹层 modified by gaohan ||gaohan5
 * $.addEvent(domList[‘shareActivity‘], ‘click‘, shareActivity);
 */
$Import(‘kit.dom.parseDOM‘);
$Import(‘kit.extra.language‘);
//通用组件
$Import(‘common.extra.timeCountDown‘);
$Import(‘common.dialog.pubwithface‘);
STK.register(‘comp.chrisEvent.counter‘, function($) {
    
    //静态及指针变量声明区
    var $L = $.kit.extra.language;

    return function(node) {
        //函数外抛句柄
        var it = {};
        //本作用域变量声明区
        var domList,questTimer,node,popNum,delayInit;
        //循环请求的两个数据,此页面暂不需要
        var questDelay  = 8000;
        var step = parseInt(100*Math.random());
        //此数组规定不同数字转动的时间不同,即记录需循环多少次0~9
        var quakeTime = [];
        //结果值
        var endNum= [];
        var $pubwithface = $.common.dialog.pubwithface;
        
        //出数动画:变动次数为节点数X 10XquakeTime
        var quake = function(list,order,curNum){
            if(!quakeTime[order]){
                return;
            }
            var quakeTimer = setTimeout(function(){
                if(curNum === 10&&quakeTime[order] ===1){
                    list.innerHTML = endNum[order];
                    window.clearTimeout(quakeTimer);
                    quakeTimer  = null ;
                    return;
                }else if(curNum===10){
                    curNum = 0;
                    quakeTime[order] = quakeTime[order]-1;
                }
                list.innerHTML = curNum;
                quake(list,order,++curNum);
            },10);
        };
        
        
        var aniNum = function(node,num){
                var realNum = num.split(‘‘);
                //如何需要显示的值大于现有节点,增加一个i节点
                if(node.length< realNum.length){
                    //超过最大长度,不再增加
                    if(node.length ===9){
                        window.clearInterval(questTimer);
                        return false;
                    }
                    var carry  = $.C(‘i‘);
                    $.core.dom.insertElement(domList[‘pop‘],carry,‘afterbegin‘);
                    //更新全局的i节点集合
                    popNodes = $.sizzle(‘i‘,domList[‘pop‘]);
                    node = popNodes;
                }
                //把结果值存到endNum中
                for(var m=node.length-1,n = realNum.length-1;m>=0;m--){
                        if(n<0){
                            endNum[m] = 0;    
                        }else{
                            endNum[m] =  realNum[n];
                            n--;
                        }
                }
                
                //计算有变化的位置
                var curNum = ‘‘;
                $.core.arr.foreach(node,function(n,html){
                     curNum +=n.innerHTML; 
                });
                var curNumArr = curNum.split(‘‘);
                //给quakeTime数组赋值,执行出数动画
                for(var i=0;i<node.length;i++){
                    //没变化的值不做动画
                    if(parseInt(endNum[i],10) === parseInt(curNumArr[i],10)){
                        quakeTime[i] = 0;
                    }else{
                        quakeTime[i] =i*2+5;
                    }
                    quake(node[i],i,0);
                };
        };
        
        //不做动画效果,直接插入
        var staticNum = function(node,num){
            var realNum = num.split(‘‘);
            var differ = realNum.length - node.length;
            //对其真实数字和显示数字长度
            //如果真实数字长,创建节点
            //如果真实数字端,向数组补0对其(从前面增加)
            if(differ > 0){
                for(var i=0;i<differ;i++){
                    var carry  = $.C(‘i‘);
                    carry.innerHTML = 0;
                    $.core.dom.insertElement(domList[‘pop‘],carry,‘afterbegin‘);
                }
                node = $.sizzle(‘i‘,domList[‘pop‘]);
            }else{
                for(var i=0;i<(0-differ);i++){
                    realNum.unshift(0);
                }
            }
            for(var j=node.length-1;j>=0;j--){
                if(realNum[j]){
                    node[j].innerHTML = realNum[j];
                }
            }

        };
        var shareActivity = function(){
            $pubwithface({‘lottery‘:false,‘brash‘:false}).show();
        };
        
        //默认函数
        var handler = {
            init: function(){
                //构造组件,模板及复用业务组件初始化
                handler.build();
                //本函数体内部时间绑定
                handler.bind();
            },
            build: function(){
                if (!node) {
                    throw new Error(‘comp.chrisEvent.counter [ERROR]:node没有定义‘);
                }
                
                domList =$.kit.dom.parseDOM($.builder(node).list);
            //    $.common.extra.timeCountDown(domList,{
            //        sec : false
            //    });
                popNodes = $.sizzle(‘i‘,domList[‘pop‘]);
                popNum =  domList[‘pop‘].getAttribute(‘node-data‘);        
                
                //IE下动画慢,延时1s处理
                if($.core.util.browser.IE7 || $.core.util.browser.IE6 || $.core.util.browser.IE8){
                    delayInit= setTimeout(function(){
                        aniNum(popNodes,popNum);
                    },1000);
                }else{
                        aniNum(popNodes,popNum);
                }
                /*//循环请求需要的动作
                questTimer  = setInterval(function(){
                                    //queryPop();
                                    popNum = ‘‘+(parseInt(popNum,10)+step);
                                    aniNum(popNodes,popNum);
                                },questDelay);*/
                
                
            },
            bind: function(){
                $.addEvent(domList[‘shareActivity‘], ‘click‘, shareActivity);
            },
            destroy: function(){
                    if(delayInit){
                        window.clearTimeout(delayInit);
                    }
                    window.clearInterval(questTimer);
            }
        };
        //启动函数
        handler.init();
        //外抛句柄
        it.destroy = handler.destroy;
        return it;
    };
});
View Code

会员--升级(接到的第一个需求,看着自己的代码跑在线上并且那么多人用,当天晚上就失眠了,觉得就算有一天离开了也不枉来过,后来走后觉得来了跟没来,,还是有点区别的PS:不要太爱上做着的东西)

技术分享
$Import(‘kit.dom.parseDOM‘);
$Import(‘ui.alert_V5‘);
$Import(‘kit.extra.language‘);
$Import(‘common.trans.upgrade‘);
STK.register(‘comp.upgrade.upgradeV5‘, function($) {
    //+++ 常量定义区 ++++++++++++++++++
    //-------------------------------------------

    return function(node) {
        var argsCheck, parseDOM, initPlugins, bindDOM, bindCustEvt, bindListener, destroy, init, that = {};
        var lang=$.kit.extra.language;
        //+++ 变量定义区 ++++++++++++++++++
        var _this ={
            DOM: {},//节点容器
            objs: {},//组件容器
            DOM_eventFun: {//DOM事件行为容器
                ‘upgrade‘: function() {
                        $.common.trans.upgrade.getTrans("upgrade", {
                             "onSuccess" : function(ret) {
                                window.location.href=ret.data.url;
                             },
                            "onError" : function(ret) {
                                $.ui.alert_V5(ret.msg, {
                                    ‘title‘ : lang(‘#L{提示信息}‘),
                                    ‘icon‘ : ‘success‘
                                });
                            }
                        }).request();
                }
            }

            //属性方法区

        };
        //----------------------------------------------

        //+++ 参数的验证方法定义区 ++++++++++++++++++
        argsCheck = function() {

            if(!node) {
                throw new Error(‘node没有定义‘);
            }
            
        };
        //-------------------------------------------

        //+++ Dom的获取方法定义区 ++++++++++++++++++
        parseDOM = function() {
            //内部dom节点
            _this.DOM = $.kit.dom.parseDOM($.builder(node).list);
            if(!1) {
                throw new Error(‘必需的节点 不存在‘);
            }
        };
        //-------------------------------------------

        //+++ 模块的初始化方法定义区 ++++++++++++++++++
        initPlugins = function() {

        };
        //-------------------------------------------

        //+++ DOM事件绑定方法定义区 ++++++++++++++++++
        bindDOM = function() {
            if (_this.DOM.upgrade){
            $.addEvent(_this.DOM.upgrade,"click",_this.DOM_eventFun.upgrade);
            }
        };
        //-------------------------------------------

        //+++ 自定义事件绑定方法定义区 ++++++++++++++++++
        bindCustEvt = function() {
            
        };
        //-------------------------------------------

        //+++ 广播事件绑定方法定义区 ++++++++++++++++++
        bindListener = function() {
            //console.log(2);
            //$.common.channel.verify2.register("shijian1", function() {
                //$.common.channel.verify2.fire("shijian1",id=1);
                //console.log(2);
                //alert(1);
            //});
        };
        //-------------------------------------------

        //+++ 组件销毁方法的定义区 ++++++++++++++++++
        destroy = function() {
            
        };
        //-------------------------------------------

        //+++ 组件的初始化方法定义区 ++++++++++++++++++
        init = function() {
            argsCheck();
            parseDOM();    
            initPlugins();        
            bindDOM();
            bindCustEvt();
            bindListener();
        };
        //-------------------------------------------
        //+++ 执行初始化 ++++++++++++++++++
        init();
        //-------------------------------------------

        //+++ 组件公开属性或方法的赋值区 ++++++++++++++++++
        that.destroy = destroy;

        //-------------------------------------------

        return that;
    };
    
});
View Code

会员--微号(对这段毫无印象)

技术分享
/**
 *
 * @id comp.chrisEvent.join
 * @param {Object} node 组件最外节点
 * @return {Object} 实例
 * @author gaohan5@staff.sina.com.cn
 * @example
 *
 */
$Import(‘common.channel.christmas‘);
$Import(‘common.trans.christmas‘);
$Import(‘kit.dom.parseDOM‘);
//$Import(‘comp.chrisEvent.followlist‘);
$Import(‘common.dialog.pubwithface‘);
$Import(‘common.dialog.sendMessage‘);
$Import(‘kit.extra.language‘);
$Import(‘ui.alert‘);
$Import(‘ui.timerNotice‘);
STK.register(‘comp.chrisEvent.join‘, function($) {

    //+++ 常量定义区 ++++++++++++++++++
    //-------------------------------------------

    return function(node) {
        var argsCheck, parseDOM, initPlugins, bindDOM, bindCustEvt, bindListener, destroy, init, that = {};
        var lang=$.kit.extra.language;
        var getTrans = $.common.trans.christmas.getTrans;
        var dEvent = $.core.evt.delegatedEvent(node);
        var fChannel = $.common.channel.christmas;
        //+++ 变量定义区 ++++++++++++++++++
        var _this = {
            DOM: {},//节点容器
            objs: {},//组件容器
            DOM_eventFun: {//DOM事件行为容器
                follow: function(){
                    
                    getTrans("follow",{
                        "onSuccess" : function(ret,para){
                            $.ui.timerNotice(‘关注成功‘,{
                                ‘icon‘ : ‘success‘,
                                ‘timer‘:1000,
                                ‘OK‘:function(){
                                    $.common.dialog.pubwithface({‘lottery‘:false,‘brash‘:true}).show();
                                }
                            })
                            //setTimeout(function(){$.common.dialog.pubwithface({‘lottery‘:false,‘brash‘:true}).show();},1000)
                        },
                        "onError" : function(ret,para){
                            $.ui.alert(ret.msg || lang("#L{服务器繁忙,请稍后再试}"));
                        }
                    }).request({
                        ‘handle_type‘ : ‘christ‘
                        //‘uid‘ :  [2715025067,2101488560]
                    });
                },
                openYearOn:function(){
                    $.ui.alert(lang("请在新开支付中心页面完成续费会员,成功续费即获得圣诞袜"),{
                        ‘title‘ : lang("续费会员"),
                        ‘textSmall‘ : ‘续费失败:<a target=_blank href="http://help.weibo.com/faq/q/1564">查看支付帮助</a>‘,
                        ‘OK‘ : function(){
                                window.location.reload();
                            },
                        ‘OKText‘ :"续费成功"
                    })
                },
                openVipYear :function(){
                    $.ui.alert("请在新开支付中心页面完成开通会员,成功开通即获得圣诞袜",{
                        ‘title‘ : "开通会员",
                        ‘textSmall‘ : ‘开通失败:<a target=_blank href="http://help.weibo.com/faq/q/1564">查看支付帮助</a>‘,
                        ‘OK‘ : function(){
                                window.location.reload();
                            },
                        ‘OKText‘ :"开通成功"
                    })
                },
                openVip :function(){
                    $.ui.alert("请在新开支付中心页面完成开通会员,成功开通即获得圣诞袜",{
                        ‘title‘ : "开通会员",
                        ‘textSmall‘ : ‘开通失败:<a target=_blank href="http://help.weibo.com/faq/q/1564">查看支付帮助</a>‘,
                        ‘OK‘ : function(){
                                window.location.reload();
                            },
                        ‘OKText‘ :"开通成功"
                    })
                },
                buyNum :function(){
                    //购买微号儿提示弹层
                    $.ui.alert("请在新开微号商城页面挑选微号,成功挑选付费微号即获得圣诞袜",{
                        ‘title‘ : lang(‘#L{挑选微号}‘),
                        ‘textSmall‘ : ‘挑选失败:<a target=_blank href="http://help.weibo.com/topic/hao">查看微号帮助</a>‘,
                        ‘OKText‘ : lang(‘#L{挑选成功}‘),
                        ‘OK‘:function(){window.location.reload();}
                    });
                },
                buyLoveNum:function(){
                    $.ui.alert("请在新开微号商城页面挑选微号,成功挑选付费微号即获得圣诞袜",{
                            ‘title‘ : lang(‘#L{挑选微号}‘),
                            ‘textSmall‘ : ‘挑选失败:<a target=_blank href="http://help.weibo.com/topic/hao">查看微号帮助</a>‘,
                            ‘OKText‘ : lang(‘#L{挑选成功}‘),
                            ‘OK‘:function(){window.location.reload();}
                        });
                },
                sendMessage:function(){
                    $.common.dialog.sendMessage().show();
                },
                copy :function(){
                    var contentCopy = _this.DOM["firstlink"].innerHTML;
                    if (STK.core.util.browser.IE == true){
                        window.clipboardData.setData("Text", contentCopy); 
                        $.ui.alert("复制成功",{‘textSmall‘ : ‘链接信息:‘+contentCopy,icon:"success"});
                    }else{
                        $.ui.alert("你当前浏览器不支持,请手动复制",{‘textSmall‘ : ‘链接信息:‘+contentCopy,icon:"warn"});
                    };
                }
            }
        };
        
        var removeEventBind = function(){
            $.removeEvent(_this.DOM[‘follow‘],_this.DOM_eventFun.follow,‘click‘);
            $.removeEvent(_this.DOM[‘openVip‘], _this.DOM_eventFun.openVip, ‘click‘);
            $.removeEvent(_this.DOM[‘openVipYear‘], _this.DOM_eventFun.openVipYear, ‘click‘);
            $.removeEvent(_this.DOM[‘openYearOn‘], _this.DOM_eventFun.openYearOn, ‘click‘);
            $.removeEvent(_this.DOM[‘buyNum‘][0], _this.DOM_eventFun.buyNum, ‘click‘);
            $.removeEvent(_this.DOM[‘buyNum‘][1], _this.DOM_eventFun.buyLoveNum, ‘click‘);
            $.removeEvent(_this.DOM[‘sendmessage‘], _this.DOM_eventFun.sendMessage, ‘click‘);
            $.removeEvent(_this.DOM[‘invite‘], _this.DOM_eventFun.sendMessage, ‘click‘);
            $.removeEvent(_this.DOM[‘copy‘], _this.DOM_eventFun.copy, ‘click‘);
        };
        
        //----------------------------------------------

        //+++ 参数的验证方法定义区 ++++++++++++++++++
        argsCheck = function() {
            if (!node) {
                throw new Error(‘node没有定义‘);
            }
        };
        //-------------------------------------------

        //+++ Dom的获取方法定义区 ++++++++++++++++++
        parseDOM = function() {
            //内部dom节点
            _this.DOM = $.kit.dom.parseDOM($.builder(node).list);
        };
        //-------------------------------------------

        //+++ 模块的初始化方法定义区 ++++++++++++++++++
        initPlugins = function() {
        };
        //-------------------------------------------

        //+++ DOM事件绑定方法定义区 ++++++++++++++++++
        bindDOM = function() {
            if($.E(‘endtime‘) && $.E(‘endtime‘).value == ‘0‘){
                return;
            }
            $.addEvent(_this.DOM[‘follow‘], ‘click‘, _this.DOM_eventFun.follow);
            $.addEvent(_this.DOM[‘openVip‘], ‘click‘, _this.DOM_eventFun.openVip);
            $.addEvent(_this.DOM[‘openVipYear‘], ‘click‘, _this.DOM_eventFun.openVipYear);
            $.addEvent(_this.DOM[‘openYearOn‘], ‘click‘, _this.DOM_eventFun.openYearOn);
            if (_this.DOM[‘numdo‘].value==2){
                $.addEvent(_this.DOM[‘buyNum‘][0], ‘click‘, _this.DOM_eventFun.buyNum);
                $.addEvent(_this.DOM[‘buyNum‘][1], ‘click‘, _this.DOM_eventFun.buyLoveNum);
            }else{
                $.addEvent(_this.DOM[‘buyNum‘], ‘click‘, _this.DOM_eventFun.buyNum);
            }
            $.addEvent(_this.DOM[‘sendmessage‘], ‘click‘, _this.DOM_eventFun.sendMessage);
            $.addEvent(_this.DOM[‘invite‘], ‘click‘, _this.DOM_eventFun.sendMessage);
            $.addEvent(_this.DOM[‘copy‘], ‘click‘, _this.DOM_eventFun.copy);
        };
        //-------------------------------------------

        //+++ 自定义事件绑定方法定义区 ++++++++++++++++++
        bindCustEvt = function() {

        };
        //-------------------------------------------

        //+++ 广播事件绑定方法定义区 ++++++++++++++++++
        bindListener = function() {
            fChannel.register(‘gameover‘, removeEventBind);
        };
        //-------------------------------------------

        //+++ 组件销毁方法的定义区 ++++++++++++++++++
        destroy = function() {
            removeEventBind();
        };
        //-------------------------------------------

        //+++ 组件的初始化方法定义区 ++++++++++++++++++
        init = function() {
            argsCheck();
            parseDOM();
            initPlugins();
            bindDOM();
            bindCustEvt();
            bindListener();
        };
        //-------------------------------------------
        //+++ 执行初始化 ++++++++++++++++++
        init();
        //-------------------------------------------

        //+++ 组件公开属性或方法的赋值区 ++++++++++++++++++
        that.destroy = destroy;

        //-------------------------------------------

        return that;
    };
});
View Code

认证(第二段线上码)

技术分享
$Import(‘kit.dom.parseDOM‘);
STK.register(‘comp.home.question‘, function($) {
    //+++ 常量定义区 ++++++++++++++++++
    //-------------------------------------------

    return function(node) {
        var argsCheck, parseDOM, initPlugins, bindDOM, bindCustEvt, bindListener, destroy, init, that = {};
        var getStyle = $.core.dom.getStyle;
        var delegate = $.core.evt.delegatedEvent(node);
        var curid = null;
        var quesNode = $.sizzle(‘[action-type="alert"]‘, node);
        var lastNode;

        //+++ 变量定义区 ++++++++++++++++++
        var _this ={
            DOM: {},//节点容器
            objs: {},//组件容器
            DOM_eventFun: {//DOM事件行为容器
                /*
                 * 点击问题,展开问题答案
                 */
                clickQa: function(spec) {
                    lastNode = lastNode || quesNode[0];
                    if($.core.dom.next(spec.el).style.display === ‘none‘) {
                        $.core.dom.next(lastNode).style.display = ‘none‘;
                        $.core.dom.next(spec.el).style.display = ‘‘;
                        lastNode = spec.el;
                    }
                //    var len = quesNode.length;
                    //for (var i = 0; i < len; i+=1){
                        //if(!($.core.dom.next(quesNode[i]) == ‘‘)) {
                            //$.setStyle($.core.dom.next(quesNode[i]), ‘display‘, ‘none‘);
                        //}
                    //}
                    //var as_node = $.core.dom.next(spec.el);//获得当前问题答案节点
                //    $.setStyle(as_node, ‘display‘, ‘block‘);//设置为可见
                    //$.core.util.scrollTo(spec.el, {
                        //step : 10
                    //});
                }
            }

            //属性方法区

        };
        //----------------------------------------------

        //+++ 参数的验证方法定义区 ++++++++++++++++++
        argsCheck = function() {

            if(!node) {
                throw new Error(‘node没有定义‘);
            }

        };
        //-------------------------------------------

        //+++ Dom的获取方法定义区 ++++++++++++++++++
        parseDOM = function() {
            //内部dom节点
            _this.DOM = $.kit.dom.parseDOM($.builder(node).list);
            if(!1) {
                throw new Error(‘必需的节点 不存在‘);
            }
        };
        //-------------------------------------------

        //+++ 模块的初始化方法定义区 ++++++++++++++++++
        initPlugins = function() {

        };
        //-------------------------------------------

        //+++ DOM事件绑定方法定义区 ++++++++++++++++++
        bindDOM = function() {
            delegate.add("alert", "click", _this.DOM_eventFun["clickQa"]);
        };
        //-------------------------------------------

        //+++ 自定义事件绑定方法定义区 ++++++++++++++++++
        bindCustEvt = function() {
            
        };
        //-------------------------------------------

        //+++ 广播事件绑定方法定义区 ++++++++++++++++++
        bindListener = function() {

        };
        //-------------------------------------------

        //+++ 组件销毁方法的定义区 ++++++++++++++++++
        destroy = function() {
            
        };
        //-------------------------------------------

        //+++ 组件的初始化方法定义区 ++++++++++++++++++
        init = function() {
            argsCheck();
            parseDOM();    
            initPlugins();    
            bindDOM();
            bindCustEvt();
            bindListener();
        };
        //-------------------------------------------
        //+++ 执行初始化 ++++++++++++++++++
        init();
        //-------------------------------------------

        //+++ 组件公开属性或方法的赋值区 ++++++++++++++++++
        that.destroy = destroy;

        //-------------------------------------------

        return that;
    };
});
View Code

<!--修修改改就算了也找不见-->

<!--只是当时已惘然-->

{{昨夜雨疏风骤----致那些年码过的码}}

标签:

原文地址:http://www.cnblogs.com/niunaimidou/p/4509092.html

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