Authored by lore-w

商品列表bug修复 code review by liuyue

@@ -76,8 +76,6 @@ exports.init = function(num) { @@ -76,8 +76,6 @@ exports.init = function(num) {
76 76
77 productList.addHandler('MouseEnter', function(event) { 77 productList.addHandler('MouseEnter', function(event) {
78 78
79 -  
80 -  
81 var itemMr = 10, //list的右边距 79 var itemMr = 10, //list的右边距
82 itemMb = 35, //list的下边距 80 itemMb = 35, //list的下边距
83 ulStr = '', 81 ulStr = '',
@@ -90,11 +88,6 @@ exports.init = function(num) { @@ -90,11 +88,6 @@ exports.init = function(num) {
90 wrapperPt, //鼠标移入时弹层的上内边距 88 wrapperPt, //鼠标移入时弹层的上内边距
91 containerPt; //商品列表容器的上内边距 89 containerPt; //商品列表容器的上内边距
92 90
93 - $goodInfoMain.html('');  
94 - $goodSelectColor.html('');  
95 - $goodItemWrapper.css({  
96 - display: 'none'  
97 - });  
98 $.ajax({ 91 $.ajax({
99 type: 'POST', 92 type: 'POST',
100 url: '/product/list/getProductPic', 93 url: '/product/list/getProductPic',
@@ -104,6 +97,11 @@ exports.init = function(num) { @@ -104,6 +97,11 @@ exports.init = function(num) {
104 } 97 }
105 }).then(function(data) { 98 }).then(function(data) {
106 99
  100 + //setTimeout(function () {
  101 +
  102 + removeHtmlFn();
  103 +
  104 +
107 ulStr = createColorList(data).colorListStr; //ajax请求的颜色列表 105 ulStr = createColorList(data).colorListStr; //ajax请求的颜色列表
108 ulNum = createColorList(data).ulNum;//ajax请求的颜色的数量 106 ulNum = createColorList(data).ulNum;//ajax请求的颜色的数量
109 107
@@ -114,8 +112,9 @@ exports.init = function(num) { @@ -114,8 +112,9 @@ exports.init = function(num) {
114 wrapperPt = $goodItemWrapper.css('paddingTop'); 112 wrapperPt = $goodItemWrapper.css('paddingTop');
115 containerPt = $goodsContainer.css('paddingTop'); 113 containerPt = $goodsContainer.css('paddingTop');
116 114
117 - //wrapperWidth = 10 + (15 + 50) * ulNum + event.targetWidth;  
118 - wrapperWidth = $goodItemWrapper.width(); 115 + wrapperWidth = 10 + (15 + 50) * ulNum + event.targetWidth;
  116 +
  117 + //wrapperWidth = $goodItemWrapper.width();
119 118
120 wrapperX = (event.targetX - 1) * (event.targetWidth + itemMr) - (parseInt(wrapperPl) + 1); 119 wrapperX = (event.targetX - 1) * (event.targetWidth + itemMr) - (parseInt(wrapperPl) + 1);
121 wrapperY = (event.targetY - 1) * 120 wrapperY = (event.targetY - 1) *
@@ -135,16 +134,21 @@ exports.init = function(num) { @@ -135,16 +134,21 @@ exports.init = function(num) {
135 display: 'inline-block' 134 display: 'inline-block'
136 }); 135 });
137 136
  137 + //}, 1000);
138 }); 138 });
139 }); 139 });
140 140
141 $goodItemWrapper.mouseleave(function() { 141 $goodItemWrapper.mouseleave(function() {
  142 + removeHtmlFn();
  143 + });
  144 +
  145 + function removeHtmlFn() {
142 $goodInfoMain.html(''); 146 $goodInfoMain.html('');
143 $goodSelectColor.html(''); 147 $goodSelectColor.html('');
144 $goodItemWrapper.css({ 148 $goodItemWrapper.css({
145 display: 'none' 149 display: 'none'
146 }); 150 });
147 - }); 151 + }
148 }; 152 };
149 153
150 //鼠标放在颜色列表上效果 154 //鼠标放在颜色列表上效果
@@ -1550,6 +1550,31 @@ class Index1Controller extends AbstractAction @@ -1550,6 +1550,31 @@ class Index1Controller extends AbstractAction
1550 'url' => 'http://item.yohobuy.com/product/pro_187471_252595/NIKEAIRMAX90ESSENTIAL537384126.html', 1550 'url' => 'http://item.yohobuy.com/product/pro_187471_252595/NIKEAIRMAX90ESSENTIAL537384126.html',
1551 'src' => 'http://img12.static.yhbimg.com/goodsimg/2015/09/24/09/028738fa8afcf5031733bcdfa83e397f0f.jpg?imageMogr2/thumbnail/75x100/extent/75x100/background/d2hpdGU=/position/center/quality/90' 1551 'src' => 'http://img12.static.yhbimg.com/goodsimg/2015/09/24/09/028738fa8afcf5031733bcdfa83e397f0f.jpg?imageMogr2/thumbnail/75x100/extent/75x100/background/d2hpdGU=/position/center/quality/90'
1552 ), 1552 ),
  1553 + array(
  1554 + 'coverImg' => 'http://img12.static.yhbimg.com/goodsimg/2015/09/24/09/028738fa8afcf5031733bcdfa83e397f0f.jpg?imageMogr2/thumbnail/75x100/extent/75x100/background/d2hpdGU=/position/center/quality/90',
  1555 + 'url' => 'http://item.yohobuy.com/product/pro_187471_252595/NIKEAIRMAX90ESSENTIAL537384126.html',
  1556 + 'src' => 'http://img12.static.yhbimg.com/goodsimg/2015/09/24/09/028738fa8afcf5031733bcdfa83e397f0f.jpg?imageMogr2/thumbnail/75x100/extent/75x100/background/d2hpdGU=/position/center/quality/90'
  1557 + ),
  1558 + array(
  1559 + 'coverImg' => 'http://img12.static.yhbimg.com/goodsimg/2015/09/24/09/028738fa8afcf5031733bcdfa83e397f0f.jpg?imageMogr2/thumbnail/75x100/extent/75x100/background/d2hpdGU=/position/center/quality/90',
  1560 + 'url' => 'http://item.yohobuy.com/product/pro_187471_252595/NIKEAIRMAX90ESSENTIAL537384126.html',
  1561 + 'src' => 'http://img12.static.yhbimg.com/goodsimg/2015/09/24/09/028738fa8afcf5031733bcdfa83e397f0f.jpg?imageMogr2/thumbnail/75x100/extent/75x100/background/d2hpdGU=/position/center/quality/90'
  1562 + ),
  1563 + array(
  1564 + 'coverImg' => 'http://img12.static.yhbimg.com/goodsimg/2015/09/24/09/028738fa8afcf5031733bcdfa83e397f0f.jpg?imageMogr2/thumbnail/75x100/extent/75x100/background/d2hpdGU=/position/center/quality/90',
  1565 + 'url' => 'http://item.yohobuy.com/product/pro_187471_252595/NIKEAIRMAX90ESSENTIAL537384126.html',
  1566 + 'src' => 'http://img12.static.yhbimg.com/goodsimg/2015/09/24/09/028738fa8afcf5031733bcdfa83e397f0f.jpg?imageMogr2/thumbnail/75x100/extent/75x100/background/d2hpdGU=/position/center/quality/90'
  1567 + ),
  1568 + array(
  1569 + 'coverImg' => 'http://img12.static.yhbimg.com/goodsimg/2015/09/24/09/028738fa8afcf5031733bcdfa83e397f0f.jpg?imageMogr2/thumbnail/75x100/extent/75x100/background/d2hpdGU=/position/center/quality/90',
  1570 + 'url' => 'http://item.yohobuy.com/product/pro_187471_252595/NIKEAIRMAX90ESSENTIAL537384126.html',
  1571 + 'src' => 'http://img12.static.yhbimg.com/goodsimg/2015/09/24/09/028738fa8afcf5031733bcdfa83e397f0f.jpg?imageMogr2/thumbnail/75x100/extent/75x100/background/d2hpdGU=/position/center/quality/90'
  1572 + ),
  1573 + array(
  1574 + 'coverImg' => 'http://img12.static.yhbimg.com/goodsimg/2015/09/24/09/028738fa8afcf5031733bcdfa83e397f0f.jpg?imageMogr2/thumbnail/75x100/extent/75x100/background/d2hpdGU=/position/center/quality/90',
  1575 + 'url' => 'http://item.yohobuy.com/product/pro_187471_252595/NIKEAIRMAX90ESSENTIAL537384126.html',
  1576 + 'src' => 'http://img12.static.yhbimg.com/goodsimg/2015/09/24/09/028738fa8afcf5031733bcdfa83e397f0f.jpg?imageMogr2/thumbnail/75x100/extent/75x100/background/d2hpdGU=/position/center/quality/90'
  1577 + )
1553 ); 1578 );
1554 1579
1555 $this->echoJson($data); 1580 $this->echoJson($data);