62,271
社区成员
发帖
与我相关
我的任务
分享
public static void ToGrade(InPageAction IN, OutPageAction OUT)
{
if (OUT.Break || IN.ActionName != "tograde")
{
return;
}
uint moduleID = 0;
uint infoID = 0;
uint point = 0;
uint nodeID = 0;
string tableName = "WB_U_Comment";
IN.Page.HttpContext.GetRequest(ref moduleID, "infotypeid");
IN.Page.HttpContext.GetRequest(ref infoID, "infoid");
IN.Page.HttpContext.GetRequest(ref point, "point");
IN.Page.HttpContext.GetRequest(ref nodeID, "nodeid");
string ip = IN.Page.HttpContext.Context.Request.UserHostAddress.ToString();
string result = "2"; //2 查询 1 评分 0 失败
try
{
WB_Info wbInfo = new WB_Info();
wbInfo.TableName = tableName;
wbInfo.Connection = IN.Page.Connection;
if (point > 0)
{
if (!wbInfo.TrySelectFirstRow(new string[] { "InfoID" }, "ModuleID = '" + moduleID + "' and NewsID ='" + infoID + "' and IpAddress = '" + ip + "' and datediff('d',CreateDate,'" + DateTime.Now.ToString() + "')=0", "InfoID"))
{
//当天同个IP如果已经评分,将不再评分
wbInfo.Insert(new string[] { "ModuleID", "NewsID", "NodeID", "Point", "State", "TopIndex", "CreateDate", "IpAddress" }, new string[]{IN.Page.Connection.FormatTextFieldValue(moduleID.ToString()),
IN.Page.Connection.FormatTextFieldValue(infoID.ToString()),IN.Page.Connection.FormatIntFieldValue(nodeID.ToString()),IN.Page.Connection.FormatTextFieldValue(point.ToString()),
IN.Page.Connection.FormatIntFieldValue(0),IN.Page.Connection.FormatIntFieldValue(0),IN.Page.Connection.FormatDateFieldValue(DateTime.Now.ToString()),IN.Page.Connection.FormatTextFieldValue(ip)});
result = "1";
}
}
//得到当前评分
string avgPointSql = LC.Data.SelectValue.CreateAvgSqlString(IN.Page.Connection, tableName, "Point", "ModuleID = '" + moduleID + "' and NewsID ='" + infoID + "'");
string avgPoint = LC.Data.SelectValue.Execute(IN.Page.Connection, avgPointSql);
if (avgPoint.Length > 4)
{
avgPoint = avgPoint.Substring(0, 4);
}
else if (string.IsNullOrEmpty(avgPoint))
{
avgPoint = "0";
}
//得到当前参与评分人数
string gradeNumSql = LC.Data.SelectValue.CreateCountSqlString(IN.Page.Connection, tableName, "InfoID", "ModuleID = '" + moduleID + "' and NewsID ='" + infoID + "'");
string gradeNum = LC.Data.SelectValue.Execute(IN.Page.Connection, gradeNumSql);
OUT.Message = "[" + result + "," + avgPoint + "," + gradeNum + "]";
}
catch (Exception ex)
{
result = "0";
OUT.Message = "[" + result + ",0," + ex.Message + "]";
}
}
团购网的出现大大的带动了ecshop网店市场,与时俱进的功能也层出不穷也带动了ecshop二次开发技术,很多客户需要倒计时代码,今天就和大家分享ecshop开发之如何实现团购网倒计时功能,以此来增加顾客购物热情和欲望。
代码不难,大致分为三部分,获取当前时间,开始倒计时,提交。
1.计算剩余时间的函数:
function countDown(){
var i;
var objArray =document.getElementsByTagName("label");
//alert(objArray.length);
for (i=0;i<(objArray.length);i++)
{
if (objArray[i].id.indexOf("article_")>-1)
{
objHid = document.getElementById("hid_article_" + objArray[i].id.substring(objArray[i].id.indexOf("_")+1));
//objHid.value就是对应的时间值,然后改下面就行了
var d=Date.parse(objHid.value);
var today=new Date();
var time=d-today;
var 时间=objArray[i];
if(Math.floor(time)<=0){
时间.innerHTML='抢购时间已过,谢谢您的关注!';
}
else
时间没有过,就开始计算距离到期日的时间
{
var 天=Math.floor(time/(1000*60*60*24));
var 小时=Math.floor(time/(1000*60*60))%24;
var 分=Math.floor(time/(1000*60))%60;
var 秒=Math.floor(time/1000)%60;
时间.innerHTML=天+' 天'+小时+'小时'+分+'分'+秒+'秒';
时间.style.fontSize='14px';
}
}
}
2.当然在计时函数之前必须知道当前时间,月份、小时、分、秒
index.php
/** 将GMT时间戳格式化为用户自定义时区日期
*
*
* @param string $format
* @param integer $time 该参数必须是一个GMT的时间戳
*
* @return string
*/
function local_date($format, $time = NULL)
{
$timezone = isset($_SESSION['timezone']) ? $_SESSION['timezone'] : $GLOBALS['_CFG']['timezone'];
if ($time === NULL)
{
$time = gmtime();
}
elseif ($time <= 0)
{
return '';
}
$time += ($timezone * 3600);
return date($format, $time);
}
function chagetime($time)
{
$time = local_date($GLOBALS['_CFG']['time_format'], $time);
//echo $time;exit;
$time = explode(" ",$time);//分割时间
$date = $time[0];
$time=$time[1];
$date=explode("-",$date);
$year = (int)$date[0];
$month = (int)$date[1];
$day = (int)$date[2];
/*$time=explode(":",$time);
$hour =$time[0];
$min =$time[1];
$sec =(int)$time[2];
$hour = (int)(24-$hour);
$min =(int)(60-$min);
$time=$hour.":".$min.":".$sec;*/
switch ($month) 这里是显示月份的函数
{
case 1:
$month_name = "Jan";
break;
case 2:
$month_name = "Feb";
break;
case 3:
$month_name = "Mar";
break;
case 4:
$month_name = "Apr";
break;
case 5:
$month_name = "May";
break;
case 6:
$month_name = "Jun";
break;
case 7:
$month_name = "Jul";
break;
case 8:
$month_name = "Aug";
break;
case 9:
$month_name = "Sep";
break;
case 10:
$month_name = "Oct";
break;
case 1:
$month_name = "Nov";
break;
case 2:
$month_name = "Dec";
break;
}
return $month_name." ".$day." ".$year." ".$time; 返回时间值
}
3.这样就基本上完成了,最后输出值就可以了
setTimeout('countDown()',1000);
}
countDown();
</script>
<label id='article_1'></label><input type='hidden' id='hid_article_1' value='<?php echo chagetime(time());?>' />