iwebshop二次开发---邀请注册

在左侧添加“邀请注册列表”

iwebshop二次开发---邀请注册
iwebshop二次开发---邀请注册
正在上传...取消

地址:classes/menUcenter中

准备:创建一个163邮箱   开启smtp  并创建一个秘钥

           在项目后台完成邮箱设置并保存

代码处:为了吸引更多的用户注册我们给iwebshop添加邀请用户功能-邮箱邀请

效果展示:

1、邮箱发送

iwebshop二次开发---邀请注册

2、点击链接注册

iwebshop二次开发---邀请注册

注册成功之后邀请人积分增加100


代码实现:

1、首先我们在user表中添加invite字段

iwebshop二次开发---邀请注册

3、在views/default/ucenter下建立invite.html

{js:jquery}
<div class="main f_r">
    <div class="uc_title m_10">
        <label class="current"><span>好友邀请</span></label>
    </div>
    <div class="form_content">
        <div class="uc_title2 m_10"><span class="f_r"><b class="red">*</b>号的项目为必填项</span><strong>邮箱邀请</strong></div>
        <!--<form action='{url:/ucenter/invitePro}' method='post' name="email">-->
            <table class="form_table" cellpadding="0" cellspacing="0">
                <col width="200px" />
                <col />
                <tr>
                    <th><span class="red">*</span>好友邮箱:</th><td><input type='text' class="normal" name="email"  alt='请输入好友邮箱' id="mail" /><label>邮件发送</label></td>
                </tr>
                <tr>
                    <th></th>
                    <td>
                        <label class="btn"><input type="butten" value="确认发送" id="sub"/></label>
                        <label class="btn"><input type="reset" value="取消" /></label>
                    </td>
                </tr>
            </table>
        <!--</form>-->
    </div>
</div>
<script type='text/javascript'>
    $(function(){
        $("#sub").click(function(){
            var ajaxUrl = '{url:/ucenter/invitePro}';
            var email=$("#mail").val();
            $.getJSON(ajaxUrl,{'email':email},function(msg){
                //console.log(msg);
                alert(msg.message);
            })
        })
    })
</script>
4、在ucenter.php建立邮箱发送控制器
/**
 * 好友邀请邮箱注册提交
 */
public function invitePro(){
    $email = IReq::get('email');
    $user_id=$this->user['user_id'];
    //发送邮件
    $smtp = new SendMail();
    if($error = $smtp->getError())
    {
        $result = array('isError'=>true,'message' => $error);
    }
    else {
        $title = '好友邀请';
        $content = '大人:小二等您好苦,您的好友邀请您注册账号    点击链接:'."http://127.0.0.1/iwebshop/index.php?controller=simple&action=reg&id=".urlencode(base64_encode($user_id));
        if ($smtp->send($email, $title, $content)) {
            $result = array('isError' => false, 'message' => '发送成功!');
        } else {
            $result = array('isError' => true, 'message' => '发送失败,请确认您填写邮箱是否正确');
        }
    }
    echo JSON::encode($result);
}
5、在simple.php中建立reg()方法 //注册控制器
function reg(){
    //接到邀请人id
    $id=IReq::get('id')?IReq::get('id'):"";
    if($id!="") {
        $uid = urldecode(base64_decode($id));
        $userObj = new IModel('user');
        $userlist =$userObj->getObj('id='.$uid,'username');
        $uname=$userlist['username'];
        $this->uname = $uname;
        $this->uid=$uid;
    }
    $this->redirect('reg');
}
6、修改注册页面views/default/simple/reg.html
{if:$this->uname}
<tr><th>邀请人:</th><td>{$this->uname}<input type="hidden" name="uid" value="{$this->uid}"></tr>
{/if}
7、修改提交注册控制器simple.php reg_act() 方法
//添加值
$invite     = IFilter::act(IReq::get('uid','post'));
入库字段添加
8.由于引用了插件 在plugins/_userinfo/_userinfo.php  userRegAct()方法中

1.接收邀请人id

2.入库user  字段添加

iwebshop二次开发---邀请注册

3.增加积分在point_log表中

iwebshop二次开发---邀请注册