Mike 8 years ago
parent
commit
9917100dfe

+ 1 - 1
miaomiao/www/js/controllers/add.js

xqd
@@ -44,7 +44,7 @@
                     video:$scope.video.server,
                     name: $scope.vm.name,
                     about: $scope.vm.about,
-                    time: 21, //默认21
+                    days: 21, //默认21
                     coin: $scope.vm.coin
                 };
                 msg.loading('保存中...');

+ 25 - 11
miaomiao/www/js/controllers/home.js

xqd xqd xqd xqd
@@ -237,10 +237,10 @@
             $scope.input.placeholder = "评论";
             var data = {
                 id:id,
-                content:vm.comment,
+                content:$scope.vm.comment,
             };
             homeService.add_comment(data).then(function(){
-                 $scope.vm.comment = '' ;
+                $scope.vm.comment = '' ;
                 $scope.load(id);
                 $scope.closeModal();
             })
@@ -296,13 +296,16 @@
         }]);
     app.controller('searchCtrl', ["$scope","homeService", "$state", "msg", "$ionicTabsDelegate", "$ionicNavBarDelegate"
         , function ($scope,homeService, $state, msg, $ionicTabsDelegate, $ionicNavBarDelegate) {
-        $scope.isResult = false;
-        $scope.index = 0;
-        $scope.vm = {
-            keyword : ""
-        }
+
         $scope.showMore = function (keyword,index) {
+            if(!keyword)return;
             $scope.index = index;
+            // $scope.vm.keyword = keyword;
+            homeService.search(keyword).then(function(result){
+                $scope.isResult = true;
+                $scope.dream_infos = result.data.data.dream_infos;
+                $scope.user_infos = result.data.data.user_infos;
+            });
         }
         $scope.search = function (keyword) {
             $scope.vm.keyword = keyword;
@@ -312,10 +315,21 @@
                 $scope.user_infos = result.data.data.user_infos;
             });
         }
+        $scope.toDetail = function (id) {
+            $state.go('app.home_dreamdetail',{id:id});
+        };
+        $scope.toUser = function (id) {
+            $state.go('app.home_dreamdetail',{id:id});
+        };
    
         $scope.$on('$ionicView.beforeEnter', function () {
+            $scope.isResult = false;
+            $scope.index = 0;
+            $scope.vm = {
+                keyword : ""
+            }
             $ionicTabsDelegate.showBar(false);
-            $ionicNavBarDelegate.showBackButton(false);
+            // $ionicNavBarDelegate.showBackButton(false);
             homeService.search('').then(function(result){
                 $scope.hot_searches = result.data.data.hot_searches;
                 $scope.history_searches = result.data.data.history_searches;
@@ -342,9 +356,9 @@
               $scope.dreams = result.data.data;
             });
       });
-          $scope.toDetail = function (id) {
-            $state.go('app.home_dreamdetail',{id:id});
-          };
+      $scope.toDetail = function (id) {
+        $state.go('app.home_dreamdetail',{id:id});
+      };
 
   }]);
     

+ 12 - 12
miaomiao/www/templates/home/search.html

xqd xqd xqd
@@ -30,21 +30,21 @@
                  <div class="item item-divider">
                      用户
                  </div>
-                 <div class="item sarch-item" ng-repeat="user_info in user_infos" ng-if="$index<3">
-                     <img ng-src="{{user_info.avtar}}" />  
+                 <div class="item sarch-item" ng-repeat="user_info in user_infos" ng-if="$index<3" ng-click="toUser(user_info.id)">
+                     <img ng-src="{{user_info.avatar}}" />  
                      <span style="padding:5px;">{{user_info.nickname}}</span>
                      <span class="level">Lv.3</span>
                  </div>
-                 <div class="item" style="text-align:center;color:#FF4B82;font-size:1.1rem;padding:10px;" ng-click="showMore(keyword,1)" ng-if="user_infos.length>=3">更多>></div>
+                 <div class="item" style="text-align:center;color:#FF4B82;font-size:1.1rem;padding:10px;" ng-click="showMore(vm.keyword,1)" ng-if="user_infos.length>=3">更多>></div>
                  <div class="item item-divider">
                      梦想
                  </div>
-                 <div class="item item-thumbnail-left" ng-repeat="dream_info in dream_infos" ng-if="$index<3">
+                 <div class="item item-thumbnail-left" ng-repeat="dream_info in dream_infos" ng-if="$index<3" ng-click="toDetail(dream_info.id)">
                      <img ng-src="{{dream_info.img.pic}}" />
                      <h2>{{dream_info.name}}</h2>
                      <p style="white-space:normal">{{dream_info.about}}</p>
                  </div>
-                 <div class="item" style="text-align:center;color:#FF4B82;font-size:1.1rem;padding:10px;" ng-click="showMore(keyword,2)" ng-if="dream_infos.length>=3">更多>></div>
+                 <div class="item" style="text-align:center;color:#FF4B82;font-size:1.1rem;padding:10px;" ng-click="showMore(vm.keyword,2)" ng-if="dream_infos.length>=3">更多>></div>
                  
                  <div class="item item-divider">
                      标签
@@ -74,17 +74,17 @@
          <div ng-if="index>0">
              <div class="tabs-striped tabs-top">
                  <div class="tabs" style="top:0">
-                     <a ng-class="type==1?'tab-item active':'tab-item'" ng-click="showMore(vm.keyword,1)">
+                     <a ng-class="index==1?'tab-item active':'tab-item'" ng-click="showMore(vm.keyword,1)">
                          用户
                      </a>
-                     <a ng-class="type==2?'tab-item active':'tab-item'" ng-click="showMore(vm.keyword,2)">
+                     <a ng-class="index==2?'tab-item active':'tab-item'" ng-click="showMore(vm.keyword,2)">
                         梦想
                      </a>
                  </div>
              </div>
              <div ng-if="index==1" class="list more-userlist">
-                 <div class="item sarch-item" ng-repeat="user_info in user_infos">
-                     <img ng-src="{{user_info.avtar}}" />
+                 <div class="item sarch-item" ng-repeat="user_info in user_infos"  ng-click="toUser(user_info.id)">
+                     <img ng-src="{{user_info.avatar}}" />
                      <span style="padding:5px;">{{user_info.nickname}}</span>
                      <span class="level">Lv.3</span>
                      <img ng-src="img/king.png" class="imgitem" />
@@ -95,10 +95,10 @@
                  </div>
              </div>
              <div ng-if="index==2" class="list more-userlist">
-                 <div class="item" style="padding:0" ng-repeat="dream_info in dream_infos">
-                     <img class="reply-head" src="../../img/demo/head1.jpg"  style="margin:5px 15px" />
+                 <div class="item" style="padding:0" ng-repeat="dream_info in dream_infos" ng-click="toDetail(dream_info.id)">
+                     <img class="reply-head" ng-src="{{dream_info.user.avatar}}" style="margin:5px 15px" />
                      <span style="position:relative;top:-25px;font-size:1.1rem;">{{ dream_info.name }}</span>
-                     <img style="display:block;width:100%" src="../../img/demo/pict.png" />
+                     <img style="display:block;width:100%" ng-src="{{dream_info.img.pic}}" />
                  </div> 
                 
              </div>

+ 6 - 5
server/app/Http/Controllers/Api/V1/DreamController.php

xqd xqd
@@ -510,15 +510,15 @@ class DreamController extends Controller
                 'name'  => 'required',
                 'about'  => 'required',
                 'coin'  => 'required|integer',
-                'time'  => 'required|integer',
+                'days'  => 'required|integer',
             ],
             [
                 'name.required'  => '梦想标题必填',
                 'about.required'  => '梦想介绍必填',
                 'coin.required'  => '梦想币必填',
                 'coin.integer'  => '梦想币必须是正整数',
-                'time.required'  => '实现时间必填',
-                'time.integer'  => '实现时间必须是正整数',
+                'days.required'  => '实现时间必填',
+                'days.integer'  => '实现时间必须是正整数',
             ]
         );
         if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
@@ -530,9 +530,10 @@ class DreamController extends Controller
         $b = $setting?$setting->value:1;
         $t = 21*3600 / 60;
 
-        $data = $request->except('_token','pics');
+        $days = $request->days;
+        $data = $request->except('_token','pics','days');
         $data['user_id'] = $user->id;
-        $data['time'] = 21*3600;
+        $data['end_time'] = strtotime('+'+$days+' days');
         \Log::debug(' care_num:'.$care_num.' a:'.$a.' b:'.$b.' t:'.$t);
         if ($care_num == 0) {
             $data['score'] = (($a/$t) + $b)*100000000 ;

+ 1 - 1
server/database/migrations/2017_06_02_044138_create_dream_info_table.php

xqd
@@ -19,7 +19,7 @@ class CreateDreamInfoTable extends Migration
             $table->string('name',20)->comment('梦想名称');
             $table->text('about')->comment('梦想介绍');
             $table->integer('coin')->default(0)->comment('所需梦想币');
-            $table->integer('time')->default(0)->comment('梦想倒计时');
+            $table->timestamp('time')->default(0)->comment('梦想倒计时');
             $table->integer('get_coin')->default(0)->comment('获得梦想币');
             $table->integer('mark')->default(0)->comment('梦想分');
             $table->tinyInteger('status')->default(0)->comment('梦想状态');