标签归档:淘宝

仿淘宝运费-无错JS修改版

 

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>

 

TAOAPI名片–淘宝开放平台!

淘宝开放平台(即TOP,无特别说明下文中TOP即指淘宝开放平台)对各类合作伙伴所提供的产品可以概括为两个平台,三条支撑主线。两个平台指的是Open.taobao.com和App.taobao.com ;三条支撑主线是开放数据和业务流程、开放淘宝自有插件平台、开放对外接入标准,关于这两个产品和三条业务支撑线的详细介绍如下:

Open.taobao.com介绍  

  Open.taobao.com所服务的对象是淘宝的各类合作伙伴。目前这些合作伙伴根据其开发方向不同可以分为:
TOP开发者 ——即利用TOP所提供的产品进行独自开发的自由开发者,如淘宝客开发群体、卖家工具开发群体、社区插件开发群体等,这些开发者既包括个人开发者也包括开发团队和公司;
淘宝商家——即淘宝商城商家或集市大C卖家;利用TOP所提供的接口淘宝商家可以开发出个性的系统或工具从而更加高效的管理店铺,如商品发布、订单管理、库存更新等。
淘拍档 ——即TaoBao Partner,是指加入淘宝合作伙伴计划的各类外包服务提供商,服务范围涵盖IT技术、市场研究、客户服务等领域,服务的对象主要是淘宝网海量的商家。淘拍档在提供外部服务的过程中所有的数据或业务流程接口将由TOP提供。
淘江湖合作伙伴 ——目前淘江湖插件主要的操作方式是定向引入,这些定向引入的SNS插件开发公司也将通过TOP所提供的服务去完成其自身产品的开发工作。  

根据各类合作伙伴开发的目的不同也可以将这些合作伙伴分为自用型开发者 和他用型开发者 :
自用型开发者 ——即使用TOP开放的服务来定制和创新自身产品的开发者,不对外销售,也不提供给第三方使用。这种用户的典型例子有:大商家自定义开发自己的店铺管理系统、自己的外部独立网店如Uniqlo.cn;淘宝客开发者创建的导购网站。他们的产品是自己经营,而不对外销售的。
他用型开发者 ——即将自己开发的应用程序和服务提供给他人使用(包括有偿的,也包括无偿的),如在淘宝应用商店进行销售。
Open.taobao.com上内容可以分为两部分:
一是基于TOP开发所必需了解的各类文档如开发文档、商业文档,同时open.taobao.com还提供了开发者的交流平台和竞赛平台。
二是合作伙伴的个人管理中心,即我的工作台,在这里开发者可以申请开发TOP应用、上线发布、对应用信息和数据进行管理等。
 

App.taobao.com介绍  

   App.taobao.com即淘宝应用商店将于2010年Q1发布,是面向应用终端使用者的在线应用销售平台,针对用户群体主要为:商家、卖家、买家、社区。TOP开发者这个群体在Open.taobao.com所开发的正式上线的他用型应用,在符合 TOP运营政策的前提下,应用都可以申请在淘宝应用商店上架,淘宝应用商店为开发者提供更加丰富的价格策略模型,要为开发者提供支付和结算系统,要建立统一的用户订购和操作体验。

淘宝应用商店在前期提供免费和月租型付费两种价格策略:
免费,即用户可以无偿使用开发者所提供的应用
月租型付费,即用户付出一定的费用,从而可以在指定期间内享受某项服务,为了让开发者更好的尝试我们的付费策略,我们在月租型付费策略中引入了免费试用期的概念,终端用户可以在免费试用之后再决定是否要购买某个付费产品,免费时长可以由开发者选择。 
TOP的三条支撑主线    开放数据和业务流程
以API数据形式开放商品、交易、物流等业务;
以流程页面化方式开放标准业务流程,和支持将来的多步骤多状态数据自定义。
   开放淘宝自有插件平台
淘宝B/S插件平台:旺铺管理平台、淘宝江湖插件平台;
淘宝C/S插件平台:任我淘。
   开放对外接入标准
允许外部站点与淘宝用户体系打通,平滑使用淘宝业务数据,将淘宝自身业务与站外业务结合起来。