[未测试]仿淘宝运费 提取到商品详细页面
来源:互联网 发布:数组冒泡排序php 编辑:程序博客网 时间:2024/04/29 17:09
方法:此方法没有调用数据库里那个,而是用JS实现的。
步骤:
1.goods.php(红色为增加的代码)
大概33行:
$goods_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
$smarty->assign('tc_goods_weight',get_goods_weight($goods_id));//tc:取得商品重量
$smarty->assign('regionname',get_region_name()); //tc:取得全国一级省市
然后在代码尾部加上两个函数:
//tc:取得全国一级城市信息
function get_region_name(){
$sql="SELECT * FROM ".$GLOBALS['ecs']->table('region')." WHERE parent_id ='1';";
return $GLOBALS['db']->getAll($sql);
}
function get_goods_weight($goods_id){
$sql="select goods_weight from ".$GLOBALS['ecs']->table('goods')." where goods_id = '$goods_id';";
$rs = $GLOBALS['db']->getAll($sql);
return $rs[0]['goods_weight'];
}
找到:
<!-- {if $goods.goods_brand neq "" and $cfg.show_brand} 显示商品品牌-->
{$lang.goods_brand}<a href="{$goods.goods_brand_url}" >{$goods.goods_brand}</a><br />
<!--{/if}-->
至 <label id="flowcity">北京</label><img src="images/selectcity.jpg" /> : 快递 <label id="tc_flowprice"></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";>
<div id="hiddenprice" style="display:none;">{$tc_goods_weight.goods_weight}</div>
<!--{foreach from=$regionname item=region_names}-->
<a href="javascript:">{$region_names.region_name}</a>
<!--{/foreach}-->
最后就是JS:
<!-- {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';
}
在head的JS里加上函数
/* tc 运费JS */
function createCityList(elem){
var xx = event.clientX;
var yy = event.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 );//续10
}
}
//台湾
else if(regid==35){
if(tc_goodsweight==1){
$("tc_flowprice").innerText= "30"; //首重
}else{
$("tc_flowprice").innerText= ((tc_goodsweight - 1)*28 + 30 );//续10
}
}
//其他
else{
if(tc_goodsweight==1){
$("tc_flowprice").innerText= "10"; //首重
}else{
$("tc_flowprice").innerText= ((tc_goodsweight - 1)*5 + 10 );//续10
}
}
$("showList").style.display='none';
}
function hideCityList(){
$("showList").style.display='none';
}
步骤:
1.goods.php(红色为增加的代码)
大概33行:
$goods_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
$smarty->assign('tc_goods_weight',get_goods_weight($goods_id));//tc:取得商品重量
$smarty->assign('regionname',get_region_name()); //tc:取得全国一级省市
然后在代码尾部加上两个函数:
//tc:取得全国一级城市信息
function get_region_name(){
$sql="SELECT * FROM ".$GLOBALS['ecs']->table('region')." WHERE parent_id ='1';";
return $GLOBALS['db']->getAll($sql);
}
function get_goods_weight($goods_id){
$sql="select goods_weight from ".$GLOBALS['ecs']->table('goods')." where goods_id = '$goods_id';";
$rs = $GLOBALS['db']->getAll($sql);
return $rs[0]['goods_weight'];
}
找到:
<!-- {if $goods.goods_brand neq "" and $cfg.show_brand} 显示商品品牌-->
{$lang.goods_brand}<a href="{$goods.goods_brand_url}" >{$goods.goods_brand}</a><br />
<!--{/if}-->
至 <label id="flowcity">北京</label><img src="images/selectcity.jpg" /> : 快递 <label id="tc_flowprice"></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";>
<div id="hiddenprice" style="display:none;">{$tc_goods_weight.goods_weight}</div>
<!--{foreach from=$regionname item=region_names}-->
<a href="javascript:">{$region_names.region_name}</a>
<!--{/foreach}-->
最后就是JS:
<!-- {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';
}
在head的JS里加上函数
/* tc 运费JS */
function createCityList(elem){
var xx = event.clientX;
var yy = event.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 );//续10
}
}
//台湾
else if(regid==35){
if(tc_goodsweight==1){
$("tc_flowprice").innerText= "30"; //首重
}else{
$("tc_flowprice").innerText= ((tc_goodsweight - 1)*28 + 30 );//续10
}
}
//其他
else{
if(tc_goodsweight==1){
$("tc_flowprice").innerText= "10"; //首重
}else{
$("tc_flowprice").innerText= ((tc_goodsweight - 1)*5 + 10 );//续10
}
}
$("showList").style.display='none';
}
function hideCityList(){
$("showList").style.display='none';
}
- [未测试]仿淘宝运费 提取到商品详细页面
- 仿淘宝运费地区设置
- 仿淘宝商品详情页面Android
- 仿淘宝商品详情页面下拉黏滞效果
- 仿淘宝商品详情页面标题下拉渐变效果
- ios仿淘宝商品详情页面粘贴商品规格弹出模板
- 仿淘宝商品列表切换
- 仿淘宝详细页面图片放大镜的制作过程
- 仿淘宝商品详情,下拉切换到图片详情,上拉切换到图文简介
- 仿淘宝商品详细页(上拉阻尼效果以及第二页View Page滑动)
- Android中仿淘宝商品详情ViewPager页面数据手动滑动
- 仿淘宝商品详情页中(继续拖动到图文详情)
- 仿淘宝首页商品分类列表效果
- ecshop商品属性仿淘宝选择功能
- ecshop商品属性仿淘宝选择功能
- Android 仿淘宝商品属性动画
- 仿淘宝— 商品图片切换
- 仿淘宝商品展示的viewpager
- 更改数据库密码
- LNAMP(Debian + Nginx + Apache + Mysql + PHP)配置笔记
- 根据反射机制测试private方法(junit测试)
- 简单字符设备驱动的编写
- Extjs , Ext.selection.Mode 实现行多选功能
- [未测试]仿淘宝运费 提取到商品详细页面
- 求二进制数中1的个数
- dedecms进行网站搬家
- AICC和 ADL宣布合作计划
- 黑马程序员_JavaSE基础11 之 异常 objcet类一些方法
- 简单三部实现导航分类二级菜单
- 高性能大容量SOCKET并发(二):IOCP完成端口控件封装
- 成为java高手的25个目标
- U-boot 启动内核过程