/** * PLUS+STAR详情页 * @author: xuqi<qi.xu@yoho.cn> * @date: 2015/10/10 */ require('guang/plustar-detail.page.css'); let $ = require('yoho-jquery'), Hammer = require('common/toy-hammer'), lazyLoad = require('yoho-jquery-lazyload'); let $intro = $('#intro'), $imt = $('#intro-more-txt'), $infosContainer = $('#related-infos-container'), uid = $('input[name="uid"]').val(); let info = require('./info'); let tip = require('plugin/tip'); let brandId = $('#brand-info').data('id'); let jumpToApp = $('#jump-to-app').val(); let mIntro, aIntro, logoImg; let likeHammer; require('plugin/wx-share'); require('common'); require('./plustar-detail-render')(function() { lazyLoad($('img.lazy')); }); // Init LazyLoad lazyLoad($('img.lazy')); $('.logo').attr('src', logoImg); // 获取截取文字和完整文字 setTimeout(function() { $intro.css('height', 'auto'); mIntro = $intro.text(); aIntro = $intro.attr('title'); }); info.initInfosEvt($infosContainer); // 文字介绍收起与展开 $('#more-intro-click-range').on('click', function(e) { let $this = $imt.parent(); e.preventDefault(); // 防止收缩后误点到商品产生跳转 $this.toggleClass('spread'); if ($this.hasClass('spread')) { // 显示 $intro.text(aIntro); $imt.text('收起'); } else { // 隐藏 $intro.text(mIntro); $imt.text('more'); $(window).scrollTop(0, 400); // 滑动到顶部 } }); if ($('#brand-like').length) { // 品牌收藏 likeHammer = new Hammer(document.getElementById('brand-like')); likeHammer.on('tap', function(e) { let opt = 'ok', $this = $(e.target); // jumpToApp = 1表示APP未登录的情况,此时不发送ajax请求而由a链接直接跳转APP // if (jumpToApp === '1') { // return true; // } e.srcEvent.preventDefault(); if ($this.hasClass('like')) { opt = 'cancel'; } $.ajax({ type: 'POST', url: '/guang/opt/favoriteBrand', data: { id: brandId, opt: opt, uid: uid, isBrand: 'brand' }, success: function(data) { if (data.code === 200) { $this.toggleClass('like'); tip.show(data.message); } else if (data.code === 400 || data.code === 412) { if (jumpToApp === '1') { let url = location.href + '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/guang.m.yohobuy.com\/plustar\/brandinfo","param":{"id":' + // eslint-disable-line window.queryString.id + '}},"requesturl":{"url":"\/guang\/api\/v1\/favorite\/togglebrand","param":{"brand_id":"' + $('#brand-info').data('id') + '"}},"priority":"Y"}}'; // eslint-disable-line $('body').append('<a href=' + url + ' style="display:none;"><span class="jump-login"> </span></a>'); $('.jump-login').click(); } else { location.href = data.data; // 未登录跳转登录页面 } } else { tip.show(data.message); } } }); return false; }); } // console.log($('.logo').attr('src'))