Showing
6 changed files
with
570 additions
and
570 deletions
@@ -3556,123 +3556,123 @@ $btnNext.on('touchstart', function() { | @@ -3556,123 +3556,123 @@ $btnNext.on('touchstart', function() { | ||
3556 | 3556 | ||
3557 | }); | 3557 | }); |
3558 | define("js/me/dialog", ["jquery","handlebars","source-map","hammer"], function(require, exports, module){ | 3558 | define("js/me/dialog", ["jquery","handlebars","source-map","hammer"], function(require, exports, module){ |
3559 | -/* | ||
3560 | - * @Description: dialog | ||
3561 | - * @Time: 2015/11/18 | ||
3562 | - * @author: chenglong.wang | ||
3563 | - */ | ||
3564 | - | ||
3565 | -var $ = require("jquery"), | ||
3566 | - Handlebars = require("handlebars"), | ||
3567 | - Hammer = require("hammer"); | ||
3568 | - | ||
3569 | -var $dialogWrapper, | ||
3570 | - dialogTpl, | ||
3571 | - dialogTemplate; | ||
3572 | - | ||
3573 | -function getInstance() { | ||
3574 | - if (dialogTpl === undefined) { | ||
3575 | - dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' + | ||
3576 | - '<div class="dialog-box">' + | ||
3577 | - '{{# hasHeader}}' + | ||
3578 | - '{{/ hasHeader}}' + | ||
3579 | - '<div class="dialog-content">{{dialogText}}</div>' + | ||
3580 | - '{{# hasFooter}}' + | ||
3581 | - '<div class="dialog-footer">' + | ||
3582 | - '{{# leftBtnText}}' + | ||
3583 | - '<span class="dialog-left-btn tap-hightlight">{{.}}</span>' + | ||
3584 | - '{{/ leftBtnText}}' + | ||
3585 | - '{{# rightBtnText}}' + | ||
3586 | - '<span class="dialog-right-btn tap-hightlight">{{.}}</span>' + | ||
3587 | - '{{/ rightBtnText}}' + | ||
3588 | - '</div>' + | ||
3589 | - '{{/ hasFooter}}' + | ||
3590 | - '</div>' + | ||
3591 | - '</div>'; | ||
3592 | - | ||
3593 | - dialogTemplate = Handlebars.compile(dialogTpl); | ||
3594 | - } | ||
3595 | - return dialogTemplate; | ||
3596 | -} | ||
3597 | - | ||
3598 | -// fullWithBtn是供详情页获取限购码使用的特殊参数 | ||
3599 | -exports.showDialog = function(data, callback, callbackForLeft, fullWithBtn) { | ||
3600 | - | ||
3601 | - var dialogTemplate = getInstance(), | ||
3602 | - dialogStr = dialogTemplate(data), | ||
3603 | - $dialogBox, | ||
3604 | - defaultHideDuraton, | ||
3605 | - dialogWrapperHammer; | ||
3606 | - | ||
3607 | - $('.dialog-wrapper').remove(); | ||
3608 | - | ||
3609 | - $('body').append($(dialogStr)); | ||
3610 | - | ||
3611 | - $dialogBox = $('.dialog-box'); | ||
3612 | - $dialogWrapper = $('.dialog-wrapper'); | ||
3613 | - | ||
3614 | - | ||
3615 | - dialogWrapperHammer = new Hammer(document.getElementById('dialog-wrapper')); | ||
3616 | - | ||
3617 | - // 显示 | ||
3618 | - if (data.fast) { | ||
3619 | - $dialogWrapper.css({ | ||
3620 | - display: 'block' | ||
3621 | - }); | ||
3622 | - } else { | ||
3623 | - $dialogWrapper.fadeIn(); | ||
3624 | - } | ||
3625 | - | ||
3626 | - if (fullWithBtn) { | ||
3627 | - $('.dialog-wrapper .dialog-footer > span').css('width', '100%'); | ||
3628 | - $('.dialog-wrapper .dialog-content').css({ | ||
3629 | - 'padding-left': '1.85rem', | ||
3630 | - 'padding-right': '1.85rem' | ||
3631 | - }); | ||
3632 | - $dialogWrapper.css('z-index', '10'); | ||
3633 | - } | ||
3634 | - | ||
3635 | - $dialogBox.css({ | ||
3636 | - top: '50%', | ||
3637 | - marginTop: -($dialogBox.height() / 2) | ||
3638 | - }); | ||
3639 | - | ||
3640 | - //隐藏 | ||
3641 | - if (data.autoHide) { | ||
3642 | - defaultHideDuraton = 1000; | ||
3643 | - if (data.autoHide > 1) { | ||
3644 | - defaultHideDuraton = data.autoHide; | ||
3645 | - } | ||
3646 | - setTimeout(function() { | ||
3647 | - $dialogWrapper.fadeOut(); | ||
3648 | - }, defaultHideDuraton); | ||
3649 | - } | ||
3650 | - | ||
3651 | - //禁止在dialog上可以上下滚动 | ||
3652 | - $dialogWrapper.on('touchmove', function() { | ||
3653 | - return false; | ||
3654 | - }); | ||
3655 | - | ||
3656 | - dialogWrapperHammer.on('tap', function(event) { | ||
3657 | - | ||
3658 | - if ($(event.target).hasClass('dialog-left-btn')) { | ||
3659 | - if (typeof callbackForLeft === 'function') { | ||
3660 | - callbackForLeft(); | ||
3661 | - } | ||
3662 | - $dialogWrapper.fadeOut(); | ||
3663 | - } else if ($(event.target).hasClass('dialog-right-btn')) { | ||
3664 | - callback(); | ||
3665 | - } | ||
3666 | - | ||
3667 | - // 防止出现点透问题 | ||
3668 | - event.preventDefault(); | ||
3669 | - event.srcEvent.stopPropagation(); | ||
3670 | - }); | ||
3671 | -}; | ||
3672 | - | ||
3673 | -exports.hideDialog = function() { | ||
3674 | - $('.dialog-wrapper').remove(); | ||
3675 | -}; | 3559 | +/* |
3560 | + * @Description: dialog | ||
3561 | + * @Time: 2015/11/18 | ||
3562 | + * @author: chenglong.wang | ||
3563 | + */ | ||
3564 | + | ||
3565 | +var $ = require("jquery"), | ||
3566 | + Handlebars = require("handlebars"), | ||
3567 | + Hammer = require("hammer"); | ||
3568 | + | ||
3569 | +var $dialogWrapper, | ||
3570 | + dialogTpl, | ||
3571 | + dialogTemplate; | ||
3572 | + | ||
3573 | +function getInstance() { | ||
3574 | + if (dialogTpl === undefined) { | ||
3575 | + dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' + | ||
3576 | + '<div class="dialog-box">' + | ||
3577 | + '{{# hasHeader}}' + | ||
3578 | + '{{/ hasHeader}}' + | ||
3579 | + '<div class="dialog-content">{{dialogText}}</div>' + | ||
3580 | + '{{# hasFooter}}' + | ||
3581 | + '<div class="dialog-footer">' + | ||
3582 | + '{{# leftBtnText}}' + | ||
3583 | + '<span class="dialog-left-btn tap-hightlight">{{.}}</span>' + | ||
3584 | + '{{/ leftBtnText}}' + | ||
3585 | + '{{# rightBtnText}}' + | ||
3586 | + '<span class="dialog-right-btn tap-hightlight">{{.}}</span>' + | ||
3587 | + '{{/ rightBtnText}}' + | ||
3588 | + '</div>' + | ||
3589 | + '{{/ hasFooter}}' + | ||
3590 | + '</div>' + | ||
3591 | + '</div>'; | ||
3592 | + | ||
3593 | + dialogTemplate = Handlebars.compile(dialogTpl); | ||
3594 | + } | ||
3595 | + return dialogTemplate; | ||
3596 | +} | ||
3597 | + | ||
3598 | +// fullWithBtn是供详情页获取限购码使用的特殊参数 | ||
3599 | +exports.showDialog = function(data, callback, callbackForLeft, fullWithBtn) { | ||
3600 | + | ||
3601 | + var dialogTemplate = getInstance(), | ||
3602 | + dialogStr = dialogTemplate(data), | ||
3603 | + $dialogBox, | ||
3604 | + defaultHideDuraton, | ||
3605 | + dialogWrapperHammer; | ||
3606 | + | ||
3607 | + $('.dialog-wrapper').remove(); | ||
3608 | + | ||
3609 | + $('body').append($(dialogStr)); | ||
3610 | + | ||
3611 | + $dialogBox = $('.dialog-box'); | ||
3612 | + $dialogWrapper = $('.dialog-wrapper'); | ||
3613 | + | ||
3614 | + | ||
3615 | + dialogWrapperHammer = new Hammer(document.getElementById('dialog-wrapper')); | ||
3616 | + | ||
3617 | + // 显示 | ||
3618 | + if (data.fast) { | ||
3619 | + $dialogWrapper.css({ | ||
3620 | + display: 'block' | ||
3621 | + }); | ||
3622 | + } else { | ||
3623 | + $dialogWrapper.fadeIn(); | ||
3624 | + } | ||
3625 | + | ||
3626 | + if (fullWithBtn) { | ||
3627 | + $('.dialog-wrapper .dialog-footer > span').css('width', '100%'); | ||
3628 | + $('.dialog-wrapper .dialog-content').css({ | ||
3629 | + 'padding-left': '1.85rem', | ||
3630 | + 'padding-right': '1.85rem' | ||
3631 | + }); | ||
3632 | + $dialogWrapper.css('z-index', '10'); | ||
3633 | + } | ||
3634 | + | ||
3635 | + $dialogBox.css({ | ||
3636 | + top: '50%', | ||
3637 | + marginTop: -($dialogBox.height() / 2) | ||
3638 | + }); | ||
3639 | + | ||
3640 | + //隐藏 | ||
3641 | + if (data.autoHide) { | ||
3642 | + defaultHideDuraton = 1000; | ||
3643 | + if (data.autoHide > 1) { | ||
3644 | + defaultHideDuraton = data.autoHide; | ||
3645 | + } | ||
3646 | + setTimeout(function() { | ||
3647 | + $dialogWrapper.fadeOut(); | ||
3648 | + }, defaultHideDuraton); | ||
3649 | + } | ||
3650 | + | ||
3651 | + //禁止在dialog上可以上下滚动 | ||
3652 | + $dialogWrapper.on('touchmove', function() { | ||
3653 | + return false; | ||
3654 | + }); | ||
3655 | + | ||
3656 | + dialogWrapperHammer.on('tap', function(event) { | ||
3657 | + | ||
3658 | + if ($(event.target).hasClass('dialog-left-btn')) { | ||
3659 | + if (typeof callbackForLeft === 'function') { | ||
3660 | + callbackForLeft(); | ||
3661 | + } | ||
3662 | + $dialogWrapper.fadeOut(); | ||
3663 | + } else if ($(event.target).hasClass('dialog-right-btn')) { | ||
3664 | + callback(); | ||
3665 | + } | ||
3666 | + | ||
3667 | + // 防止出现点透问题 | ||
3668 | + event.preventDefault(); | ||
3669 | + event.srcEvent.stopPropagation(); | ||
3670 | + }); | ||
3671 | +}; | ||
3672 | + | ||
3673 | +exports.hideDialog = function() { | ||
3674 | + $('.dialog-wrapper').remove(); | ||
3675 | +}; | ||
3676 | 3676 | ||
3677 | }); | 3677 | }); |
3678 | define("js/passport/bind/code", ["jquery"], function(require, exports, module){ | 3678 | define("js/passport/bind/code", ["jquery"], function(require, exports, module){ |
@@ -6996,460 +6996,460 @@ optHammer.on('tap', function(e) { | @@ -6996,460 +6996,460 @@ optHammer.on('tap', function(e) { | ||
6996 | 6996 | ||
6997 | }); | 6997 | }); |
6998 | define("js/me/fav", ["jquery","hammer","swiper","handlebars","source-map","index"], function(require, exports, module){ | 6998 | define("js/me/fav", ["jquery","hammer","swiper","handlebars","source-map","index"], function(require, exports, module){ |
6999 | -/** | ||
7000 | - * 个人中心--收藏 | ||
7001 | - * @author: chenglong<chenglong.wang@yoho.cn> | ||
7002 | - * @date: 2015/11/12 | ||
7003 | - */ | ||
7004 | -var $ = require("jquery"), | ||
7005 | - Hammer = require("hammer"), | ||
7006 | - Swiper = require("swiper"); | ||
7007 | - | ||
7008 | -var diaLog = require("js/me/dialog"); | ||
7009 | - | ||
7010 | -var $navLi = $('#fav-tab > li'), | ||
7011 | - $favContainer = $('.fav-content > .fav-type'), | ||
7012 | - swiperObj = {}, | ||
7013 | - favTabHammer, | ||
7014 | - favContentHammer, | ||
7015 | - $loadMore = $('.fav-load-more'), | ||
7016 | - $brandLoadMore = $('.fav-brand-load-more'), | ||
7017 | - winH = $(window).height(), | ||
7018 | - footerH = $('#yoho-footer').height(), | ||
7019 | - $favProductList = $('.fav-product-list'), | ||
7020 | - $favBrandList = $('.fav-brand-swiper-wrapper'), | ||
7021 | - pageId = 1, | ||
7022 | - brandPageId = 1, //收藏品牌的当前页数 | ||
7023 | - lockId = true, | ||
7024 | - brandLockId = true, //收藏品牌是否可下拉加载更多 | ||
7025 | - brandTab = false; //当前是否停留在收藏品牌页 | ||
7026 | - | ||
7027 | -function showFavTab(index) { | ||
7028 | - $navLi.filter('.active').removeClass('active'); | ||
7029 | - $navLi.eq(index).addClass('active'); | ||
7030 | - | ||
7031 | - $favContainer.filter('.show').removeClass('show'); | ||
7032 | - $favContainer.eq(index).addClass('show'); | ||
7033 | -} | ||
7034 | - | ||
7035 | -//初始化swiper | ||
7036 | -function initSwiper(data) { | ||
7037 | - var i, | ||
7038 | - idStrReg = /container-(\d+)['"]{1}/gi, | ||
7039 | - idReg = /\d+/, | ||
7040 | - idArr = data.match(idStrReg), | ||
7041 | - idArrLen = idArr.length, | ||
7042 | - containerId; | ||
7043 | - | ||
7044 | - //$swiperList = $('.swiper-container'); | ||
7045 | - for (i = 0; i < idArrLen; i++) { | ||
7046 | - | ||
7047 | - /*id = $swiperList.eq(i).attr('data-id'); | ||
7048 | - | ||
7049 | - if (!!swiperObj[id]) { | ||
7050 | - swiperObj[id].destroy(true, true); | ||
7051 | - }*/ | ||
7052 | - | ||
7053 | - containerId = idArr[i].match(idReg)[0]; | ||
7054 | - | ||
7055 | - swiperObj[containerId] = new Swiper('#swiper-container-' + containerId, { | ||
7056 | - slidesPerView: 'auto', | ||
7057 | - grabCursor: true, | ||
7058 | - slideElement: 'li', | ||
7059 | - wrapperClass: 'swiper-wrapper-' + containerId, | ||
7060 | - lazyLoading: true, | ||
7061 | - watchSlidesVisibility: true | ||
7062 | - }); | ||
7063 | - } | ||
7064 | -} | ||
7065 | - | ||
7066 | -// 上拉加载更多 | ||
7067 | -function loadData($parent, url, page) { | ||
7068 | - if (url === 'favBrand') { | ||
7069 | - brandLockId = true; | ||
7070 | - } else { | ||
7071 | - lockId = true; | ||
7072 | - } | ||
7073 | - $.ajax({ | ||
7074 | - method: 'post', | ||
7075 | - url: '/home/' + url, | ||
7076 | - data: { | ||
7077 | - page: page | ||
7078 | - }, | ||
7079 | - success: function(data) { | ||
7080 | - var $loadingMask = $parent.closest('.fav-type').find('.fav-content-loading'); | ||
7081 | - | ||
7082 | - if (url === 'favBrand') { | ||
7083 | - $brandLoadMore.addClass('hide'); | ||
7084 | - } else { | ||
7085 | - $loadMore.addClass('hide'); | ||
7086 | - } | ||
7087 | - | ||
7088 | - if (data === ' ') { | ||
7089 | - $loadingMask.addClass('hide'); | ||
7090 | - $parent.closest('.fav-type').find('.fav-null-box').removeClass('hide'); | ||
7091 | - } else if (data === 'end') { | ||
7092 | - | ||
7093 | - //处理data等于end时如果loadingMask存在且没有hide样式的情况 | ||
7094 | - if ($loadingMask && !$loadingMask.hasClass('hide')) { | ||
7095 | - $loadingMask.addClass('hide'); | ||
7096 | - //$parent.closest('.fav-type').find('.fav-null-box').removeClass('hide'); | ||
7097 | - } | ||
7098 | - | ||
7099 | - $parent.closest('.fav-type').find('.fav-load-background') | ||
7100 | - .removeClass('fav-load-background').html('没有更多了'); | ||
7101 | - | ||
7102 | - // hf: fixes bug to 修改没有数据还调接口,加载错误页面问题 | ||
7103 | - brandLockId = true; | ||
7104 | - lockId = true; | ||
7105 | - } else if (data.length > 10) { | ||
7106 | - $parent.append(data); | ||
7107 | - | ||
7108 | - //如果有数据loadingMask会被remove掉 | ||
7109 | - $loadingMask.remove(); | ||
7110 | - if (url === 'favBrand') { | ||
7111 | - initSwiper(data);//如果是收藏品牌需要初始化swiper | ||
7112 | - | ||
7113 | - brandLockId = false;//请求成功后解锁品牌收藏page++ | ||
7114 | - } else { | ||
7115 | - lockId = false;//请求成功后解锁商品收藏page++ | ||
7116 | - } | ||
7117 | - } | ||
7118 | - window.rePosFooter(); | ||
7119 | - } | ||
7120 | - }); | ||
7121 | -} | ||
7122 | - | ||
7123 | -// 如果从品牌收藏入口进入 | ||
7124 | -if ($('#fav-tab').hasClass('brand-tab')) { | ||
7125 | - showFavTab(1); | ||
7126 | - loadData($favBrandList, 'favBrand', 1); | ||
7127 | - brandTab = true; | ||
7128 | - window.rePosFooter(); | ||
7129 | -} else { | ||
7130 | - showFavTab(0); | ||
7131 | - loadData($favProductList, 'favProduct', 1); | ||
7132 | - brandTab = false; | ||
7133 | - window.rePosFooter(); | ||
7134 | -} | ||
7135 | - | ||
7136 | -favTabHammer = new Hammer(document.getElementById('fav-tab')); | ||
7137 | -favTabHammer.on('tap', function(e) { | ||
7138 | - var $cur = $(e.target).closest('li'), | ||
7139 | - index; | ||
7140 | - | ||
7141 | - if ($cur.length === 0 || $cur.hasClass('active')) { | ||
7142 | - return; | ||
7143 | - } | ||
7144 | - | ||
7145 | - index = $cur.index(); | ||
7146 | - | ||
7147 | - if (index === 0) { | ||
7148 | - brandTab = false; | ||
7149 | - if ($favProductList.find('li').length === 0 && | ||
7150 | - $favProductList.closest('.fav-type').find('.fav-null-box').hasClass('hide')) { | ||
7151 | - loadData($favProductList, 'favProduct', 1); | ||
7152 | - } | ||
7153 | - } else { | ||
7154 | - brandTab = true; | ||
7155 | - if ($favBrandList.find('div').length === 0 && | ||
7156 | - $favBrandList.closest('.fav-type').find('.fav-null-box').hasClass('hide')) { | ||
7157 | - loadData($favBrandList, 'favBrand', 1); | ||
7158 | - } | ||
7159 | - } | ||
7160 | - showFavTab(index); | ||
7161 | - window.rePosFooter(); | ||
7162 | - | ||
7163 | -}); | ||
7164 | - | ||
7165 | -//删除收藏的商品 | ||
7166 | -favContentHammer = new Hammer(document.getElementById('fav-content')); | ||
7167 | - | ||
7168 | -favContentHammer.on('tap', function(e) { | ||
7169 | - var id = ''; | ||
7170 | - | ||
7171 | - if (!$(e.target).hasClass('del-fav')) { | ||
7172 | - return; | ||
7173 | - } | ||
7174 | - | ||
7175 | - diaLog.showDialog({ | ||
7176 | - dialogText: '您确定要取消收藏吗?', | ||
7177 | - hasFooter: { | ||
7178 | - leftBtnText: '取消', | ||
7179 | - rightBtnText: '确定' | ||
7180 | - } | ||
7181 | - }, function() { | ||
7182 | - id = $(e.target).closest('li').attr('data-id'); | ||
7183 | - $.ajax({ | ||
7184 | - method: 'post', | ||
7185 | - url: '/home/favoriteDel', | ||
7186 | - data: { | ||
7187 | - id: id | ||
7188 | - } | ||
7189 | - }).then(function(data) { | ||
7190 | - | ||
7191 | - if (data.code === 200) { | ||
7192 | - diaLog.showDialog({ | ||
7193 | - autoHide: true, | ||
7194 | - fast: true, | ||
7195 | - dialogText: '已经取消收藏' | ||
7196 | - }); | ||
7197 | - $(e.target).closest('li').remove(); | ||
7198 | - } else if (data.code === 400) { | ||
7199 | - diaLog.showDialog({ | ||
7200 | - autoHide: true, | ||
7201 | - fast: true, | ||
7202 | - dialogText: data.message | ||
7203 | - }); | ||
7204 | - } else { | ||
7205 | - diaLog.showDialog({ | ||
7206 | - autoHide: true, | ||
7207 | - fast: true, | ||
7208 | - dialogText: '取消收藏失败' | ||
7209 | - }); | ||
7210 | - } | ||
7211 | - }).fail(function() { | ||
7212 | - | ||
7213 | - //TODO | ||
7214 | - | ||
7215 | - diaLog.showDialog({ | ||
7216 | - autoHide: true, | ||
7217 | - dialogText: '网络错误~' | ||
7218 | - }); | ||
7219 | - }); | ||
7220 | - }); | ||
7221 | -}); | ||
7222 | - | ||
7223 | -function scrollHandler() { | ||
7224 | - | ||
7225 | - //距离底部未1/4列表高度+底部高度的时候加载更多 | ||
7226 | - if ($(window).scrollTop() + winH >= $(document).height() - 0.25 * $favBrandList.height() - footerH) { | ||
7227 | - if (brandTab) { | ||
7228 | - $brandLoadMore.filter('.hide').removeClass('hide'); | ||
7229 | - | ||
7230 | - if (!brandLockId) { | ||
7231 | - brandPageId++; | ||
7232 | - loadData($favBrandList, 'favBrand', brandPageId); | ||
7233 | - } | ||
7234 | - | ||
7235 | - } else { | ||
7236 | - | ||
7237 | - $loadMore.filter('.hide').removeClass('hide'); | ||
7238 | - | ||
7239 | - if (!lockId) { | ||
7240 | - pageId++; | ||
7241 | - loadData($favProductList, 'favProduct', pageId); | ||
7242 | - } | ||
7243 | - } | ||
7244 | - } | ||
7245 | -} | ||
7246 | - | ||
7247 | -//srcoll to load more | ||
7248 | -$(window).scroll(scrollHandler); | ||
7249 | - | ||
7250 | -$(document).on('touchend', '.swiper-header', function() { | ||
7251 | - var url = $(this).find('.fav-more').attr('href'); | ||
7252 | - | ||
7253 | - if (url) { | ||
7254 | - window.location.href = url; | ||
7255 | - } | ||
7256 | -}); | ||
7257 | - | ||
7258 | -$('.invalidGoods').on('touchstart touchend', function() { | ||
7259 | - var $this = $(e.target).closest('span'); | ||
7260 | - | ||
7261 | - if ($this.hasClass('del-fav')) { | ||
7262 | - return; | ||
7263 | - } | ||
7264 | - tip.show('商品已下架'); | ||
7265 | - return false; | 6999 | +/** |
7000 | + * 个人中心--收藏 | ||
7001 | + * @author: chenglong<chenglong.wang@yoho.cn> | ||
7002 | + * @date: 2015/11/12 | ||
7003 | + */ | ||
7004 | +var $ = require("jquery"), | ||
7005 | + Hammer = require("hammer"), | ||
7006 | + Swiper = require("swiper"); | ||
7007 | + | ||
7008 | +var diaLog = require("js/me/dialog"); | ||
7009 | + | ||
7010 | +var $navLi = $('#fav-tab > li'), | ||
7011 | + $favContainer = $('.fav-content > .fav-type'), | ||
7012 | + swiperObj = {}, | ||
7013 | + favTabHammer, | ||
7014 | + favContentHammer, | ||
7015 | + $loadMore = $('.fav-load-more'), | ||
7016 | + $brandLoadMore = $('.fav-brand-load-more'), | ||
7017 | + winH = $(window).height(), | ||
7018 | + footerH = $('#yoho-footer').height(), | ||
7019 | + $favProductList = $('.fav-product-list'), | ||
7020 | + $favBrandList = $('.fav-brand-swiper-wrapper'), | ||
7021 | + pageId = 1, | ||
7022 | + brandPageId = 1, //收藏品牌的当前页数 | ||
7023 | + lockId = true, | ||
7024 | + brandLockId = true, //收藏品牌是否可下拉加载更多 | ||
7025 | + brandTab = false; //当前是否停留在收藏品牌页 | ||
7026 | + | ||
7027 | +function showFavTab(index) { | ||
7028 | + $navLi.filter('.active').removeClass('active'); | ||
7029 | + $navLi.eq(index).addClass('active'); | ||
7030 | + | ||
7031 | + $favContainer.filter('.show').removeClass('show'); | ||
7032 | + $favContainer.eq(index).addClass('show'); | ||
7033 | +} | ||
7034 | + | ||
7035 | +//初始化swiper | ||
7036 | +function initSwiper(data) { | ||
7037 | + var i, | ||
7038 | + idStrReg = /container-(\d+)['"]{1}/gi, | ||
7039 | + idReg = /\d+/, | ||
7040 | + idArr = data.match(idStrReg), | ||
7041 | + idArrLen = idArr.length, | ||
7042 | + containerId; | ||
7043 | + | ||
7044 | + //$swiperList = $('.swiper-container'); | ||
7045 | + for (i = 0; i < idArrLen; i++) { | ||
7046 | + | ||
7047 | + /*id = $swiperList.eq(i).attr('data-id'); | ||
7048 | + | ||
7049 | + if (!!swiperObj[id]) { | ||
7050 | + swiperObj[id].destroy(true, true); | ||
7051 | + }*/ | ||
7052 | + | ||
7053 | + containerId = idArr[i].match(idReg)[0]; | ||
7054 | + | ||
7055 | + swiperObj[containerId] = new Swiper('#swiper-container-' + containerId, { | ||
7056 | + slidesPerView: 'auto', | ||
7057 | + grabCursor: true, | ||
7058 | + slideElement: 'li', | ||
7059 | + wrapperClass: 'swiper-wrapper-' + containerId, | ||
7060 | + lazyLoading: true, | ||
7061 | + watchSlidesVisibility: true | ||
7062 | + }); | ||
7063 | + } | ||
7064 | +} | ||
7065 | + | ||
7066 | +// 上拉加载更多 | ||
7067 | +function loadData($parent, url, page) { | ||
7068 | + if (url === 'favBrand') { | ||
7069 | + brandLockId = true; | ||
7070 | + } else { | ||
7071 | + lockId = true; | ||
7072 | + } | ||
7073 | + $.ajax({ | ||
7074 | + method: 'post', | ||
7075 | + url: '/home/' + url, | ||
7076 | + data: { | ||
7077 | + page: page | ||
7078 | + }, | ||
7079 | + success: function(data) { | ||
7080 | + var $loadingMask = $parent.closest('.fav-type').find('.fav-content-loading'); | ||
7081 | + | ||
7082 | + if (url === 'favBrand') { | ||
7083 | + $brandLoadMore.addClass('hide'); | ||
7084 | + } else { | ||
7085 | + $loadMore.addClass('hide'); | ||
7086 | + } | ||
7087 | + | ||
7088 | + if (data === ' ') { | ||
7089 | + $loadingMask.addClass('hide'); | ||
7090 | + $parent.closest('.fav-type').find('.fav-null-box').removeClass('hide'); | ||
7091 | + } else if (data === 'end') { | ||
7092 | + | ||
7093 | + //处理data等于end时如果loadingMask存在且没有hide样式的情况 | ||
7094 | + if ($loadingMask && !$loadingMask.hasClass('hide')) { | ||
7095 | + $loadingMask.addClass('hide'); | ||
7096 | + //$parent.closest('.fav-type').find('.fav-null-box').removeClass('hide'); | ||
7097 | + } | ||
7098 | + | ||
7099 | + $parent.closest('.fav-type').find('.fav-load-background') | ||
7100 | + .removeClass('fav-load-background').html('没有更多了'); | ||
7101 | + | ||
7102 | + // hf: fixes bug to 修改没有数据还调接口,加载错误页面问题 | ||
7103 | + brandLockId = true; | ||
7104 | + lockId = true; | ||
7105 | + } else if (data.length > 10) { | ||
7106 | + $parent.append(data); | ||
7107 | + | ||
7108 | + //如果有数据loadingMask会被remove掉 | ||
7109 | + $loadingMask.remove(); | ||
7110 | + if (url === 'favBrand') { | ||
7111 | + initSwiper(data);//如果是收藏品牌需要初始化swiper | ||
7112 | + | ||
7113 | + brandLockId = false;//请求成功后解锁品牌收藏page++ | ||
7114 | + } else { | ||
7115 | + lockId = false;//请求成功后解锁商品收藏page++ | ||
7116 | + } | ||
7117 | + } | ||
7118 | + window.rePosFooter(); | ||
7119 | + } | ||
7120 | + }); | ||
7121 | +} | ||
7122 | + | ||
7123 | +// 如果从品牌收藏入口进入 | ||
7124 | +if ($('#fav-tab').hasClass('brand-tab')) { | ||
7125 | + showFavTab(1); | ||
7126 | + loadData($favBrandList, 'favBrand', 1); | ||
7127 | + brandTab = true; | ||
7128 | + window.rePosFooter(); | ||
7129 | +} else { | ||
7130 | + showFavTab(0); | ||
7131 | + loadData($favProductList, 'favProduct', 1); | ||
7132 | + brandTab = false; | ||
7133 | + window.rePosFooter(); | ||
7134 | +} | ||
7135 | + | ||
7136 | +favTabHammer = new Hammer(document.getElementById('fav-tab')); | ||
7137 | +favTabHammer.on('tap', function(e) { | ||
7138 | + var $cur = $(e.target).closest('li'), | ||
7139 | + index; | ||
7140 | + | ||
7141 | + if ($cur.length === 0 || $cur.hasClass('active')) { | ||
7142 | + return; | ||
7143 | + } | ||
7144 | + | ||
7145 | + index = $cur.index(); | ||
7146 | + | ||
7147 | + if (index === 0) { | ||
7148 | + brandTab = false; | ||
7149 | + if ($favProductList.find('li').length === 0 && | ||
7150 | + $favProductList.closest('.fav-type').find('.fav-null-box').hasClass('hide')) { | ||
7151 | + loadData($favProductList, 'favProduct', 1); | ||
7152 | + } | ||
7153 | + } else { | ||
7154 | + brandTab = true; | ||
7155 | + if ($favBrandList.find('div').length === 0 && | ||
7156 | + $favBrandList.closest('.fav-type').find('.fav-null-box').hasClass('hide')) { | ||
7157 | + loadData($favBrandList, 'favBrand', 1); | ||
7158 | + } | ||
7159 | + } | ||
7160 | + showFavTab(index); | ||
7161 | + window.rePosFooter(); | ||
7162 | + | ||
7163 | +}); | ||
7164 | + | ||
7165 | +//删除收藏的商品 | ||
7166 | +favContentHammer = new Hammer(document.getElementById('fav-content')); | ||
7167 | + | ||
7168 | +favContentHammer.on('tap', function(e) { | ||
7169 | + var id = ''; | ||
7170 | + | ||
7171 | + if (!$(e.target).hasClass('del-fav')) { | ||
7172 | + return; | ||
7173 | + } | ||
7174 | + | ||
7175 | + diaLog.showDialog({ | ||
7176 | + dialogText: '您确定要取消收藏吗?', | ||
7177 | + hasFooter: { | ||
7178 | + leftBtnText: '取消', | ||
7179 | + rightBtnText: '确定' | ||
7180 | + } | ||
7181 | + }, function() { | ||
7182 | + id = $(e.target).closest('li').attr('data-id'); | ||
7183 | + $.ajax({ | ||
7184 | + method: 'post', | ||
7185 | + url: '/home/favoriteDel', | ||
7186 | + data: { | ||
7187 | + id: id | ||
7188 | + } | ||
7189 | + }).then(function(data) { | ||
7190 | + | ||
7191 | + if (data.code === 200) { | ||
7192 | + diaLog.showDialog({ | ||
7193 | + autoHide: true, | ||
7194 | + fast: true, | ||
7195 | + dialogText: '已经取消收藏' | ||
7196 | + }); | ||
7197 | + $(e.target).closest('li').remove(); | ||
7198 | + } else if (data.code === 400) { | ||
7199 | + diaLog.showDialog({ | ||
7200 | + autoHide: true, | ||
7201 | + fast: true, | ||
7202 | + dialogText: data.message | ||
7203 | + }); | ||
7204 | + } else { | ||
7205 | + diaLog.showDialog({ | ||
7206 | + autoHide: true, | ||
7207 | + fast: true, | ||
7208 | + dialogText: '取消收藏失败' | ||
7209 | + }); | ||
7210 | + } | ||
7211 | + }).fail(function() { | ||
7212 | + | ||
7213 | + //TODO | ||
7214 | + | ||
7215 | + diaLog.showDialog({ | ||
7216 | + autoHide: true, | ||
7217 | + dialogText: '网络错误~' | ||
7218 | + }); | ||
7219 | + }); | ||
7220 | + }); | ||
7221 | +}); | ||
7222 | + | ||
7223 | +function scrollHandler() { | ||
7224 | + | ||
7225 | + //距离底部未1/4列表高度+底部高度的时候加载更多 | ||
7226 | + if ($(window).scrollTop() + winH >= $(document).height() - 0.25 * $favBrandList.height() - footerH) { | ||
7227 | + if (brandTab) { | ||
7228 | + $brandLoadMore.filter('.hide').removeClass('hide'); | ||
7229 | + | ||
7230 | + if (!brandLockId) { | ||
7231 | + brandPageId++; | ||
7232 | + loadData($favBrandList, 'favBrand', brandPageId); | ||
7233 | + } | ||
7234 | + | ||
7235 | + } else { | ||
7236 | + | ||
7237 | + $loadMore.filter('.hide').removeClass('hide'); | ||
7238 | + | ||
7239 | + if (!lockId) { | ||
7240 | + pageId++; | ||
7241 | + loadData($favProductList, 'favProduct', pageId); | ||
7242 | + } | ||
7243 | + } | ||
7244 | + } | ||
7245 | +} | ||
7246 | + | ||
7247 | +//srcoll to load more | ||
7248 | +$(window).scroll(scrollHandler); | ||
7249 | + | ||
7250 | +$(document).on('touchend', '.swiper-header', function() { | ||
7251 | + var url = $(this).find('.fav-more').attr('href'); | ||
7252 | + | ||
7253 | + if (url) { | ||
7254 | + window.location.href = url; | ||
7255 | + } | ||
7256 | +}); | ||
7257 | + | ||
7258 | +$('.invalidGoods').on('touchstart touchend', function() { | ||
7259 | + var $this = $(e.target).closest('span'); | ||
7260 | + | ||
7261 | + if ($this.hasClass('del-fav')) { | ||
7262 | + return; | ||
7263 | + } | ||
7264 | + tip.show('商品已下架'); | ||
7265 | + return false; | ||
7266 | }); | 7266 | }); |
7267 | }); | 7267 | }); |
7268 | define("js/me/suggest", ["jquery","hammer","lazyload","handlebars","source-map"], function(require, exports, module){ | 7268 | define("js/me/suggest", ["jquery","hammer","lazyload","handlebars","source-map"], function(require, exports, module){ |
7269 | -/** | ||
7270 | - * 个人中心--意见反馈 | ||
7271 | - * @author: chenglong<chenglong.wang@yoho.cn> | ||
7272 | - * @date: 2015/11/12 | ||
7273 | - */ | ||
7274 | - | ||
7275 | - | ||
7276 | -var $ = require("jquery"), | ||
7277 | - Hammer = require("hammer"), | ||
7278 | - lazyLoad = require("lazyload"), | ||
7279 | - Handlebars = require("handlebars"); | ||
7280 | - | ||
7281 | -var diaLog = require("js/me/dialog"); | ||
7282 | - | ||
7283 | -var $uploadImgList = $('.upload-img-list'), | ||
7284 | - headerNavHammer, | ||
7285 | - formHammer, | ||
7286 | - imgTpl, | ||
7287 | - imgTemplate, | ||
7288 | - $likeBtn = $('.suggest-item .like-btn'), | ||
7289 | - $disLikeBtn = $('.suggest-item .dislike-btn'), | ||
7290 | - $imgAdd = $('.img-add'), | ||
7291 | - imgStr = '', | ||
7292 | - uploadImgNum = 0; | ||
7293 | - | ||
7294 | -require("js/me/jquery.upload"); | ||
7295 | - | ||
7296 | -imgTpl = '{{# imgList}}' + | ||
7297 | - '<li>' + | ||
7298 | - '{{# imgUrl}}<img src="{{.}}" />' + | ||
7299 | - '<span class="upload-img-remove"></span>{{/ imgUrl}}' + | ||
7300 | - '</li>' + | ||
7301 | - '{{/ imgList}}'; | ||
7302 | - | ||
7303 | -imgTemplate = Handlebars.compile(imgTpl); | ||
7304 | - | ||
7305 | -$('#upload-img').upload({ | ||
7306 | - auto: true, | ||
7307 | - fileType: 'image/*', | ||
7308 | - uploadScript: '/home/suggestimgUpload', | ||
7309 | - fileObjName: 'fileData', | ||
7310 | - fileSizeLimit: 300, | ||
7311 | - height: '100%', | ||
7312 | - width: '100%', | ||
7313 | - multi: false, | ||
7314 | - onAddQueueItem: function(files) { | ||
7315 | - | ||
7316 | - //TODO | ||
7317 | - $uploadImgList.html(imgTemplate({ | ||
7318 | - imgList: true | ||
7319 | - })); | ||
7320 | - }, | ||
7321 | - onUploadComplete: function(file, data) { | ||
7322 | - $uploadImgList.html(''); | ||
7323 | - imgStr = JSON.parse(data).imgList[0].imgRelUrl; | ||
7324 | - $uploadImgList.html(imgTemplate(JSON.parse(data))); | ||
7325 | - $imgAdd.hide(); | ||
7326 | - uploadImgNum++; | ||
7327 | - } | ||
7328 | -}); | ||
7329 | - | ||
7330 | -lazyLoad(); | ||
7331 | - | ||
7332 | -headerNavHammer = new Hammer(document.getElementById('yoho-header')); | ||
7333 | - | ||
7334 | -headerNavHammer.on('tap', function(e) { | ||
7335 | - var suggestText = $('#suggest-textarea').val(), | ||
7336 | - textReg = /\S+/; | ||
7337 | - | ||
7338 | - | ||
7339 | - if ($(e.target).hasClass('nav-btn')) { | ||
7340 | - | ||
7341 | - if (!textReg.test(suggestText)) { | ||
7342 | - diaLog.showDialog({ | ||
7343 | - autoHide: true, | ||
7344 | - dialogText: '意见不能为空' | ||
7345 | - }); | ||
7346 | - | ||
7347 | - return; | ||
7348 | - } | ||
7349 | - | ||
7350 | - $.ajax({ | ||
7351 | - method: 'post', | ||
7352 | - url: '/home/savesuggest', | ||
7353 | - data: { | ||
7354 | - content: suggestText, | ||
7355 | - image: imgStr | ||
7356 | - } | ||
7357 | - }).then(function(data) { | ||
7358 | - if (data.code === 200) { | ||
7359 | - diaLog.showDialog({ | ||
7360 | - autoHide: true, | ||
7361 | - dialogText: '提交成功' | ||
7362 | - }); | ||
7363 | - setTimeout(function() { | ||
7364 | - location.pathname = 'home/suggest'; | ||
7365 | - }, 2000); | ||
7366 | - } else { | ||
7367 | - diaLog.showDialog({ | ||
7368 | - autoHide: true, | ||
7369 | - dialogText: '提交失败~' | ||
7370 | - }); | ||
7371 | - } | ||
7372 | - }).fail(function() { | ||
7373 | - | ||
7374 | - diaLog.showDialog({ | ||
7375 | - autoHide: true, | ||
7376 | - dialogText: '网络错误~' | ||
7377 | - }); | ||
7378 | - }); | ||
7379 | - } | ||
7380 | -}); | ||
7381 | - | ||
7382 | -if (document.getElementById('img-form') !== null) { | ||
7383 | - formHammer = new Hammer(document.getElementById('img-form')); | ||
7384 | - | ||
7385 | - formHammer.on('tap', function(e) { | ||
7386 | - if ($(e.target).hasClass('upload-img-remove')) { | ||
7387 | - $uploadImgList.html(''); | ||
7388 | - imgStr = ''; | ||
7389 | - uploadImgNum--; | ||
7390 | - setTimeout(function() { | ||
7391 | - $imgAdd.show(); | ||
7392 | - }, 50); | ||
7393 | - | ||
7394 | - } | ||
7395 | - }); | ||
7396 | -} | ||
7397 | - | ||
7398 | -// 点赞与取消点赞 | ||
7399 | -$likeBtn.bind('click', function() { | ||
7400 | - | ||
7401 | - var id = $(this).closest('.suggest-item').attr('data-id'), | ||
7402 | - $that = $(this); | ||
7403 | - | ||
7404 | - $.ajax({ | ||
7405 | - method: 'post', | ||
7406 | - url: '/home/upAndDown', | ||
7407 | - data: { | ||
7408 | - suggest_id: id, | ||
7409 | - reliable: 1 | ||
7410 | - } | ||
7411 | - }).then(function(data) { | ||
7412 | - if (data.code === 200) { | ||
7413 | - $that.closest('.suggest-type').removeClass('show'); | ||
7414 | - $that.closest('.suggest-item').find('.suggest-good').addClass('show'); | ||
7415 | - } | ||
7416 | - }).fail(function(data) { | ||
7417 | - | ||
7418 | - //TODO | ||
7419 | - | ||
7420 | - diaLog.showDialog({ | ||
7421 | - autoHide: true, | ||
7422 | - dialogText: '网络错误~' | ||
7423 | - }); | ||
7424 | - }); | ||
7425 | -}); | ||
7426 | - | ||
7427 | -$disLikeBtn.bind('click', function() { | ||
7428 | - | ||
7429 | - var id = $(this).closest('.suggest-item').attr('data-id'), | ||
7430 | - $that = $(this); | ||
7431 | - | ||
7432 | - $.ajax({ | ||
7433 | - method: 'post', | ||
7434 | - url: '/home/upAndDown', | ||
7435 | - data: { | ||
7436 | - suggest_id: id, | ||
7437 | - reliable: 2 | ||
7438 | - } | ||
7439 | - }).then(function(data) { | ||
7440 | - if (data.code === 200) { | ||
7441 | - $that.closest('.suggest-type').removeClass('show'); | ||
7442 | - $that.closest('.suggest-item').find('.suggest-bad').addClass('show'); | ||
7443 | - } | ||
7444 | - }).fail(function(data) { | ||
7445 | - | ||
7446 | - //TODO | ||
7447 | - | ||
7448 | - diaLog.showDialog({ | ||
7449 | - autoHide: true, | ||
7450 | - dialogText: '网络错误~' | ||
7451 | - }); | ||
7452 | - }); | 7269 | +/** |
7270 | + * 个人中心--意见反馈 | ||
7271 | + * @author: chenglong<chenglong.wang@yoho.cn> | ||
7272 | + * @date: 2015/11/12 | ||
7273 | + */ | ||
7274 | + | ||
7275 | + | ||
7276 | +var $ = require("jquery"), | ||
7277 | + Hammer = require("hammer"), | ||
7278 | + lazyLoad = require("lazyload"), | ||
7279 | + Handlebars = require("handlebars"); | ||
7280 | + | ||
7281 | +var diaLog = require("js/me/dialog"); | ||
7282 | + | ||
7283 | +var $uploadImgList = $('.upload-img-list'), | ||
7284 | + headerNavHammer, | ||
7285 | + formHammer, | ||
7286 | + imgTpl, | ||
7287 | + imgTemplate, | ||
7288 | + $likeBtn = $('.suggest-item .like-btn'), | ||
7289 | + $disLikeBtn = $('.suggest-item .dislike-btn'), | ||
7290 | + $imgAdd = $('.img-add'), | ||
7291 | + imgStr = '', | ||
7292 | + uploadImgNum = 0; | ||
7293 | + | ||
7294 | +require("js/me/jquery.upload"); | ||
7295 | + | ||
7296 | +imgTpl = '{{# imgList}}' + | ||
7297 | + '<li>' + | ||
7298 | + '{{# imgUrl}}<img src="{{.}}" />' + | ||
7299 | + '<span class="upload-img-remove"></span>{{/ imgUrl}}' + | ||
7300 | + '</li>' + | ||
7301 | + '{{/ imgList}}'; | ||
7302 | + | ||
7303 | +imgTemplate = Handlebars.compile(imgTpl); | ||
7304 | + | ||
7305 | +$('#upload-img').upload({ | ||
7306 | + auto: true, | ||
7307 | + fileType: 'image/*', | ||
7308 | + uploadScript: '/home/suggestimgUpload', | ||
7309 | + fileObjName: 'fileData', | ||
7310 | + fileSizeLimit: 300, | ||
7311 | + height: '100%', | ||
7312 | + width: '100%', | ||
7313 | + multi: false, | ||
7314 | + onAddQueueItem: function(files) { | ||
7315 | + | ||
7316 | + //TODO | ||
7317 | + $uploadImgList.html(imgTemplate({ | ||
7318 | + imgList: true | ||
7319 | + })); | ||
7320 | + }, | ||
7321 | + onUploadComplete: function(file, data) { | ||
7322 | + $uploadImgList.html(''); | ||
7323 | + imgStr = JSON.parse(data).imgList[0].imgRelUrl; | ||
7324 | + $uploadImgList.html(imgTemplate(JSON.parse(data))); | ||
7325 | + $imgAdd.hide(); | ||
7326 | + uploadImgNum++; | ||
7327 | + } | ||
7328 | +}); | ||
7329 | + | ||
7330 | +lazyLoad(); | ||
7331 | + | ||
7332 | +headerNavHammer = new Hammer(document.getElementById('yoho-header')); | ||
7333 | + | ||
7334 | +headerNavHammer.on('tap', function(e) { | ||
7335 | + var suggestText = $('#suggest-textarea').val(), | ||
7336 | + textReg = /\S+/; | ||
7337 | + | ||
7338 | + | ||
7339 | + if ($(e.target).hasClass('nav-btn')) { | ||
7340 | + | ||
7341 | + if (!textReg.test(suggestText)) { | ||
7342 | + diaLog.showDialog({ | ||
7343 | + autoHide: true, | ||
7344 | + dialogText: '意见不能为空' | ||
7345 | + }); | ||
7346 | + | ||
7347 | + return; | ||
7348 | + } | ||
7349 | + | ||
7350 | + $.ajax({ | ||
7351 | + method: 'post', | ||
7352 | + url: '/home/savesuggest', | ||
7353 | + data: { | ||
7354 | + content: suggestText, | ||
7355 | + image: imgStr | ||
7356 | + } | ||
7357 | + }).then(function(data) { | ||
7358 | + if (data.code === 200) { | ||
7359 | + diaLog.showDialog({ | ||
7360 | + autoHide: true, | ||
7361 | + dialogText: '提交成功' | ||
7362 | + }); | ||
7363 | + setTimeout(function() { | ||
7364 | + location.pathname = 'home/suggest'; | ||
7365 | + }, 2000); | ||
7366 | + } else { | ||
7367 | + diaLog.showDialog({ | ||
7368 | + autoHide: true, | ||
7369 | + dialogText: '提交失败~' | ||
7370 | + }); | ||
7371 | + } | ||
7372 | + }).fail(function() { | ||
7373 | + | ||
7374 | + diaLog.showDialog({ | ||
7375 | + autoHide: true, | ||
7376 | + dialogText: '网络错误~' | ||
7377 | + }); | ||
7378 | + }); | ||
7379 | + } | ||
7380 | +}); | ||
7381 | + | ||
7382 | +if (document.getElementById('img-form') !== null) { | ||
7383 | + formHammer = new Hammer(document.getElementById('img-form')); | ||
7384 | + | ||
7385 | + formHammer.on('tap', function(e) { | ||
7386 | + if ($(e.target).hasClass('upload-img-remove')) { | ||
7387 | + $uploadImgList.html(''); | ||
7388 | + imgStr = ''; | ||
7389 | + uploadImgNum--; | ||
7390 | + setTimeout(function() { | ||
7391 | + $imgAdd.show(); | ||
7392 | + }, 50); | ||
7393 | + | ||
7394 | + } | ||
7395 | + }); | ||
7396 | +} | ||
7397 | + | ||
7398 | +// 点赞与取消点赞 | ||
7399 | +$likeBtn.bind('click', function() { | ||
7400 | + | ||
7401 | + var id = $(this).closest('.suggest-item').attr('data-id'), | ||
7402 | + $that = $(this); | ||
7403 | + | ||
7404 | + $.ajax({ | ||
7405 | + method: 'post', | ||
7406 | + url: '/home/upAndDown', | ||
7407 | + data: { | ||
7408 | + suggest_id: id, | ||
7409 | + reliable: 1 | ||
7410 | + } | ||
7411 | + }).then(function(data) { | ||
7412 | + if (data.code === 200) { | ||
7413 | + $that.closest('.suggest-type').removeClass('show'); | ||
7414 | + $that.closest('.suggest-item').find('.suggest-good').addClass('show'); | ||
7415 | + } | ||
7416 | + }).fail(function(data) { | ||
7417 | + | ||
7418 | + //TODO | ||
7419 | + | ||
7420 | + diaLog.showDialog({ | ||
7421 | + autoHide: true, | ||
7422 | + dialogText: '网络错误~' | ||
7423 | + }); | ||
7424 | + }); | ||
7425 | +}); | ||
7426 | + | ||
7427 | +$disLikeBtn.bind('click', function() { | ||
7428 | + | ||
7429 | + var id = $(this).closest('.suggest-item').attr('data-id'), | ||
7430 | + $that = $(this); | ||
7431 | + | ||
7432 | + $.ajax({ | ||
7433 | + method: 'post', | ||
7434 | + url: '/home/upAndDown', | ||
7435 | + data: { | ||
7436 | + suggest_id: id, | ||
7437 | + reliable: 2 | ||
7438 | + } | ||
7439 | + }).then(function(data) { | ||
7440 | + if (data.code === 200) { | ||
7441 | + $that.closest('.suggest-type').removeClass('show'); | ||
7442 | + $that.closest('.suggest-item').find('.suggest-bad').addClass('show'); | ||
7443 | + } | ||
7444 | + }).fail(function(data) { | ||
7445 | + | ||
7446 | + //TODO | ||
7447 | + | ||
7448 | + diaLog.showDialog({ | ||
7449 | + autoHide: true, | ||
7450 | + dialogText: '网络错误~' | ||
7451 | + }); | ||
7452 | + }); | ||
7453 | }); | 7453 | }); |
7454 | }); | 7454 | }); |
7455 | define("js/me/jquery.upload", ["jquery"], function(require, exports, module){ | 7455 | define("js/me/jquery.upload", ["jquery"], function(require, exports, module){ |
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
@@ -38,12 +38,12 @@ | @@ -38,12 +38,12 @@ | ||
38 | text-align: center; | 38 | text-align: center; |
39 | font-size: 22px; | 39 | font-size: 22px; |
40 | color: #fff; | 40 | color: #fff; |
41 | - background: resolve("../img/me/employ/rank.png") no-repeat; | 41 | + background: resolve("me/employ/rank.png") no-repeat; |
42 | background-position: center top; | 42 | background-position: center top; |
43 | background-size: auto 100%; | 43 | background-size: auto 100%; |
44 | 44 | ||
45 | &.top { | 45 | &.top { |
46 | - background: resolve("../img/me/employ/rank-t.png") no-repeat; | 46 | + background: resolve("me/employ/rank-t.png") no-repeat; |
47 | background-position: center top; | 47 | background-position: center top; |
48 | background-size: 100%; | 48 | background-size: 100%; |
49 | line-height: 54px; | 49 | line-height: 54px; |
-
Please register or login to post a comment