Showing
4 changed files
with
573 additions
and
573 deletions
@@ -5668,123 +5668,123 @@ if (/MicroMessenger/i.test(navigator.userAgent) && $.queryString().refer) { | @@ -5668,123 +5668,123 @@ if (/MicroMessenger/i.test(navigator.userAgent) && $.queryString().refer) { | ||
5668 | 5668 | ||
5669 | }); | 5669 | }); |
5670 | define("js/me/dialog", ["jquery","handlebars","source-map","hammer"], function(require, exports, module){ | 5670 | define("js/me/dialog", ["jquery","handlebars","source-map","hammer"], function(require, exports, module){ |
5671 | -/* | ||
5672 | - * @Description: dialog | ||
5673 | - * @Time: 2015/11/18 | ||
5674 | - * @author: chenglong.wang | ||
5675 | - */ | ||
5676 | - | ||
5677 | -var $ = require("jquery"), | ||
5678 | - Handlebars = require("handlebars"), | ||
5679 | - Hammer = require("hammer"); | ||
5680 | - | ||
5681 | -var $dialogWrapper, | ||
5682 | - dialogTpl, | ||
5683 | - dialogTemplate; | ||
5684 | - | ||
5685 | -function getInstance() { | ||
5686 | - if (dialogTpl === undefined) { | ||
5687 | - dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' + | ||
5688 | - '<div class="dialog-box">' + | ||
5689 | - '{{# hasHeader}}' + | ||
5690 | - '{{/ hasHeader}}' + | ||
5691 | - '<div class="dialog-content">{{dialogText}}</div>' + | ||
5692 | - '{{# hasFooter}}' + | ||
5693 | - '<div class="dialog-footer">' + | ||
5694 | - '{{# leftBtnText}}' + | ||
5695 | - '<span class="dialog-left-btn tap-hightlight">{{.}}</span>' + | ||
5696 | - '{{/ leftBtnText}}' + | ||
5697 | - '{{# rightBtnText}}' + | ||
5698 | - '<span class="dialog-right-btn tap-hightlight">{{.}}</span>' + | ||
5699 | - '{{/ rightBtnText}}' + | ||
5700 | - '</div>' + | ||
5701 | - '{{/ hasFooter}}' + | ||
5702 | - '</div>' + | ||
5703 | - '</div>'; | ||
5704 | - | ||
5705 | - dialogTemplate = Handlebars.compile(dialogTpl); | ||
5706 | - } | ||
5707 | - return dialogTemplate; | ||
5708 | -} | ||
5709 | - | ||
5710 | -// fullWithBtn是供详情页获取限购码使用的特殊参数 | ||
5711 | -exports.showDialog = function(data, callback, callbackForLeft, fullWithBtn) { | ||
5712 | - | ||
5713 | - var dialogTemplate = getInstance(), | ||
5714 | - dialogStr = dialogTemplate(data), | ||
5715 | - $dialogBox, | ||
5716 | - defaultHideDuraton, | ||
5717 | - dialogWrapperHammer; | ||
5718 | - | ||
5719 | - $('.dialog-wrapper').remove(); | ||
5720 | - | ||
5721 | - $('body').append($(dialogStr)); | ||
5722 | - | ||
5723 | - $dialogBox = $('.dialog-box'); | ||
5724 | - $dialogWrapper = $('.dialog-wrapper'); | ||
5725 | - | ||
5726 | - | ||
5727 | - dialogWrapperHammer = new Hammer(document.getElementById('dialog-wrapper')); | ||
5728 | - | ||
5729 | - // 显示 | ||
5730 | - if (data.fast) { | ||
5731 | - $dialogWrapper.css({ | ||
5732 | - display: 'block' | ||
5733 | - }); | ||
5734 | - } else { | ||
5735 | - $dialogWrapper.fadeIn(); | ||
5736 | - } | ||
5737 | - | ||
5738 | - if (fullWithBtn) { | ||
5739 | - $('.dialog-wrapper .dialog-footer > span').css('width', '100%'); | ||
5740 | - $('.dialog-wrapper .dialog-content').css({ | ||
5741 | - 'padding-left': '1.85rem', | ||
5742 | - 'padding-right': '1.85rem' | ||
5743 | - }); | ||
5744 | - $dialogWrapper.css('z-index', '10'); | ||
5745 | - } | ||
5746 | - | ||
5747 | - $dialogBox.css({ | ||
5748 | - top: '50%', | ||
5749 | - marginTop: -($dialogBox.height() / 2) | ||
5750 | - }); | ||
5751 | - | ||
5752 | - //隐藏 | ||
5753 | - if (data.autoHide) { | ||
5754 | - defaultHideDuraton = 1000; | ||
5755 | - if (data.autoHide > 1) { | ||
5756 | - defaultHideDuraton = data.autoHide; | ||
5757 | - } | ||
5758 | - setTimeout(function() { | ||
5759 | - $dialogWrapper.fadeOut(); | ||
5760 | - }, defaultHideDuraton); | ||
5761 | - } | ||
5762 | - | ||
5763 | - //禁止在dialog上可以上下滚动 | ||
5764 | - $dialogWrapper.on('touchmove', function() { | ||
5765 | - return false; | ||
5766 | - }); | ||
5767 | - | ||
5768 | - dialogWrapperHammer.on('tap', function(event) { | ||
5769 | - | ||
5770 | - if ($(event.target).hasClass('dialog-left-btn')) { | ||
5771 | - if (typeof callbackForLeft === 'function') { | ||
5772 | - callbackForLeft(); | ||
5773 | - } | ||
5774 | - $dialogWrapper.fadeOut(); | ||
5775 | - } else if ($(event.target).hasClass('dialog-right-btn')) { | ||
5776 | - callback(); | ||
5777 | - } | ||
5778 | - | ||
5779 | - // 防止出现点透问题 | ||
5780 | - event.preventDefault(); | ||
5781 | - event.srcEvent.stopPropagation(); | ||
5782 | - }); | ||
5783 | -}; | ||
5784 | - | ||
5785 | -exports.hideDialog = function() { | ||
5786 | - $('.dialog-wrapper').remove(); | ||
5787 | -}; | 5671 | +/* |
5672 | + * @Description: dialog | ||
5673 | + * @Time: 2015/11/18 | ||
5674 | + * @author: chenglong.wang | ||
5675 | + */ | ||
5676 | + | ||
5677 | +var $ = require("jquery"), | ||
5678 | + Handlebars = require("handlebars"), | ||
5679 | + Hammer = require("hammer"); | ||
5680 | + | ||
5681 | +var $dialogWrapper, | ||
5682 | + dialogTpl, | ||
5683 | + dialogTemplate; | ||
5684 | + | ||
5685 | +function getInstance() { | ||
5686 | + if (dialogTpl === undefined) { | ||
5687 | + dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' + | ||
5688 | + '<div class="dialog-box">' + | ||
5689 | + '{{# hasHeader}}' + | ||
5690 | + '{{/ hasHeader}}' + | ||
5691 | + '<div class="dialog-content">{{dialogText}}</div>' + | ||
5692 | + '{{# hasFooter}}' + | ||
5693 | + '<div class="dialog-footer">' + | ||
5694 | + '{{# leftBtnText}}' + | ||
5695 | + '<span class="dialog-left-btn tap-hightlight">{{.}}</span>' + | ||
5696 | + '{{/ leftBtnText}}' + | ||
5697 | + '{{# rightBtnText}}' + | ||
5698 | + '<span class="dialog-right-btn tap-hightlight">{{.}}</span>' + | ||
5699 | + '{{/ rightBtnText}}' + | ||
5700 | + '</div>' + | ||
5701 | + '{{/ hasFooter}}' + | ||
5702 | + '</div>' + | ||
5703 | + '</div>'; | ||
5704 | + | ||
5705 | + dialogTemplate = Handlebars.compile(dialogTpl); | ||
5706 | + } | ||
5707 | + return dialogTemplate; | ||
5708 | +} | ||
5709 | + | ||
5710 | +// fullWithBtn是供详情页获取限购码使用的特殊参数 | ||
5711 | +exports.showDialog = function(data, callback, callbackForLeft, fullWithBtn) { | ||
5712 | + | ||
5713 | + var dialogTemplate = getInstance(), | ||
5714 | + dialogStr = dialogTemplate(data), | ||
5715 | + $dialogBox, | ||
5716 | + defaultHideDuraton, | ||
5717 | + dialogWrapperHammer; | ||
5718 | + | ||
5719 | + $('.dialog-wrapper').remove(); | ||
5720 | + | ||
5721 | + $('body').append($(dialogStr)); | ||
5722 | + | ||
5723 | + $dialogBox = $('.dialog-box'); | ||
5724 | + $dialogWrapper = $('.dialog-wrapper'); | ||
5725 | + | ||
5726 | + | ||
5727 | + dialogWrapperHammer = new Hammer(document.getElementById('dialog-wrapper')); | ||
5728 | + | ||
5729 | + // 显示 | ||
5730 | + if (data.fast) { | ||
5731 | + $dialogWrapper.css({ | ||
5732 | + display: 'block' | ||
5733 | + }); | ||
5734 | + } else { | ||
5735 | + $dialogWrapper.fadeIn(); | ||
5736 | + } | ||
5737 | + | ||
5738 | + if (fullWithBtn) { | ||
5739 | + $('.dialog-wrapper .dialog-footer > span').css('width', '100%'); | ||
5740 | + $('.dialog-wrapper .dialog-content').css({ | ||
5741 | + 'padding-left': '1.85rem', | ||
5742 | + 'padding-right': '1.85rem' | ||
5743 | + }); | ||
5744 | + $dialogWrapper.css('z-index', '10'); | ||
5745 | + } | ||
5746 | + | ||
5747 | + $dialogBox.css({ | ||
5748 | + top: '50%', | ||
5749 | + marginTop: -($dialogBox.height() / 2) | ||
5750 | + }); | ||
5751 | + | ||
5752 | + //隐藏 | ||
5753 | + if (data.autoHide) { | ||
5754 | + defaultHideDuraton = 1000; | ||
5755 | + if (data.autoHide > 1) { | ||
5756 | + defaultHideDuraton = data.autoHide; | ||
5757 | + } | ||
5758 | + setTimeout(function() { | ||
5759 | + $dialogWrapper.fadeOut(); | ||
5760 | + }, defaultHideDuraton); | ||
5761 | + } | ||
5762 | + | ||
5763 | + //禁止在dialog上可以上下滚动 | ||
5764 | + $dialogWrapper.on('touchmove', function() { | ||
5765 | + return false; | ||
5766 | + }); | ||
5767 | + | ||
5768 | + dialogWrapperHammer.on('tap', function(event) { | ||
5769 | + | ||
5770 | + if ($(event.target).hasClass('dialog-left-btn')) { | ||
5771 | + if (typeof callbackForLeft === 'function') { | ||
5772 | + callbackForLeft(); | ||
5773 | + } | ||
5774 | + $dialogWrapper.fadeOut(); | ||
5775 | + } else if ($(event.target).hasClass('dialog-right-btn')) { | ||
5776 | + callback(); | ||
5777 | + } | ||
5778 | + | ||
5779 | + // 防止出现点透问题 | ||
5780 | + event.preventDefault(); | ||
5781 | + event.srcEvent.stopPropagation(); | ||
5782 | + }); | ||
5783 | +}; | ||
5784 | + | ||
5785 | +exports.hideDialog = function() { | ||
5786 | + $('.dialog-wrapper').remove(); | ||
5787 | +}; | ||
5788 | 5788 | ||
5789 | }); | 5789 | }); |
5790 | define("js/passport/bind/code", ["jquery"], function(require, exports, module){ | 5790 | define("js/passport/bind/code", ["jquery"], function(require, exports, module){ |
@@ -10484,465 +10484,465 @@ $reaMask.on('touchend', function(event) { | @@ -10484,465 +10484,465 @@ $reaMask.on('touchend', function(event) { | ||
10484 | 10484 | ||
10485 | }); | 10485 | }); |
10486 | define("js/me/fav", ["jquery","hammer","swiper","handlebars","source-map","index"], function(require, exports, module){ | 10486 | define("js/me/fav", ["jquery","hammer","swiper","handlebars","source-map","index"], function(require, exports, module){ |
10487 | -/** | ||
10488 | - * 个人中心--收藏 | ||
10489 | - * @author: chenglong<chenglong.wang@yoho.cn> | ||
10490 | - * @date: 2015/11/12 | ||
10491 | - */ | ||
10492 | -var $ = require("jquery"), | ||
10493 | - Hammer = require("hammer"), | ||
10494 | - Swiper = require("swiper"); | ||
10495 | - | ||
10496 | -var diaLog = require("js/me/dialog"); | ||
10497 | - | ||
10498 | -var tip = require("js/plugin/tip"); | ||
10499 | - | ||
10500 | -var $navLi = $('#fav-tab > li'), | ||
10501 | - $favContainer = $('.fav-content > .fav-type'), | ||
10502 | - swiperObj = {}, | ||
10503 | - favTabHammer, | ||
10504 | - favContentHammer, | ||
10505 | - $loadMore = $('.fav-load-more'), | ||
10506 | - $brandLoadMore = $('.fav-brand-load-more'), | ||
10507 | - winH = $(window).height(), | ||
10508 | - footerH = $('#yoho-footer').height(), | ||
10509 | - $favProductList = $('.fav-product-list'), | ||
10510 | - $favBrandList = $('.fav-brand-swiper-wrapper'), | ||
10511 | - pageId = 1, | ||
10512 | - brandPageId = 1, //收藏品牌的当前页数 | ||
10513 | - lockId = true, | ||
10514 | - brandLockId = true, //收藏品牌是否可下拉加载更多 | ||
10515 | - brandTab = false; //当前是否停留在收藏品牌页 | ||
10516 | - | ||
10517 | -function showFavTab(index) { | ||
10518 | - $navLi.filter('.active').removeClass('active'); | ||
10519 | - $navLi.eq(index).addClass('active'); | ||
10520 | - | ||
10521 | - $favContainer.filter('.show').removeClass('show'); | ||
10522 | - $favContainer.eq(index).addClass('show'); | ||
10523 | -} | ||
10524 | - | ||
10525 | -//初始化swiper | ||
10526 | -function initSwiper(data) { | ||
10527 | - var i, | ||
10528 | - idStrReg = /container-(\d+)['"]{1}/gi, | ||
10529 | - idReg = /\d+/, | ||
10530 | - idArr = data.match(idStrReg), | ||
10531 | - idArrLen = idArr.length, | ||
10532 | - containerId; | ||
10533 | - | ||
10534 | - //$swiperList = $('.swiper-container'); | ||
10535 | - for (i = 0; i < idArrLen; i++) { | ||
10536 | - | ||
10537 | - /*id = $swiperList.eq(i).attr('data-id'); | ||
10538 | - | ||
10539 | - if (!!swiperObj[id]) { | ||
10540 | - swiperObj[id].destroy(true, true); | ||
10541 | - }*/ | ||
10542 | - | ||
10543 | - containerId = idArr[i].match(idReg)[0]; | ||
10544 | - | ||
10545 | - swiperObj[containerId] = new Swiper('#swiper-container-' + containerId, { | ||
10546 | - slidesPerView: 'auto', | ||
10547 | - grabCursor: true, | ||
10548 | - slideElement: 'li', | ||
10549 | - wrapperClass: 'swiper-wrapper-' + containerId, | ||
10550 | - lazyLoading: true, | ||
10551 | - watchSlidesVisibility: true | ||
10552 | - }); | ||
10553 | - } | ||
10554 | -} | ||
10555 | - | ||
10556 | -// 上拉加载更多 | ||
10557 | -function loadData($parent, url, page) { | ||
10558 | - if (url === 'favBrand') { | ||
10559 | - brandLockId = true; | ||
10560 | - } else { | ||
10561 | - lockId = true; | ||
10562 | - } | ||
10563 | - $.ajax({ | ||
10564 | - method: 'post', | ||
10565 | - url: '/home/' + url, | ||
10566 | - data: { | ||
10567 | - page: page | ||
10568 | - }, | ||
10569 | - success: function(data) { | ||
10570 | - var $loadingMask = $parent.closest('.fav-type').find('.fav-content-loading'); | ||
10571 | - | ||
10572 | - if (url === 'favBrand') { | ||
10573 | - $brandLoadMore.addClass('hide'); | ||
10574 | - } else { | ||
10575 | - $loadMore.addClass('hide'); | ||
10576 | - } | ||
10577 | - | ||
10578 | - if (data === ' ') { | ||
10579 | - $loadingMask.addClass('hide'); | ||
10580 | - $parent.closest('.fav-type').find('.fav-null-box').removeClass('hide'); | ||
10581 | - window.rePosFooter(); | ||
10582 | - } else if (data === 'end') { | ||
10583 | - | ||
10584 | - //处理data等于end时如果loadingMask存在且没有hide样式的情况 | ||
10585 | - if ($loadingMask && !$loadingMask.hasClass('hide')) { | ||
10586 | - $loadingMask.addClass('hide'); | ||
10587 | - | ||
10588 | - //$parent.closest('.fav-type').find('.fav-null-box').removeClass('hide'); | ||
10589 | - } | ||
10590 | - | ||
10591 | - $parent.closest('.fav-type').find('.fav-load-background') | ||
10592 | - .removeClass('fav-load-background').html('没有更多了'); | ||
10593 | - | ||
10594 | - // hf: fixes bug to 修改没有数据还调接口,加载错误页面问题 | ||
10595 | - brandLockId = true; | ||
10596 | - lockId = true; | ||
10597 | - } else if (data.length > 10) { | ||
10598 | - $parent.append(data); | ||
10599 | - | ||
10600 | - //如果有数据loadingMask会被remove掉 | ||
10601 | - $loadingMask.remove(); | ||
10602 | - if (url === 'favBrand') { | ||
10603 | - initSwiper(data);//如果是收藏品牌需要初始化swiper | ||
10604 | - | ||
10605 | - brandLockId = false;//请求成功后解锁品牌收藏page++ | ||
10606 | - } else { | ||
10607 | - lockId = false;//请求成功后解锁商品收藏page++ | ||
10608 | - } | ||
10609 | - } | ||
10610 | - window.rePosFooter(); | ||
10611 | - } | ||
10612 | - }); | ||
10613 | -} | ||
10614 | - | ||
10615 | -// 如果从品牌收藏入口进入 | ||
10616 | -if ($('#fav-tab').hasClass('brand-tab')) { | ||
10617 | - showFavTab(1); | ||
10618 | - loadData($favBrandList, 'favBrand', 1); | ||
10619 | - brandTab = true; | ||
10620 | - window.rePosFooter(); | ||
10621 | -} else { | ||
10622 | - showFavTab(0); | ||
10623 | - loadData($favProductList, 'favProduct', 1); | ||
10624 | - brandTab = false; | ||
10625 | - window.rePosFooter(); | ||
10626 | -} | ||
10627 | - | ||
10628 | -favTabHammer = new Hammer(document.getElementById('fav-tab')); | ||
10629 | -favTabHammer.on('tap', function(e) { | ||
10630 | - var $cur = $(e.target).closest('li'), | ||
10631 | - index; | ||
10632 | - | ||
10633 | - if ($cur.length === 0 || $cur.hasClass('active')) { | ||
10634 | - return; | ||
10635 | - } | ||
10636 | - | ||
10637 | - index = $cur.index(); | ||
10638 | - | ||
10639 | - if (index === 0) { | ||
10640 | - brandTab = false; | ||
10641 | - if ($favProductList.find('li').length === 0 && | ||
10642 | - $favProductList.closest('.fav-type').find('.fav-null-box').hasClass('hide')) { | ||
10643 | - loadData($favProductList, 'favProduct', 1); | ||
10644 | - } | ||
10645 | - } else { | ||
10646 | - brandTab = true; | ||
10647 | - if ($favBrandList.find('div').length === 0 && | ||
10648 | - $favBrandList.closest('.fav-type').find('.fav-null-box').hasClass('hide')) { | ||
10649 | - loadData($favBrandList, 'favBrand', 1); | ||
10650 | - } | ||
10651 | - } | ||
10652 | - showFavTab(index); | ||
10653 | - window.rePosFooter(); | ||
10654 | - | ||
10655 | -}); | ||
10656 | - | ||
10657 | -//删除收藏的商品 | ||
10658 | -favContentHammer = new Hammer(document.getElementById('fav-content')); | ||
10659 | - | ||
10660 | -favContentHammer.on('tap', function(e) { | ||
10661 | - var id = ''; | ||
10662 | - | ||
10663 | - if (!$(e.target).hasClass('del-fav')) { | ||
10664 | - return; | ||
10665 | - } | ||
10666 | - | ||
10667 | - diaLog.showDialog({ | ||
10668 | - dialogText: '您确定要取消收藏吗?', | ||
10669 | - hasFooter: { | ||
10670 | - leftBtnText: '取消', | ||
10671 | - rightBtnText: '确定' | ||
10672 | - } | ||
10673 | - }, function() { | ||
10674 | - id = $(e.target).closest('li').attr('data-id'); | ||
10675 | - $.ajax({ | ||
10676 | - method: 'post', | ||
10677 | - url: '/home/favoriteDel', | ||
10678 | - data: { | ||
10679 | - id: id | ||
10680 | - } | ||
10681 | - }).then(function(data) { | ||
10682 | - | ||
10683 | - if (data.code === 200) { | ||
10684 | - diaLog.showDialog({ | ||
10685 | - autoHide: true, | ||
10686 | - fast: true, | ||
10687 | - dialogText: '已经取消收藏' | ||
10688 | - }); | ||
10689 | - $(e.target).closest('li').remove(); | ||
10690 | - } else if (data.code === 400) { | ||
10691 | - diaLog.showDialog({ | ||
10692 | - autoHide: true, | ||
10693 | - fast: true, | ||
10694 | - dialogText: data.message | ||
10695 | - }); | ||
10696 | - } else { | ||
10697 | - diaLog.showDialog({ | ||
10698 | - autoHide: true, | ||
10699 | - fast: true, | ||
10700 | - dialogText: '取消收藏失败' | ||
10701 | - }); | ||
10702 | - } | ||
10703 | - }).fail(function() { | ||
10704 | - | ||
10705 | - //TODO | ||
10706 | - | ||
10707 | - diaLog.showDialog({ | ||
10708 | - autoHide: true, | ||
10709 | - dialogText: '网络错误~' | ||
10710 | - }); | ||
10711 | - }); | ||
10712 | - }); | ||
10713 | -}); | ||
10714 | - | ||
10715 | -function scrollHandler() { | ||
10716 | - | ||
10717 | - //距离底部未1/4列表高度+底部高度的时候加载更多 | ||
10718 | - if ($(window).scrollTop() + winH >= $(document).height() - 0.25 * $favBrandList.height() - footerH) { | ||
10719 | - if (brandTab) { | ||
10720 | - $brandLoadMore.filter('.hide').removeClass('hide'); | ||
10721 | - | ||
10722 | - if (!brandLockId) { | ||
10723 | - brandPageId++; | ||
10724 | - loadData($favBrandList, 'favBrand', brandPageId); | ||
10725 | - } | ||
10726 | - | ||
10727 | - } else { | ||
10728 | - | ||
10729 | - $loadMore.filter('.hide').removeClass('hide'); | ||
10730 | - | ||
10731 | - if (!lockId) { | ||
10732 | - pageId++; | ||
10733 | - loadData($favProductList, 'favProduct', pageId); | ||
10734 | - } | ||
10735 | - } | ||
10736 | - } | ||
10737 | -} | ||
10738 | - | ||
10739 | -//srcoll to load more | ||
10740 | -$(window).scroll(scrollHandler); | ||
10741 | - | ||
10742 | -$(document).on('touchend', '.swiper-header', function() { | ||
10743 | - var url = $(this).find('.fav-more').attr('href'); | ||
10744 | - | ||
10745 | - if (url) { | ||
10746 | - window.location.href = url; | ||
10747 | - } | ||
10748 | -}); | ||
10749 | - | ||
10750 | -$('.invalidGoods').on('touchstart touchend', function(e) { | ||
10751 | - var $this = $(e.target).closest('span'); | ||
10752 | - | ||
10753 | - if ($this.hasClass('del-fav')) { | ||
10754 | - return; | ||
10755 | - } | ||
10756 | - tip.show('商品已下架'); | ||
10757 | - return false; | ||
10758 | -}); | 10487 | +/** |
10488 | + * 个人中心--收藏 | ||
10489 | + * @author: chenglong<chenglong.wang@yoho.cn> | ||
10490 | + * @date: 2015/11/12 | ||
10491 | + */ | ||
10492 | +var $ = require("jquery"), | ||
10493 | + Hammer = require("hammer"), | ||
10494 | + Swiper = require("swiper"); | ||
10495 | + | ||
10496 | +var diaLog = require("js/me/dialog"); | ||
10497 | + | ||
10498 | +var tip = require("js/plugin/tip"); | ||
10499 | + | ||
10500 | +var $navLi = $('#fav-tab > li'), | ||
10501 | + $favContainer = $('.fav-content > .fav-type'), | ||
10502 | + swiperObj = {}, | ||
10503 | + favTabHammer, | ||
10504 | + favContentHammer, | ||
10505 | + $loadMore = $('.fav-load-more'), | ||
10506 | + $brandLoadMore = $('.fav-brand-load-more'), | ||
10507 | + winH = $(window).height(), | ||
10508 | + footerH = $('#yoho-footer').height(), | ||
10509 | + $favProductList = $('.fav-product-list'), | ||
10510 | + $favBrandList = $('.fav-brand-swiper-wrapper'), | ||
10511 | + pageId = 1, | ||
10512 | + brandPageId = 1, //收藏品牌的当前页数 | ||
10513 | + lockId = true, | ||
10514 | + brandLockId = true, //收藏品牌是否可下拉加载更多 | ||
10515 | + brandTab = false; //当前是否停留在收藏品牌页 | ||
10516 | + | ||
10517 | +function showFavTab(index) { | ||
10518 | + $navLi.filter('.active').removeClass('active'); | ||
10519 | + $navLi.eq(index).addClass('active'); | ||
10520 | + | ||
10521 | + $favContainer.filter('.show').removeClass('show'); | ||
10522 | + $favContainer.eq(index).addClass('show'); | ||
10523 | +} | ||
10524 | + | ||
10525 | +//初始化swiper | ||
10526 | +function initSwiper(data) { | ||
10527 | + var i, | ||
10528 | + idStrReg = /container-(\d+)['"]{1}/gi, | ||
10529 | + idReg = /\d+/, | ||
10530 | + idArr = data.match(idStrReg), | ||
10531 | + idArrLen = idArr.length, | ||
10532 | + containerId; | ||
10533 | + | ||
10534 | + //$swiperList = $('.swiper-container'); | ||
10535 | + for (i = 0; i < idArrLen; i++) { | ||
10536 | + | ||
10537 | + /*id = $swiperList.eq(i).attr('data-id'); | ||
10538 | + | ||
10539 | + if (!!swiperObj[id]) { | ||
10540 | + swiperObj[id].destroy(true, true); | ||
10541 | + }*/ | ||
10542 | + | ||
10543 | + containerId = idArr[i].match(idReg)[0]; | ||
10544 | + | ||
10545 | + swiperObj[containerId] = new Swiper('#swiper-container-' + containerId, { | ||
10546 | + slidesPerView: 'auto', | ||
10547 | + grabCursor: true, | ||
10548 | + slideElement: 'li', | ||
10549 | + wrapperClass: 'swiper-wrapper-' + containerId, | ||
10550 | + lazyLoading: true, | ||
10551 | + watchSlidesVisibility: true | ||
10552 | + }); | ||
10553 | + } | ||
10554 | +} | ||
10555 | + | ||
10556 | +// 上拉加载更多 | ||
10557 | +function loadData($parent, url, page) { | ||
10558 | + if (url === 'favBrand') { | ||
10559 | + brandLockId = true; | ||
10560 | + } else { | ||
10561 | + lockId = true; | ||
10562 | + } | ||
10563 | + $.ajax({ | ||
10564 | + method: 'post', | ||
10565 | + url: '/home/' + url, | ||
10566 | + data: { | ||
10567 | + page: page | ||
10568 | + }, | ||
10569 | + success: function(data) { | ||
10570 | + var $loadingMask = $parent.closest('.fav-type').find('.fav-content-loading'); | ||
10571 | + | ||
10572 | + if (url === 'favBrand') { | ||
10573 | + $brandLoadMore.addClass('hide'); | ||
10574 | + } else { | ||
10575 | + $loadMore.addClass('hide'); | ||
10576 | + } | ||
10577 | + | ||
10578 | + if (data === ' ') { | ||
10579 | + $loadingMask.addClass('hide'); | ||
10580 | + $parent.closest('.fav-type').find('.fav-null-box').removeClass('hide'); | ||
10581 | + window.rePosFooter(); | ||
10582 | + } else if (data === 'end') { | ||
10583 | + | ||
10584 | + //处理data等于end时如果loadingMask存在且没有hide样式的情况 | ||
10585 | + if ($loadingMask && !$loadingMask.hasClass('hide')) { | ||
10586 | + $loadingMask.addClass('hide'); | ||
10587 | + | ||
10588 | + //$parent.closest('.fav-type').find('.fav-null-box').removeClass('hide'); | ||
10589 | + } | ||
10590 | + | ||
10591 | + $parent.closest('.fav-type').find('.fav-load-background') | ||
10592 | + .removeClass('fav-load-background').html('没有更多了'); | ||
10593 | + | ||
10594 | + // hf: fixes bug to 修改没有数据还调接口,加载错误页面问题 | ||
10595 | + brandLockId = true; | ||
10596 | + lockId = true; | ||
10597 | + } else if (data.length > 10) { | ||
10598 | + $parent.append(data); | ||
10599 | + | ||
10600 | + //如果有数据loadingMask会被remove掉 | ||
10601 | + $loadingMask.remove(); | ||
10602 | + if (url === 'favBrand') { | ||
10603 | + initSwiper(data);//如果是收藏品牌需要初始化swiper | ||
10604 | + | ||
10605 | + brandLockId = false;//请求成功后解锁品牌收藏page++ | ||
10606 | + } else { | ||
10607 | + lockId = false;//请求成功后解锁商品收藏page++ | ||
10608 | + } | ||
10609 | + } | ||
10610 | + window.rePosFooter(); | ||
10611 | + } | ||
10612 | + }); | ||
10613 | +} | ||
10614 | + | ||
10615 | +// 如果从品牌收藏入口进入 | ||
10616 | +if ($('#fav-tab').hasClass('brand-tab')) { | ||
10617 | + showFavTab(1); | ||
10618 | + loadData($favBrandList, 'favBrand', 1); | ||
10619 | + brandTab = true; | ||
10620 | + window.rePosFooter(); | ||
10621 | +} else { | ||
10622 | + showFavTab(0); | ||
10623 | + loadData($favProductList, 'favProduct', 1); | ||
10624 | + brandTab = false; | ||
10625 | + window.rePosFooter(); | ||
10626 | +} | ||
10627 | + | ||
10628 | +favTabHammer = new Hammer(document.getElementById('fav-tab')); | ||
10629 | +favTabHammer.on('tap', function(e) { | ||
10630 | + var $cur = $(e.target).closest('li'), | ||
10631 | + index; | ||
10632 | + | ||
10633 | + if ($cur.length === 0 || $cur.hasClass('active')) { | ||
10634 | + return; | ||
10635 | + } | ||
10636 | + | ||
10637 | + index = $cur.index(); | ||
10638 | + | ||
10639 | + if (index === 0) { | ||
10640 | + brandTab = false; | ||
10641 | + if ($favProductList.find('li').length === 0 && | ||
10642 | + $favProductList.closest('.fav-type').find('.fav-null-box').hasClass('hide')) { | ||
10643 | + loadData($favProductList, 'favProduct', 1); | ||
10644 | + } | ||
10645 | + } else { | ||
10646 | + brandTab = true; | ||
10647 | + if ($favBrandList.find('div').length === 0 && | ||
10648 | + $favBrandList.closest('.fav-type').find('.fav-null-box').hasClass('hide')) { | ||
10649 | + loadData($favBrandList, 'favBrand', 1); | ||
10650 | + } | ||
10651 | + } | ||
10652 | + showFavTab(index); | ||
10653 | + window.rePosFooter(); | ||
10654 | + | ||
10655 | +}); | ||
10656 | + | ||
10657 | +//删除收藏的商品 | ||
10658 | +favContentHammer = new Hammer(document.getElementById('fav-content')); | ||
10659 | + | ||
10660 | +favContentHammer.on('tap', function(e) { | ||
10661 | + var id = ''; | ||
10662 | + | ||
10663 | + if (!$(e.target).hasClass('del-fav')) { | ||
10664 | + return; | ||
10665 | + } | ||
10666 | + | ||
10667 | + diaLog.showDialog({ | ||
10668 | + dialogText: '您确定要取消收藏吗?', | ||
10669 | + hasFooter: { | ||
10670 | + leftBtnText: '取消', | ||
10671 | + rightBtnText: '确定' | ||
10672 | + } | ||
10673 | + }, function() { | ||
10674 | + id = $(e.target).closest('li').attr('data-id'); | ||
10675 | + $.ajax({ | ||
10676 | + method: 'post', | ||
10677 | + url: '/home/favoriteDel', | ||
10678 | + data: { | ||
10679 | + id: id | ||
10680 | + } | ||
10681 | + }).then(function(data) { | ||
10682 | + | ||
10683 | + if (data.code === 200) { | ||
10684 | + diaLog.showDialog({ | ||
10685 | + autoHide: true, | ||
10686 | + fast: true, | ||
10687 | + dialogText: '已经取消收藏' | ||
10688 | + }); | ||
10689 | + $(e.target).closest('li').remove(); | ||
10690 | + } else if (data.code === 400) { | ||
10691 | + diaLog.showDialog({ | ||
10692 | + autoHide: true, | ||
10693 | + fast: true, | ||
10694 | + dialogText: data.message | ||
10695 | + }); | ||
10696 | + } else { | ||
10697 | + diaLog.showDialog({ | ||
10698 | + autoHide: true, | ||
10699 | + fast: true, | ||
10700 | + dialogText: '取消收藏失败' | ||
10701 | + }); | ||
10702 | + } | ||
10703 | + }).fail(function() { | ||
10704 | + | ||
10705 | + //TODO | ||
10706 | + | ||
10707 | + diaLog.showDialog({ | ||
10708 | + autoHide: true, | ||
10709 | + dialogText: '网络错误~' | ||
10710 | + }); | ||
10711 | + }); | ||
10712 | + }); | ||
10713 | +}); | ||
10714 | + | ||
10715 | +function scrollHandler() { | ||
10716 | + | ||
10717 | + //距离底部未1/4列表高度+底部高度的时候加载更多 | ||
10718 | + if ($(window).scrollTop() + winH >= $(document).height() - 0.25 * $favBrandList.height() - footerH) { | ||
10719 | + if (brandTab) { | ||
10720 | + $brandLoadMore.filter('.hide').removeClass('hide'); | ||
10721 | + | ||
10722 | + if (!brandLockId) { | ||
10723 | + brandPageId++; | ||
10724 | + loadData($favBrandList, 'favBrand', brandPageId); | ||
10725 | + } | ||
10726 | + | ||
10727 | + } else { | ||
10728 | + | ||
10729 | + $loadMore.filter('.hide').removeClass('hide'); | ||
10730 | + | ||
10731 | + if (!lockId) { | ||
10732 | + pageId++; | ||
10733 | + loadData($favProductList, 'favProduct', pageId); | ||
10734 | + } | ||
10735 | + } | ||
10736 | + } | ||
10737 | +} | ||
10738 | + | ||
10739 | +//srcoll to load more | ||
10740 | +$(window).scroll(scrollHandler); | ||
10741 | + | ||
10742 | +$(document).on('touchend', '.swiper-header', function() { | ||
10743 | + var url = $(this).find('.fav-more').attr('href'); | ||
10744 | + | ||
10745 | + if (url) { | ||
10746 | + window.location.href = url; | ||
10747 | + } | ||
10748 | +}); | ||
10749 | + | ||
10750 | +$('.invalidGoods').on('touchstart touchend', function(e) { | ||
10751 | + var $this = $(e.target).closest('span'); | ||
10752 | + | ||
10753 | + if ($this.hasClass('del-fav')) { | ||
10754 | + return; | ||
10755 | + } | ||
10756 | + tip.show('商品已下架'); | ||
10757 | + return false; | ||
10758 | +}); | ||
10759 | 10759 | ||
10760 | }); | 10760 | }); |
10761 | define("js/me/suggest", ["jquery","hammer","lazyload","handlebars","source-map"], function(require, exports, module){ | 10761 | define("js/me/suggest", ["jquery","hammer","lazyload","handlebars","source-map"], function(require, exports, module){ |
10762 | -/** | ||
10763 | - * 个人中心--意见反馈 | ||
10764 | - * @author: chenglong<chenglong.wang@yoho.cn> | ||
10765 | - * @date: 2015/11/12 | ||
10766 | - */ | ||
10767 | - | ||
10768 | - | ||
10769 | -var $ = require("jquery"), | ||
10770 | - Hammer = require("hammer"), | ||
10771 | - lazyLoad = require("lazyload"), | ||
10772 | - Handlebars = require("handlebars"); | ||
10773 | - | ||
10774 | -var diaLog = require("js/me/dialog"); | ||
10775 | - | ||
10776 | -var $uploadImgList = $('.upload-img-list'), | ||
10777 | - headerNavHammer, | ||
10778 | - formHammer, | ||
10779 | - imgTpl, | ||
10780 | - imgTemplate, | ||
10781 | - $likeBtn = $('.suggest-item .like-btn'), | ||
10782 | - $disLikeBtn = $('.suggest-item .dislike-btn'), | ||
10783 | - $imgAdd = $('.img-add'), | ||
10784 | - imgStr = '', | ||
10785 | - uploadImgNum = 0; | ||
10786 | - | ||
10787 | -require("js/me/jquery.upload"); | ||
10788 | - | ||
10789 | -imgTpl = '{{# imgList}}' + | ||
10790 | - '<li>' + | ||
10791 | - '{{# imgUrl}}<img src="{{.}}" />' + | ||
10792 | - '<span class="upload-img-remove"></span>{{/ imgUrl}}' + | ||
10793 | - '</li>' + | ||
10794 | - '{{/ imgList}}'; | ||
10795 | - | ||
10796 | -imgTemplate = Handlebars.compile(imgTpl); | ||
10797 | - | ||
10798 | -$('#upload-img').upload({ | ||
10799 | - auto: true, | ||
10800 | - fileType: 'image/*', | ||
10801 | - uploadScript: '/home/suggestimgUpload', | ||
10802 | - fileObjName: 'fileData', | ||
10803 | - fileSizeLimit: 300, | ||
10804 | - height: '100%', | ||
10805 | - width: '100%', | ||
10806 | - multi: false, | ||
10807 | - onAddQueueItem: function(files) { | ||
10808 | - | ||
10809 | - //TODO | ||
10810 | - $uploadImgList.html(imgTemplate({ | ||
10811 | - imgList: true | ||
10812 | - })); | ||
10813 | - }, | ||
10814 | - onUploadComplete: function(file, data) { | ||
10815 | - $uploadImgList.html(''); | ||
10816 | - imgStr = JSON.parse(data).imgList[0].imgRelUrl; | ||
10817 | - $uploadImgList.html(imgTemplate(JSON.parse(data))); | ||
10818 | - $imgAdd.hide(); | ||
10819 | - uploadImgNum++; | ||
10820 | - } | ||
10821 | -}); | ||
10822 | - | ||
10823 | -lazyLoad(); | ||
10824 | - | ||
10825 | -headerNavHammer = new Hammer(document.getElementById('yoho-header')); | ||
10826 | - | ||
10827 | -headerNavHammer.on('tap', function(e) { | ||
10828 | - var suggestText = $('#suggest-textarea').val(), | ||
10829 | - textReg = /\S+/; | ||
10830 | - | ||
10831 | - | ||
10832 | - if ($(e.target).hasClass('nav-btn')) { | ||
10833 | - | ||
10834 | - if (!textReg.test(suggestText)) { | ||
10835 | - diaLog.showDialog({ | ||
10836 | - autoHide: true, | ||
10837 | - dialogText: '意见不能为空' | ||
10838 | - }); | ||
10839 | - | ||
10840 | - return; | ||
10841 | - } | ||
10842 | - | ||
10843 | - $.ajax({ | ||
10844 | - method: 'post', | ||
10845 | - url: '/home/savesuggest', | ||
10846 | - data: { | ||
10847 | - content: suggestText, | ||
10848 | - image: imgStr | ||
10849 | - } | ||
10850 | - }).then(function(data) { | ||
10851 | - if (data.code === 200) { | ||
10852 | - diaLog.showDialog({ | ||
10853 | - autoHide: true, | ||
10854 | - dialogText: '提交成功' | ||
10855 | - }); | ||
10856 | - setTimeout(function() { | ||
10857 | - location.pathname = 'home/suggest'; | ||
10858 | - }, 2000); | ||
10859 | - } else { | ||
10860 | - diaLog.showDialog({ | ||
10861 | - autoHide: true, | ||
10862 | - dialogText: '提交失败~' | ||
10863 | - }); | ||
10864 | - } | ||
10865 | - }).fail(function() { | ||
10866 | - | ||
10867 | - diaLog.showDialog({ | ||
10868 | - autoHide: true, | ||
10869 | - dialogText: '网络错误~' | ||
10870 | - }); | ||
10871 | - }); | ||
10872 | - } | ||
10873 | -}); | ||
10874 | - | ||
10875 | -if (document.getElementById('img-form') !== null) { | ||
10876 | - formHammer = new Hammer(document.getElementById('img-form')); | ||
10877 | - | ||
10878 | - formHammer.on('tap', function(e) { | ||
10879 | - if ($(e.target).hasClass('upload-img-remove')) { | ||
10880 | - $uploadImgList.html(''); | ||
10881 | - imgStr = ''; | ||
10882 | - uploadImgNum--; | ||
10883 | - setTimeout(function() { | ||
10884 | - $imgAdd.show(); | ||
10885 | - }, 50); | ||
10886 | - | ||
10887 | - } | ||
10888 | - }); | ||
10889 | -} | ||
10890 | - | ||
10891 | -// 点赞与取消点赞 | ||
10892 | -$likeBtn.bind('click', function() { | ||
10893 | - | ||
10894 | - var id = $(this).closest('.suggest-item').attr('data-id'), | ||
10895 | - $that = $(this); | ||
10896 | - | ||
10897 | - $.ajax({ | ||
10898 | - method: 'post', | ||
10899 | - url: '/home/upAndDown', | ||
10900 | - data: { | ||
10901 | - suggest_id: id, | ||
10902 | - reliable: 1 | ||
10903 | - } | ||
10904 | - }).then(function(data) { | ||
10905 | - if (data.code === 200) { | ||
10906 | - $that.closest('.suggest-type').removeClass('show'); | ||
10907 | - $that.closest('.suggest-item').find('.suggest-good').addClass('show'); | ||
10908 | - } | ||
10909 | - }).fail(function(data) { | ||
10910 | - | ||
10911 | - //TODO | ||
10912 | - | ||
10913 | - diaLog.showDialog({ | ||
10914 | - autoHide: true, | ||
10915 | - dialogText: '网络错误~' | ||
10916 | - }); | ||
10917 | - }); | ||
10918 | -}); | ||
10919 | - | ||
10920 | -$disLikeBtn.bind('click', function() { | ||
10921 | - | ||
10922 | - var id = $(this).closest('.suggest-item').attr('data-id'), | ||
10923 | - $that = $(this); | ||
10924 | - | ||
10925 | - $.ajax({ | ||
10926 | - method: 'post', | ||
10927 | - url: '/home/upAndDown', | ||
10928 | - data: { | ||
10929 | - suggest_id: id, | ||
10930 | - reliable: 2 | ||
10931 | - } | ||
10932 | - }).then(function(data) { | ||
10933 | - if (data.code === 200) { | ||
10934 | - $that.closest('.suggest-type').removeClass('show'); | ||
10935 | - $that.closest('.suggest-item').find('.suggest-bad').addClass('show'); | ||
10936 | - } | ||
10937 | - }).fail(function(data) { | ||
10938 | - | ||
10939 | - //TODO | ||
10940 | - | ||
10941 | - diaLog.showDialog({ | ||
10942 | - autoHide: true, | ||
10943 | - dialogText: '网络错误~' | ||
10944 | - }); | ||
10945 | - }); | 10762 | +/** |
10763 | + * 个人中心--意见反馈 | ||
10764 | + * @author: chenglong<chenglong.wang@yoho.cn> | ||
10765 | + * @date: 2015/11/12 | ||
10766 | + */ | ||
10767 | + | ||
10768 | + | ||
10769 | +var $ = require("jquery"), | ||
10770 | + Hammer = require("hammer"), | ||
10771 | + lazyLoad = require("lazyload"), | ||
10772 | + Handlebars = require("handlebars"); | ||
10773 | + | ||
10774 | +var diaLog = require("js/me/dialog"); | ||
10775 | + | ||
10776 | +var $uploadImgList = $('.upload-img-list'), | ||
10777 | + headerNavHammer, | ||
10778 | + formHammer, | ||
10779 | + imgTpl, | ||
10780 | + imgTemplate, | ||
10781 | + $likeBtn = $('.suggest-item .like-btn'), | ||
10782 | + $disLikeBtn = $('.suggest-item .dislike-btn'), | ||
10783 | + $imgAdd = $('.img-add'), | ||
10784 | + imgStr = '', | ||
10785 | + uploadImgNum = 0; | ||
10786 | + | ||
10787 | +require("js/me/jquery.upload"); | ||
10788 | + | ||
10789 | +imgTpl = '{{# imgList}}' + | ||
10790 | + '<li>' + | ||
10791 | + '{{# imgUrl}}<img src="{{.}}" />' + | ||
10792 | + '<span class="upload-img-remove"></span>{{/ imgUrl}}' + | ||
10793 | + '</li>' + | ||
10794 | + '{{/ imgList}}'; | ||
10795 | + | ||
10796 | +imgTemplate = Handlebars.compile(imgTpl); | ||
10797 | + | ||
10798 | +$('#upload-img').upload({ | ||
10799 | + auto: true, | ||
10800 | + fileType: 'image/*', | ||
10801 | + uploadScript: '/home/suggestimgUpload', | ||
10802 | + fileObjName: 'fileData', | ||
10803 | + fileSizeLimit: 300, | ||
10804 | + height: '100%', | ||
10805 | + width: '100%', | ||
10806 | + multi: false, | ||
10807 | + onAddQueueItem: function(files) { | ||
10808 | + | ||
10809 | + //TODO | ||
10810 | + $uploadImgList.html(imgTemplate({ | ||
10811 | + imgList: true | ||
10812 | + })); | ||
10813 | + }, | ||
10814 | + onUploadComplete: function(file, data) { | ||
10815 | + $uploadImgList.html(''); | ||
10816 | + imgStr = JSON.parse(data).imgList[0].imgRelUrl; | ||
10817 | + $uploadImgList.html(imgTemplate(JSON.parse(data))); | ||
10818 | + $imgAdd.hide(); | ||
10819 | + uploadImgNum++; | ||
10820 | + } | ||
10821 | +}); | ||
10822 | + | ||
10823 | +lazyLoad(); | ||
10824 | + | ||
10825 | +headerNavHammer = new Hammer(document.getElementById('yoho-header')); | ||
10826 | + | ||
10827 | +headerNavHammer.on('tap', function(e) { | ||
10828 | + var suggestText = $('#suggest-textarea').val(), | ||
10829 | + textReg = /\S+/; | ||
10830 | + | ||
10831 | + | ||
10832 | + if ($(e.target).hasClass('nav-btn')) { | ||
10833 | + | ||
10834 | + if (!textReg.test(suggestText)) { | ||
10835 | + diaLog.showDialog({ | ||
10836 | + autoHide: true, | ||
10837 | + dialogText: '意见不能为空' | ||
10838 | + }); | ||
10839 | + | ||
10840 | + return; | ||
10841 | + } | ||
10842 | + | ||
10843 | + $.ajax({ | ||
10844 | + method: 'post', | ||
10845 | + url: '/home/savesuggest', | ||
10846 | + data: { | ||
10847 | + content: suggestText, | ||
10848 | + image: imgStr | ||
10849 | + } | ||
10850 | + }).then(function(data) { | ||
10851 | + if (data.code === 200) { | ||
10852 | + diaLog.showDialog({ | ||
10853 | + autoHide: true, | ||
10854 | + dialogText: '提交成功' | ||
10855 | + }); | ||
10856 | + setTimeout(function() { | ||
10857 | + location.pathname = 'home/suggest'; | ||
10858 | + }, 2000); | ||
10859 | + } else { | ||
10860 | + diaLog.showDialog({ | ||
10861 | + autoHide: true, | ||
10862 | + dialogText: '提交失败~' | ||
10863 | + }); | ||
10864 | + } | ||
10865 | + }).fail(function() { | ||
10866 | + | ||
10867 | + diaLog.showDialog({ | ||
10868 | + autoHide: true, | ||
10869 | + dialogText: '网络错误~' | ||
10870 | + }); | ||
10871 | + }); | ||
10872 | + } | ||
10873 | +}); | ||
10874 | + | ||
10875 | +if (document.getElementById('img-form') !== null) { | ||
10876 | + formHammer = new Hammer(document.getElementById('img-form')); | ||
10877 | + | ||
10878 | + formHammer.on('tap', function(e) { | ||
10879 | + if ($(e.target).hasClass('upload-img-remove')) { | ||
10880 | + $uploadImgList.html(''); | ||
10881 | + imgStr = ''; | ||
10882 | + uploadImgNum--; | ||
10883 | + setTimeout(function() { | ||
10884 | + $imgAdd.show(); | ||
10885 | + }, 50); | ||
10886 | + | ||
10887 | + } | ||
10888 | + }); | ||
10889 | +} | ||
10890 | + | ||
10891 | +// 点赞与取消点赞 | ||
10892 | +$likeBtn.bind('click', function() { | ||
10893 | + | ||
10894 | + var id = $(this).closest('.suggest-item').attr('data-id'), | ||
10895 | + $that = $(this); | ||
10896 | + | ||
10897 | + $.ajax({ | ||
10898 | + method: 'post', | ||
10899 | + url: '/home/upAndDown', | ||
10900 | + data: { | ||
10901 | + suggest_id: id, | ||
10902 | + reliable: 1 | ||
10903 | + } | ||
10904 | + }).then(function(data) { | ||
10905 | + if (data.code === 200) { | ||
10906 | + $that.closest('.suggest-type').removeClass('show'); | ||
10907 | + $that.closest('.suggest-item').find('.suggest-good').addClass('show'); | ||
10908 | + } | ||
10909 | + }).fail(function(data) { | ||
10910 | + | ||
10911 | + //TODO | ||
10912 | + | ||
10913 | + diaLog.showDialog({ | ||
10914 | + autoHide: true, | ||
10915 | + dialogText: '网络错误~' | ||
10916 | + }); | ||
10917 | + }); | ||
10918 | +}); | ||
10919 | + | ||
10920 | +$disLikeBtn.bind('click', function() { | ||
10921 | + | ||
10922 | + var id = $(this).closest('.suggest-item').attr('data-id'), | ||
10923 | + $that = $(this); | ||
10924 | + | ||
10925 | + $.ajax({ | ||
10926 | + method: 'post', | ||
10927 | + url: '/home/upAndDown', | ||
10928 | + data: { | ||
10929 | + suggest_id: id, | ||
10930 | + reliable: 2 | ||
10931 | + } | ||
10932 | + }).then(function(data) { | ||
10933 | + if (data.code === 200) { | ||
10934 | + $that.closest('.suggest-type').removeClass('show'); | ||
10935 | + $that.closest('.suggest-item').find('.suggest-bad').addClass('show'); | ||
10936 | + } | ||
10937 | + }).fail(function(data) { | ||
10938 | + | ||
10939 | + //TODO | ||
10940 | + | ||
10941 | + diaLog.showDialog({ | ||
10942 | + autoHide: true, | ||
10943 | + dialogText: '网络错误~' | ||
10944 | + }); | ||
10945 | + }); | ||
10946 | }); | 10946 | }); |
10947 | }); | 10947 | }); |
10948 | define("js/me/jquery.upload", ["jquery"], function(require, exports, module){ | 10948 | 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.
-
Please register or login to post a comment