Browse Source

Merge branch 'test' of git.oschina.net:yiguanjia/php into test

e 8 years ago
parent
commit
7afed44dca

+ 6 - 13
www/protected/modules/common/controllers/ActivityController.php

@@ -21,9 +21,6 @@ class ActivityController extends O2oBaseController  {
         $home_page = Yii::app()->getRequest()->getParam("home_page",'');
         $userId = Yii::app()->request->getParam('userId','');
         $appToken = '';
-        echo "1";
-        var_dump($userId);
-        var_dump($state);
         if($code && $state){
             $accessInfo = CommonWeixin::getAccessInfo($code);
             $userId = '';
@@ -89,17 +86,14 @@ class ActivityController extends O2oBaseController  {
         $coupon_id =new MongoId($coupon_id);
         $start_time = time();                 //发放优惠券可用开始时间
         $end_time = $start_time + 86400*30;   //发放优惠券过期时间
-        var_dump($userId);
-        if (!CommonFn::isMongoId($userId)) {
-            $userId = new MongoId($userId);
-        }
-        if ($coupon_id) {
-            if ($userId) {
-                Service::factory('CouponService')->giveCoupon($userId, $coupon_id, $start_time, $end_time);//发放代金券
-                $home_page = 1;
+        if ($userId != ""){
+            if (!CommonFn::isMongoId($userId)) {
+                $userId = new MongoId($userId);
             }
+            Service::factory('CouponService')->giveCoupon($userId, $coupon_id, $start_time, $end_time);//发放代金券
+
         }
-        var_dump($home_page);
+
         if($home_page){
             $this->renderpartial('index');
         }else{
@@ -119,7 +113,6 @@ class ActivityController extends O2oBaseController  {
 
     //检查微信登录页
     public function actionWxIndex() {
-
         $wxConfig = Yii::app()->params['wxConfig'];
         $home_page = Yii::app()->getRequest()->getParam("home_page",'');
         $coupon_id = Yii::app()->request->getParam('coupon_id', '');

+ 3 - 8
www/protected/modules/common/views/activity/getCoupon.php

@@ -48,7 +48,7 @@
             }
         }
         ?>
-        alert('<?php $userId?>');
+
         if (ua.match(/MicroMessenger/i) == 'micromessenger') {
             <?php
             if(!empty($userId) && !empty($appToken)){
@@ -58,13 +58,8 @@
           ';
             }
             ?>
-            var userID = localStorage.getItem('wxUserID');
-            var appToken = localStorage.getItem('appToken');
-
-            if (!userID || !appToken) {
-                localStorage.clear();
-                location.href = '<?php echo Yii::app()->request->baseUrl . 'index.php?r=/common/activity/wxIndex&coupon_id='.$coupon_id; ?>';
-            }
+            location.href = '<?php echo Yii::app()->request->baseUrl . 'index.php?r=/common/activity/wxIndex&coupon_id='.$coupon_id; ?>';
+            
             document.write('<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"><\/script>');
         }
         if (location.hash == '#rd') {

+ 1 - 0
www/protected/modules/o2o/views/web/wxIndex.php

@@ -17,6 +17,7 @@
     (function(){
         var codeURI = '<?php echo $codeURI; ?>';
         var appURI = '<?php echo $appURI; ?>';
+
         var wxUserID = localStorage.getItem('wxUserID');
         if (wxUserID) {
             location.href = appURI+'&userId='+wxUserID;