ecshop通过email领取红包
2009-11-05 16:06 来源:www.chinab4c.com 作者:ecshop专家
1:user_transaction.dwt中
<!-- {if $action eq 'lingqu'} 用户的红包列表 start-->
<script type="text/javascript">
{foreach from=$lang.profile_js item=item key=key}
var {$key} = "{$item}";
{/foreach}
</script>
<div class="blank5"></div>
<h5><span>领取红包</span></h5>
<div class="blank"></div>
<form name="ling" method="post">
<div style="padding: 15px;">
输入Email领取红包:
<input name="email" type="text" size="30" class="inputBg" value="{$email}"/>
<input type="buttom" class="bnt_blue_1" style="border:none;" onclick="return lingqu();" value="领取红包" />
</div>
</form>
<!-- {/if} -->
2:js/user.js
function lingqu()
{
var frm = document.forms['ling'];
var email = frm.elements['email'].value;
var msg = '';
var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
if(email == ''){
msg+= '输入邮件'+'\n';
}else if(!myreg.test(email)){
msg+='邮件格式不对'+'\n';
}
if(msg){
alert(msg);
return false;
}
Ajax.call('user.php?act=sub_lingqu', 'email=' + email, returnlingqu, 'POST', 'JSON');
}
function returnlingqu(result)
{
alert(result.message);
}
3:user.php
//领取红包
elseif ($action == 'lingqu')
{
include_once(ROOT_PATH .'includes/lib_transaction.php');
if($_SESSION[user_id]){
$smarty -> assign('email',$db -> getOne("select email from ".$ecs->table('users')." where user_id = ".$_SESSION['user_id']));
}//检索红包发送的邮件
$smarty->display('user_transaction.dwt');
}elseif($action == 'sub_lingqu'){
include_once('includes/cls_json.php');
$result = array('error' => 0, 'message' => '');
$json = new JSON;
$sql = "select user_id from ".$ecs->table('user_bonus')." where bonus_type_id = 6 ";//检索是否该会员被发过红包
$user_id = $db -> getOne($sql);
if($user_id){
$result[message]= '折扣红包,您已经领取过一次,不能再次领取';//领取过一次,不能在领取
die($json->encode($result));
}else{
$row = $db -> getRow("select * from ".$ecs->table('user_bonus')." where user_id = 0 and bonus_type_id = 6 order by rand() limit 1");//检索出一个红包
if($row[bonus_id]){
$sql = "update ".$ecs->table('user_bonus')." set user_id = ".$_SESSION[user_id]." where bonus_id = ".$row[bonus_id];//发送红包
$db -> query($sql);
$string ="您所获取的红包编号为:".$row[bonus_sn];//检索编号
if(send_mail($_CFG['shop_name'], $_POST['email'], '红包发送', $string,'')){//发送红包
$result[message]= '您领取的红包,已经发送到您的邮箱里面了,请查收!';//发送邮件
}else{
$result[message]= '发送邮件失败,请联系管理员!';
}
}
die($json->encode($result));
}
}
//红包处理结束
最近更新
常用插件
- ecshop购物车功能改进[插件
ecshop购物车功能改进[插件套餐]主要是我们最近开发工作和开发项目中。...
- ecshop红包修改成满多少减
我们在长期使用ecshop的时候,我们可以发现。ecshop的红包是一个非常强...
- ecshop分类树中统计商品数
最近忙于开发其他项目,在不少朋友不断要求和催促的情况下,做出了该小...
- ecshop通用红包编码
很多时候,为了结合促销,必须扩展一下ecshop的红包功能。ecshop的红包...
- ecshop降价通知登记插件
ecshop降价通知登记插件,主要是为了方便某些客户,对商品价格要求比...