通过本教程可以实现ECSHOP购买商品选择属 时弹出层来选择:
1.在commen.js中
找到
function addToCartResponse(result)
中的
else if (result.error == 6)
{
openSpeDiv(result.message, result.goods_id, result.parent);
}
将if中的内容换为
openSpeDiv(result.message, result.goods_id, result.parent,result.goods_title,result.goods_thumb,result.goods_name);
将
function openSpeDiv(message, goods_id, parent)
整个函数,替换为
function openSpeDiv(message, goods_id, parent,goods_title,goods_thumb,goods_name) { var _id = "speDiv"; var m = "mask"; if (docEle(_id)) document.removeChild(docEle(_id)); if (docEle(m)) document.removeChild(docEle(m)); //计算上卷元素值 var scrollPos; if (typeof window.pageYOffset != 'undefined') { scrollPos = window.pageYOffset; } else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') { scrollPos = document.documentElement.scrollTop; } else if (typeof document.body != 'undefined') { scrollPos = document.body.scrollTop; } var i = 0; var sel_obj = document.getElementsByTagName('select'); while (sel_obj[i]) { sel_obj[i].style.visibility = "hidden"; i++; } // 新激活图层 var newDiv = document.createElement("div"); newDiv.id = _id; newDiv.style.position = "absolute"; newDiv.style.zIndex = "10000"; newDiv.style.width = "500px"; newDiv.style.height = "380px"; newDiv.style.top = (parseInt(scrollPos + 200)) + "px"; newDiv.style.left = (parseInt(document.body.offsetWidth) - 400) / 2 + "px"; // 屏幕居中 newDiv.style.background = "#fff"; newDiv.style.border = "5px solid #ffcae3"; var html = ''; //生成层内内容 html = '
产品购买关闭'+goods_title+'
'; html += '
'; html +='
品名: | '+goods_name+' |
'; for (var spec = 0; spec < message.length; spec++) { html +=''; html +=''+message[spec]['name']+': | '; html +=''; html +=''; html +=' | ' html +='
'; } html += '
'; html +=''; html +="
"; html +=''; newDiv.innerHTML = html; document.body.appendChild(newDiv); // mask图层 var newMask = document.createElement("div"); newMask.id = m; newMask.style.position = "absolute"; newMask.style.zIndex = "9999"; newMask.style.width = document.body.scrollWidth + "px"; newMask.style.height = document.body.scrollHeight + "px"; newMask.style.top = "0px"; newMask.style.left = "0px"; newMask.style.background = "#FFF"; newMask.style.filter = "alpha(opacity=30)"; newMask.style.opacity = "0.40"; document.body.appendChild(newMask);}
2.在flow.php中的
if ($_REQUEST['step'] == 'add_to_cart')
里
$result['error'] = ERR_NEED_SELECT_ATTR;
$result['goods_id'] = $goods->goods_id;
$result['parent'] = $goods->parent;
$result['message'] = $spe_array;
下面添加
$goods_row = $GLOBALS['db']->getRow("select goods_name,goods_title,goods_thumb from ".$GLOBALS['ecs']->table('goods')." where goods_id='".$goods->goods_id."'");$result['goods_title']= $goods_row['goods_title'];$result['goods_thumb']= $goods_row['goods_thumb'];$result['goods_name'] = $goods_row['goods_name'];
大功告成
-
联系我们
客服QQ
工作时间:8:00-18:00
客服QQ
379144319
电子邮件
379144319@qq.com
-
返回顶部