good.php页面

 

/*------------------------------------------------------ */
//取得全国一级城市信息  for nopost QQ:859898918
/*------------------------------------------------------ */
function get_region_name(){
$sql="SELECT * FROM ecs_region WHERE parent_id ='1';";
return $GLOBALS['db']->getAll($sql);
}
/*------------------------------------------------------ */
//:取得商品的重量  for nopost QQ:859898918
/*------------------------------------------------------ */
function get_goods_weight($goods_id){
$sql="select goods_weight from ecs_goods where goods_id = '$goods_id';";
$rs = $GLOBALS['db']->getAll($sql);
return $rs[0]['goods_weight'];
}
//传给smarty模板
$smarty->assign('tc_goods_weight',get_goods_weight($goods_id));//商品重量
$smarty->assign('regionname',get_region_name()); //全国一级省市

 

 good.dwt页面

 

< script>
/*  运费JS */
function createCityList(elem){
 var e=event || window.event;
 var xx = e.clientX;
 var yy = e.clientY;
 $$("showList").style.display='block';
 $$("showList").style.left=xx+'px';
 $$("showList").style.top=yy+'px'; 
}
function changeCity(cityname,regid){
 var tc_goodsweight = Math.ceil($$("hiddenprice").innerText); //取得商品重量
 $$("flowcity").innerText=cityname;
 if(tc_goodsweight== 0)
  tc_goodsweight=1;
 else
  tc_goodsweight=tc_goodsweight;
 //北京
 if(regid==2){
  initprice();
 }
 //河北 天津
 else if(regid==27 || regid==10){  
  if(tc_goodsweight==1){
   $$("tc_flowprice").innerText= "8"; //首重
  }else{
   $$("tc_flowprice").innerText= ((tc_goodsweight - 1)*3 + 8 ); //续3
  } 
 }
 //新疆 西藏
 else if(regid==28 || regid==29){
  if(tc_goodsweight==1){
   $$("tc_flowprice").innerText= "20"; //首重
  }else{
   $$("tc_flowprice").innerText= ((tc_goodsweight - 1)*10 + 20 );//续10
  }
 }
 //香港
 else if(regid==33){
  if(tc_goodsweight==1){
   $$("tc_flowprice").innerText= "25"; //首重
  }else{
   $$("tc_flowprice").innerText= ((tc_goodsweight - 1)*10 + 25 );//续10
  }
 }
 //澳门
 else if(regid==34){
  if(tc_goodsweight==1){
   $$("tc_flowprice").innerText= "35"; //首重
  }else{
   $$("tc_flowprice").innerText= ((tc_goodsweight - 1)*20 + 35 );//续20
  }
 }
 //台湾
 else if(regid==35){
  if(tc_goodsweight==1){
   $$("tc_flowprice").innerText= "30"; //首重
  }else{
   $$("tc_flowprice").innerText= ((tc_goodsweight - 1)*28 + 30 );//续28
  }
 }
 //其他
 else{
  if(tc_goodsweight==1){
   $$("tc_flowprice").innerText= "10"; //首重
  }else{
   $$("tc_flowprice").innerText= ((tc_goodsweight - 1)*5 + 10 );//续5
  }
 }
 
 $$("showList").style.display='none';
}
function hideCityList(){
 $$("showList").style.display='none';
}
</script>

 

……

 

 

 

 

 
      <li>
       <dd>
       <!-- {if $goods.goods_brand neq "" and $cfg.show_brand} 显示商品品牌-->
       <strong>{$lang.goods_brand}</strong><a href="{$goods.goods_brand_url}" >{$goods.goods_brand}</a>
       <!--{/if}-->
       </dd>
       <dd>     
                     至 <label onmouseover="createCityList(this);" onmouseout="hideCityList();"  id="flowcity">{$mycity}</label><img src="images/selectcity.jpg" /> <label id="tc_flowprice">平邮:{$p_fee}元  快递:{$s_fee}元  EMS{$e_fee} 元</label> <br />
     
        <div id="showList" style="position:absolute;border:2px solid #ccc; display:none;font-size:12px; padding:5px; background:#fff; width:260px; z-index:99999" onmousemove="this.style.display='block'"; onmouseout="this.style.display='none'"> 
    <div id="hiddenprice" style="display:none;">{$tc_goods_weight.goods_weight}</div>
    <!--{foreach from=$regionname item=region_names}-->
     <a href="javascript:" onclick="changeCity(this.innerText,{$region_names.region_id})">{$region_names.region_name}</a>
    <!--{/foreach}-->
        </dd>
      </li>
      <li>
       <dd>
       <!-- {if $cfg.show_addtime} 上架时间-->
      <strong>{$lang.add_time}</strong>{$goods.add_time}
      <!-- {/if} -->
       </dd>
       <dd>
       <!--点击数-->
       <strong>{$lang.goods_click_count}:</strong>{$goods.click_count}
       </dd>
      </li>

 

……

 

<!-- {literal} -->
onload = function(){
  changePrice();
  fixpng();
  //initprice(); //tc:初始化运费信息
  try { onload_leftTime(); }
  catch (e) {}
}

 

/**
 * 运费相关
 */
function initprice(){
var tc_goodsweight = Math.ceil($$("hiddenprice").innerText);
tc_goodsweight == 0 ? 1 : tc_goodsweight;
if(tc_goodsweight <=5)
  $$("tc_flowprice").innerText = '5';
if(tc_goodsweight >=5 && tc_goodsweight<=10)
  $$("tc_flowprice").innerText = '10';
if(tc_goodsweight >=10 && tc_goodsweight<=15)
  $$("tc_flowprice").innerText = '15';
if(tc_goodsweight >=15 && tc_goodsweight<=20)
  $$("tc_flowprice").innerText = '20';
}

 

/**
 * 点选可选属性或改变数量时修改商品价格的函数
 */
function changePrice()
{
  var attr = getSelectedAttributes(document.forms['ECS_FORMBUY']);
  var qty = document.forms['ECS_FORMBUY'].elements['number'].value;

 

  Ajax.call('goods.php', 'act=price&id=' + goodsId + '&attr=' + attr + '&number=' + qty, changePriceResponse, 'GET', 'JSON');
}

 

/**
 * 接收返回的信息
 */
function changePriceResponse(res)
{
  if (res.err_msg.length > 0)
  {
    alert(res.err_msg);
  }
  else
  {
    document.forms['ECS_FORMBUY'].elements['number'].value = res.qty;

 

    if (document.getElementById('ECS_GOODS_AMOUNT'))
      document.getElementById('ECS_GOODS_AMOUNT').innerHTML = res.result;
  }
}
<!-- {/literal} -->
</script>
</html>