Ejemplo n.º 1
0
 public function index()
 {
     $map['id'] = I('id');
     $params['mp_id'] = $map['mp_id'] = get_mpid();
     hook('init_ucuser', $params);
     //把消息分发到addons/ucuser/init_ucuser的方法中,初始化公众号粉丝信息
     $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $surl = get_shareurl();
     if (!empty($surl)) {
         $this->assign('share_url', $surl);
     }
     $info = get_mpid_appinfo($params['mp_id']);
     $options['appid'] = $info['appid'];
     //初始化options信息
     $options['appsecret'] = $info['secret'];
     $options['encodingaeskey'] = $info['encodingaeskey'];
     $weObj = new TPWechat($options);
     $auth = $weObj->checkAuth();
     $js_ticket = $weObj->getJsTicket();
     if (!$js_ticket) {
         $this->error('获取js_ticket失败!错误码:' . $weObj->errCode . ' 错误原因:' . ErrCode::getErrText($weObj->errCode));
     }
     $js_sign = $weObj->getJsSign($url);
     $this->assign('js_sign', $js_sign);
     $info = M('weicj')->where($map)->find();
     $info['pic1'] = get_cover_url($info['pic1']);
     $info['pic2'] = get_cover_url($info['pic2']);
     $info['pic3'] = get_cover_url($info['pic3']);
     $info['pic4'] = get_cover_url($info['pic4']);
     $info['pic5'] = get_cover_url($info['pic5']);
     $info['pic6'] = get_cover_url($info['pic6']);
     $info['clickpic'] = get_cover_url($info['clickpic']);
     if ($info['andio']) {
         $file = M('file')->where('id=' . $info['andio'])->find();
         $filename = 'http://' . $_SERVER['HTTP_HOST'] . '/Uploads/Download/' . $file['savepath'] . $file['savename'];
         $info['trueaudio'] = $filename;
     } else {
         $info['trueaudio'] = $info['audio2'];
     }
     $this->assign('info', $info);
     //$templateFile = $this->model ['template_list'] ? $this->model ['template_list'] : '';
     $this->display();
 }
Ejemplo n.º 2
0
 /**
  * 活动详情
  * @param int $id
  * autor:xjw129xjt
  */
 public function detail($id = 0)
 {
     $check_isSign = D('event_attend')->where(array('uid' => is_login(), 'event_id' => $id))->select();
     $this->assign('check_isSign', $check_isSign);
     $event_content = D('Event')->where(array('status' => 1, 'id' => $id))->find();
     if (!$event_content) {
         $this->error('404 not found');
     }
     D('Event')->where(array('id' => $id))->setInc('view_count');
     $event_content['user'] = query_user(array('id', 'username', 'nickname', 'space_url', 'space_link', 'avatar64', 'rank_html', 'signature'), $event_content['uid']);
     $event_content['type'] = $this->getType($event_content['type_id']);
     $menber = D('event_attend')->where(array('event_id' => $id, 'status' => 1))->select();
     foreach ($menber as $k => $v) {
         $event_content['member'][$k] = query_user(array('id', 'username', 'nickname', 'space_url', 'space_link', 'avatar64', 'rank_html', 'signature'), $v['uid']);
     }
     $params['mp_id'] = $map['mp_id'] = get_mpid();
     $this->assign('mp_id', $params['mp_id']);
     $uid = get_ucuser_uid();
     //获取粉丝用户uid,一个神奇的函数,没初始化过就初始化一个粉丝
     if ($uid === false) {
         $this->error('只可在微信中访问');
     }
     $user = get_uid_ucuser($uid);
     //获取公众号粉丝用户信息
     $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $surl = get_shareurl();
     if (!empty($surl)) {
         $this->assign('share_url', $surl);
     }
     $appinfo = get_mpid_appinfo($params['mp_id']);
     //获取公众号信息
     $this->assign('appinfo', $appinfo);
     $options['appid'] = $appinfo['appid'];
     //初始化options信息
     $options['appsecret'] = $appinfo['secret'];
     $options['encodingaeskey'] = $appinfo['encodingaeskey'];
     $weObj = new TPWechat($options);
     $auth = $weObj->checkAuth();
     $js_ticket = $weObj->getJsTicket();
     if (!$js_ticket) {
     }
     $js_sign = $weObj->getJsSign($url);
     $this->assign('js_sign', $js_sign);
     $this->assign('user', $user);
     $this->assign('content', $event_content);
     $this->setTitle('{$content.title|op_t}' . '——活动');
     $this->setKeywords('{$content.title|op_t}' . ',活动');
     $this->getRecommend();
     $this->display();
 }
Ejemplo n.º 3
0
 public function index()
 {
     //JSSDK 初始部分
     $param['mp_id'] = I('mp_id');
     //$param ['id'] = I('id');                                          //如有插件中数据id,分享url中应加入id参数
     //$url = addons_url ( 'Jssdk://Jssdk/index', $param );  //分享的url需要和自定义回复入口url保持相同
     $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $surl = get_shareurl();
     if (!empty($surl)) {
         $this->assign('share_url', $surl);
     }
     $info = get_mpid_appinfo($param['mp_id']);
     $options['appid'] = $info['appid'];
     //初始化options信息
     $options['appsecret'] = $info['secret'];
     $options['encodingaeskey'] = $info['encodingaeskey'];
     $weObj = new TPWechat($options);
     $auth = $weObj->checkAuth();
     $js_ticket = $weObj->getJsTicket();
     if (!$js_ticket) {
         $this->error('获取js_ticket失败!错误码:' . $weObj->errCode . ' 错误原因:' . ErrCode::getErrText($weObj->errCode));
     }
     $js_sign = $weObj->getJsSign($url);
     $this->assign('js_sign', $js_sign);
     $addon_config = get_addon_config('Jssdk');
     $this->assign('addon_config', $addon_config);
     //微信支付部分
     //此处可以动态获取数据库中的MCHID和KEY
     $jssdkpay = new JsSdkPay($options);
     $jssdkpay->MCHID = "";
     // 动态MCHID;微信支付分配的商户号
     $jssdkpay->KEY = "";
     // 动态KEY;
     //=========步骤2:使用统一支付接口,获取prepay_id============
     //使用统一支付接口
     $jssdkpay->parameters['openid'] = get_openid();
     //trade_type=JSAPI,此参数必传,用户在商户appid下的唯一标识。
     $jssdkpay->parameters['body'] = "订单支付";
     //商品或支付单简要描述
     $jssdkpay->parameters['out_trade_no'] = "outtradeno" . time();
     //商户系统内部的订单号,32个字符内、可包含字母,不可重复
     $jssdkpay->parameters['total_fee'] = 100;
     //收款金额,此处单位为分 出现小数点接口报错必须是整数
     $jssdkpay->parameters['notify_url'] = 'http://test.uctoo.com/index.php/addon/Jssdk/Jssdk/alarmnotify';
     //接收微信支付异步通知回调地址
     $jssdkpay->parameters['trade_type'] = "JSAPI";
     //取值如下:JSAPI,NATIVE,APP
     $jssdkpay->parameters['spbill_create_ip'] = get_client_ip();
     //APP和网页支付提交用户端ip,Native支付填调用微信支付API的机器IP。
     //以下非必填参数根据需要添加
     //$jssdkpay->parameters['device_info'] = "013467007045764";            //微信支付分配的终端设备号,商户自定义
     //$jssdkpay->parameters['detail'] = "UCToo   蓝色";                     //商品名称明细列表
     //$jssdkpay->parameters['attach'] = "说明";                             //附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据
     //$jssdkpay->parameters['fee_type'] = "CNY";                           //符合ISO 4217标准的三位字母代码,默认人民币:CNY
     //$jssdkpay->parameters['time_start'] = "20091225091010";              //订单生成时间,格式为yyyyMMddHHmmss
     //$jssdkpay->parameters['time_expire'] = "20091227091010";             //订单失效时间,格式为yyyyMMddHHmmss
     //$jssdkpay->parameters['goods_tag'] = "WXG";                          //商品标记,代金券或立减优惠功能的参数
     //$jssdkpay->parameters['product_id'] = "12235413214070356458058";     //trade_type=NATIVE,此参数必传。此id为二维码中包含的商品ID,商户自行定义。
     $jssdkpay->prepay_id = $jssdkpay->getPrepayId();
     //微信生成的预支付回话标识,用于后续接口调用中使用,该值有效期为2小时
     //=========步骤3:使用jsapi调起支付============
     $jsApiParameters = $jssdkpay->getParameters();
     //JSSDK 用户支付完成后的一些系统操作
     $param1['dcnum'] = $jssdkpay->parameters['out_trade_no'];
     $param1['openid'] = $jssdkpay->parameters['openid'];
     $ajaxurl = addons_url('Jssdk://Jssdk/orderpaid', $param1);
     //用户支付完成后,在微信支付返回alarmnotify之前(不保证时序),可以通过ajax调用,进行一些预处理操作
     $jsApiParameters = substr($jsApiParameters, 1, -1) . ",success: function (res) {\n                // 支付成功后的js回调函数\n               \n                }";
     $this->assign("jsApiParameters", $jsApiParameters);
     //向页面传整理好的调起支付参数
     $this->display();
 }
Ejemplo n.º 4
0
 public function profile()
 {
     $params['mp_id'] = $map['mp_id'] = get_mpid();
     $this->assign('mp_id', $params['mp_id']);
     $map['id'] = I('id');
     $uid = get_ucuser_uid();
     //获取粉丝用户uid,一个神奇的函数,没初始化过就初始化一个粉丝
     if ($uid === false) {
         $this->error('只可在微信中访问');
     }
     $user = get_uid_ucuser($uid);
     //获取公众号粉丝用户信息
     $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $surl = get_shareurl();
     if (!empty($surl)) {
         $this->assign('share_url', $surl);
     }
     $appinfo = get_mpid_appinfo($params['mp_id']);
     //获取公众号信息
     $this->assign('appinfo', $appinfo);
     $options['appid'] = $appinfo['appid'];
     //初始化options信息
     $options['appsecret'] = $appinfo['secret'];
     $options['encodingaeskey'] = $appinfo['encodingaeskey'];
     $weObj = new TPWechat($options);
     $auth = $weObj->checkAuth();
     $js_ticket = $weObj->getJsTicket();
     if (!$js_ticket) {
         $this->error('获取js_ticket失败!错误码:' . $weObj->errCode . ' 错误原因:' . ErrCode::getErrText($weObj->errCode));
     }
     $js_sign = $weObj->getJsSign($url);
     $this->assign('js_sign', $js_sign);
     $fans = $weObj->getUserInfo($user['openid']);
     $this->assign('user', $user);
     if (IS_POST) {
         $data['uid'] = $uid;
         $data['nickname'] = I('post.nickname', '', 'op_t');
         $data['mobile'] = I('post.mobile', '', 'op_t');
         $data['email'] = I('post.email', '', 'op_t');
         $data['sex'] = I('post.sex', '', 'intval');
         $data['qq'] = I('post.qq', '', 'op_t');
         $data['weibo'] = I('post.weibo', '', 'op_t');
         $data['signature'] = I('post.signature', '', 'op_t');
         $ucuser = D('Common/Ucuser');
         $res = $ucuser->save($data);
         if ($res > 0) {
             $this->success('更新资料成功', addons_url('Ucuser://Ucuser/profile'));
         } else {
             $this->error($ucuser->getError());
         }
     } else {
         //显示资料页面
         if ($user['openid'] != $fans['openid']) {
             //本地保存的openid和公众平台获取的不同,不允许用户自己以外的人访问
             $this->error('无权访问用户资料', addons_url('Ucuser://Ucuser/login'), 5);
         }
         $this->display();
     }
 }