public function _initialize()
 {
     //获取微信服务器传递的数值,储存为对象。
     $this->postObj = get_postObj();
     $this->assign('toUserName', $this->postObj->FromUserName);
     $this->assign('fromUserName', $this->postObj->ToUserName);
 }
 public function registeAction()
 {
     $customer = new CustomerModel();
     $openId = I('get.openid', '');
     $checkCode = I('get.checkcode', '');
     $weixinId = I('get.weixinid', '');
     if ($openId == '' || $checkCode == '' || $weixinId == '') {
         return false;
     }
     //取用户信息
     $customerInfo = get_customer_info($openId);
     if ($customerInfo == false) {
         $customer->setOpenid($openId);
         $customer->addCustomer();
         $customerInfo = get_customer_info($openId);
     }
     $customerType = $customerInfo['subscribe_state'];
     //判断用户类型
     if ((int) $customerType & 1 == 1) {
         echo "请务重复注册";
         return;
     }
     if ($checkCode != session($openId . 'checkCode')) {
         echo "验证码错语";
         return;
     }
     if (time() - session($openId . 'lastTime') > 300) {
         echo "验证码已过期,请重新获取";
         return;
     }
     //用户状态更新
     $customer->setWeixinId($weixinId);
     $customer->updateState();
     //调用关注送券活动
     $active = new ActiveModel();
     $active->setopenId($openId);
     $accessToken = get_access_token();
     $data = get_weichat_user_info($openId, $accessToken);
     //用出客户基本信息
     //
     $obj = get_postObj();
     if (isset($obj->EventKey)) {
         $pcid = (int) $obj->EventKey;
     } else {
         $pcid = 0;
     }
     $data['parentid'] = $pcid;
     $active->setParentId($pcid);
     $active->subscribe();
     //
     echo "success";
 }