ecshop加入购物车效果(各个页面)
ecshop中点击加入购物车出现下图

通过以下代码改成下图效果

1、后台网店设置 购物车确定提示 选择为“提示用户,点击“确定”进购物车”

2、打开js/common.js 104行就是function addToCartResponse中的case '1'
替换之前的 if (confirm(result.message)) location.href = cart_url;为
opencartDiv(result.shop_price,result.goods_name,result.goods_thumb,result.goods_brief,result.goods_id,result.goods_price,result.goods_number);
3、把以下代码复制到这个common.js里 大家看了会觉的这个函数很熟悉 这就是这个文件里的 我只是拿出来修改了一下 ,当然我们可以自己重新写弹出层 比如用jquery
function opencartDiv(price,name,pic,goods_brief,goods_id,total,number)
{
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 = "270px";
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 #37911C";
var html = ''; //生成层内内容
html = '<div style="font-size:14;background:#8cc67b;width:480px;height:40px;line-height:40px;padding:0 10px;font-size:14px; "><span style="float:left; font-weight:bold">产品购买</span><a href=\'javascript:cancel_div()\' style="float:right;padding:0 26px 0 0;background:url(themes/popocai/images/ico_closebig.gif) right center no-repeat;cursor:pointer;" >关闭</a></div><div class="cartpopDiv"><div class="toptitle"><a href="goods.php?id='+goods_id+'" class="pic"><img src='+pic+' width="100" height="100"/></a><p><font style="font-weight:bold">'+name+'</font> <font style="color:#ff6701">'+price+'</font><br>'+goods_brief+'</p></div>'; html += '<div class="coninfo">';
html +='<table cellpadding="0" height="30"><tr><td align="center" >购物车共有<font style="color:#ff6701;"><strong>'+number+'</strong></font>种商品:合计:<font style="color:#ff6701;"><strong>'+total+'</strong></font></td></tr>';
html += '</table>';
html +='</div>'; html +="<div style='float:left;width:450px;text-align:center;padding:15px 0 0;'><a href='index.php'><img src='themes/popocai/images/goon_ico.gif'></a> <a href='flow.php'><img src='themes/popocai/images/jsico.gif'></a></div>";
html +='</div></div>';
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); }
4、打开flow.php
把以下代码加在这一行代码的上面 $result['confirm_type'] = !empty($_CFG['cart_confirm']) ? $_CFG['cart_confirm'] : 2;
$rows = $GLOBALS['db']->getRow("select goods_brief,shop_price,goods_name,goods_thumb from ".$GLOBALS['ecs']->table('goods')." where goods_id=".$goods->goods_id);
$result['shop_price'] = price_format($rows['shop_price']);
$result['goods_name'] = $rows['goods_name'];
$result['goods_thumb'] = $rows['goods_thumb'];
$result['goods_brief'] = $rows['goods_brief'];
$result['goods_id'] = $goods->goods_id;
$sql = 'SELECT SUM(goods_number) AS number, SUM(goods_price * goods_number) AS amount' .
' FROM ' . $GLOBALS['ecs']->table('cart') .
" WHERE session_id = '" . SESS_ID . "' AND rec_type = '" . CART_GENERAL_GOODS . "'";
$rowss = $GLOBALS['db']->GetRow($sql);
$result['goods_price'] = price_format($rowss['amount']);
$result['goods_number'] = $rowss['number'];
5、把样式和图片放到对应的css文件中
/* 购物车弹出效果*/
.cartpopDiv{
width:450px;
padding:0 25px;
float:left;
}
.toptitle{
width:450px;
float:left;
padding:16px 0;
background:url(../images/cartpop_bg.gif) left bottom repeat-x;
}
.toptitle a.pic{
float:left;
width:100px;
height:100px;
overflow:hidden;
}
.toptitle p{
float:right;
width:350px;
font-size:14px;
line-height:20px;
height:58px;
overflow:hidden;
}
.coninfo{
float:left;
width:450px;
padding:4px 0 6px;
background:url(../images/cartpop_bg.gif) left bottom repeat-x;
font-size:14px;
}
.coninfo table{
float:left;
width:100%;
border:none;
color:#a00;
}
.coninfo table td.left{
width:82px;
text-align:right;
font-weight:bold;
}
.coninfo table td.left span,
.toptitle p a{color:#333}
.coninfo table td .gray{color:#999}
.coninfo table td strong{color:#f00}
.coninfo table td font{font-size:18px}
用到的三张图
jsico.gif
goon_ico.gif
ico_closebig.gif
ecshop加入购物车效果(各个页面)的更多相关文章
- 使用session页面控制登录入口及购物车效果的实现
由于 Session 是以文本文件形式存储在服务器端的,所以不怕客户端修改 Session 内容.实际上在服务器端的 Session 文件,PHP 自动修改 Session 文件的权限,只 ...
- vue-transition实现加入购物车效果及其他动画效果实现
vue提供了<transition></transition>和<transition-group></transition-group>实现元素状态的 ...
- PC,移动端H5实现实现小球加入购物车效果
HTML部分: <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" ...
- 给ecshop后台增加管理功能页面
给ecshop后台增加管理功能页面 比如我们增加一个统计报表叫做 物流费用统计报表 放在后台“报表统计”栏目中 具体操作步骤: 第一步,我们要添加一个菜单到后台,然后设置语言项,最后设置权限,这样,后 ...
- JavaScript实现的购物车效果-效果好友列表
JavaScript实现的购物车效果.当然,可以在许多地方使用这种效果.朋友的.例如,在选择.人力资源模块,工资的计算,人才选拔等..下面来看一下班似有些车效果图: watermark/2/text/ ...
- angularjs购物车效果
用angularjs写了一个购物车效果中. html代码: <div png-app="myAp" ng-controller="conTroll"> ...
- Android -- 贝塞尔二阶实现饿了么加入购物车效果
1,上周我们实现了简单的三阶贝塞尔曲线效果实例,今天是使用二阶贝塞尔曲线加动画实现的加入购物车效果,在码代码过程中出现了些问题,过一下和大家来探讨探讨,先看一下效果图 2,从上面的效果来看我们基本上可 ...
- CSS鼠标悬停图片加边框效果,页面布局发生错位的解决办法
CSS鼠标悬停图片加边框效果,页面布局发生错位的解决办法 .recomend-list{ width:1200px; a{ @extend %fl; margin-right: 30px; width ...
- jQuery实现购物车效果
简单的购物车效果 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> < ...
随机推荐
- 『算法』Dinic求最大流
作为一个[NOIP+,省选-]算法,这个算法真的很暴力.同样是最大流,跑得比EK不知快到哪里去了.首先是一个 广度优先搜索() { 按照可用路径上节点的访问顺序标号. 然后判断一下能否到汇点. 如果不 ...
- nodejs querystring踩坑笔记----只能用于表单提交
API中的实例: var http = require('http'); var querystring = require('querystring'); var postData = querys ...
- 九思老客户分享:部署OA办公系统的四大意义
原文:http://www.jiusi.net/detail/472__776__4009__1.html 关键词:OA办公系统.oa系统 .九思OA 九思老客户分享:部署OA办公系统的四大意义 当今 ...
- Jdk1.6 JUC源码解析(12)-ArrayBlockingQueue
功能简介: ArrayBlockingQueue是一种基于数组实现的有界的阻塞队列.队列中的元素遵循先入先出(FIFO)的规则.新元素插入到队列的尾部,从队列头部取出元素. 和普通队列有所不同,该队列 ...
- ke
#include <stdio.h> #include <stdlib.h> // For rand() and srand() #include <time.h> ...
- php的八大数据类型
1. 八大数据: bool 布尔类型:0,1:真假 integer 整形 float 浮点型 string 字符串 array 数组 object 对象,类,class resource 文件,图片, ...
- Android框架式编程之BufferKnife
配置 compile 'com.jakewharton:butterknife:(insert latest version)' annotationProcessor 'com.jakewharto ...
- 测试class
各种断言方法: assertEqual(a,b) a == b assertNotEqual(a,b) a != b assertTrue(x) x == True assertFalse(x) x ...
- python中的数字
在编程中,通常使用数字来记录游戏得分,表示可视化数据.存储web应用信息等. #运算# 1,基本运算 >>> 2+35>>> 1-2-1>>> 3 ...
- malloc与new相关
前言: 通常我们使用数组的时候:必须提前用一个常量来指定数组的长度,同时它的内存空间在编译的时候就已经被分配了.但是有时候数组的长度只有在运行的时候才能知道.因此,一种简单的解决方案就是提前申请一块较 ...