Ejemplo n.º 1
0
 public function index()
 {
     /* 加载微信SDK */
     import('Com.ThinkWechat');
     $Wechat = D('Wechat', 'Service');
     $weixin = new \ThinkWechat('chenjianxiang');
     $data = $weixin->request();
     list($content, $type) = $Wechat->reply($data);
     $weixin->response($content, $type);
     $this->display();
 }
Ejemplo n.º 2
0
 public function index()
 {
     /* 加载微信SDK */
     import('ORG.Net.ThinkWechat');
     $weixin = new ThinkWechat('weixin');
     /* 获取请求信息 */
     $data = $weixin->request();
     /* 获取回复信息 */
     // 这里的回复信息是通过判断请求内容自行定制的, 不在 SDK范围内,请自行完成
     list($content, $type) = $this->reply($data);
     /* 响应当前请求 */
     $weixin->response($content, $type);
 }
Ejemplo n.º 3
0
 protected function _welogin($code)
 {
     import("@.ORG.Util.ThinkWechat");
     $weixin = new ThinkWechat();
     $openid = $weixin->openid($code);
     $model = M("User");
     $auth_info = $model->where("openid = '{$openid}' AND westatus = 1")->find();
     // 查到userid
     if ($auth_info) {
         session(C('USER_AUTH_KEY'), $auth_info['id']);
         session('emp_no', $auth_info['emp_no']);
         session('email', $auth_info['email']);
         session('user_name', $auth_info['name']);
         session('user_pic', $auth_info['pic']);
         session('dept_id', $auth_info['dept_id']);
         if ($auth_info['emp_no'] == 'admin') {
             session(C('ADMIN_AUTH_KEY'), true);
         }
     } else {
         redirect(U('wechat/oauth', array('openid' => $openid)));
     }
 }
Ejemplo n.º 4
0
 private function _send_wechat($content, $openid = '', $type = 'text')
 {
     import("@.ORG.Util.ThinkWechat");
     $weixin = new ThinkWechat();
     // $openid = 'o0ehLt1pOAIEFZtPD4ghluvjamf0';
     $restr = $weixin->sendMsg($content, $openid, $type);
     return $restr;
 }
Ejemplo n.º 5
0
 /**
  * 生成菜单
  */
 public function setmenu()
 {
     $sub = array();
     $data = array();
     $subs = array();
     $subs1[] = array('type' => 'click', 'name' => '我申请的任务', 'key' => 'apply_task');
     $subs1[] = array('type' => 'click', 'name' => '邀请我的任务', 'key' => 'invite_task');
     $subs1[] = array('type' => 'click', 'name' => '待评价的任务', 'key' => 'comment_task');
     $subs2[] = array('type' => 'click', 'name' => '适合我的任务', 'key' => 'fit_task');
     $subs2[] = array('type' => 'view', 'name' => '任务检索', 'url' => 'http://www.马赛克.com/wechat/search/');
     $subs3[] = array('type' => 'click', 'name' => '功能介绍', 'key' => 'ites_intro');
     $subs3[] = array('type' => 'view', 'name' => '意见反馈', 'url' => 'http://www.马赛克.com/wechat/feedback/');
     $subs3[] = array('type' => 'click', 'name' => '工程师联盟认证', 'key' => 'ites_verify');
     $subs3[] = array('type' => 'click', 'name' => '信息推送设置', 'key' => 'ites_set');
     $sub1 = array('name' => '任务管理', 'sub_button' => $subs1);
     $sub2 = array('name' => '任务查询', 'sub_button' => $subs2);
     $sub3 = array('name' => '系统功能', 'sub_button' => $subs3);
     $data['button'][] = $sub1;
     $data['button'][] = $sub2;
     $data['button'][] = $sub3;
     $data = jsencode($data);
     /* 加载微信SDK */
     import("@.ORG.Util.ThinkWechat");
     $weixin = new ThinkWechat();
     echo $weixin->setMenu($data);
 }