Browse Source

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

e 8 years ago
parent
commit
0a49cec76a

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

@@ -19,9 +19,11 @@ class ActivityController extends O2oBaseController  {
         $code = Yii::app()->getRequest()->getParam("code");
         $state = Yii::app()->getRequest()->getParam("state");
         $home_page = Yii::app()->getRequest()->getParam("home_page",'');
-        $userId = '';
+        $userId = Yii::app()->request->getParam('userId','');
         $appToken = '';
-        var_dump($code);
+        echo "1";
+        var_dump($userId);
+        var_dump($state);
         if($code && $state){
             $accessInfo = CommonWeixin::getAccessInfo($code);
             $userId = '';
@@ -88,16 +90,19 @@ class ActivityController extends O2oBaseController  {
         $start_time = time();                 //发放优惠券可用开始时间
         $end_time = $start_time + 86400*30;   //发放优惠券过期时间
         var_dump($userId);
-        if (CommonFn::isMongoId($coupon_id) && !$coupon_id) {
-            if (CommonFn::isMongoId($userId) && !$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;
             }
         }
+        var_dump($home_page);
         if($home_page){
-            var_dump($user->_id);
             $this->renderpartial('index');
         }else{
-            var_dump($coupon_id);
             $this->renderpartial('getCoupon', array(
                 'version' => '2015111601',
                 'debug' => 'false',

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

@@ -30,6 +30,7 @@
         <div class="bg"></div>
         <span class="ball"></span>
         <span class="ball"></span>
+
     </div>
 </div>
 
@@ -47,6 +48,7 @@
             }
         }
         ?>
+        alert('<?php $userId?>');
         if (ua.match(/MicroMessenger/i) == 'micromessenger') {
             <?php
             if(!empty($userId) && !empty($appToken)){
@@ -58,14 +60,10 @@
             ?>
             var userID = localStorage.getItem('wxUserID');
             var appToken = localStorage.getItem('appToken');
-            alert(userID);
+
             if (!userID || !appToken) {
                 localStorage.clear();
                 location.href = '<?php echo Yii::app()->request->baseUrl . 'index.php?r=/common/activity/wxIndex&coupon_id='.$coupon_id; ?>';
-            } else {
-                localStorage.clear();
-                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>');
         }

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

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