baimeng 9 years ago
parent
commit
4eb5d59b40

+ 26 - 7
wl/www/js/config/router.js

xqd
@@ -70,16 +70,35 @@
                 }
             }
         })
+        .state('wl.car_add', {
+            url: '/car/add',
+            views: {
+                'wl-car': {
+                    templateUrl: 'templates/car/add.html',
+                    controller: 'carAddCtrl'
+                }
+            }
+        })
         .state('wl.car_detail', {
-                url: '/car/detail',
-                views: {
-                    'wl-car': {
-                        templateUrl: 'templates/car/detail.html',
-                        controller: 'carDetailCtrl'
-                    }
+            url: '/car/detail',
+            params: { item: null },
+            views: {
+                'wl-car': {
+                    templateUrl: 'templates/car/detail.html',
+                    controller: 'carDetailCtrl'
                 }
+            }
         })
-       
+       .state('wl.car_success', {
+           url: '/car/success',
+           params: { item: null },
+           views: {
+               'wl-car': {
+                   templateUrl: 'templates/car/success.html',
+                   controller: 'carSuccessCtrl'
+               }
+           }
+       })
         //个人中心
         .state('wl.my', {
             url: '/my',

+ 99 - 12
wl/www/js/controllers/car.js

xqd
@@ -1,21 +1,108 @@
-(function (app) {
-    app.controller('carCtrl', ["$scope", "$ionicSideMenuDelegate", "$state", function ($scope, $ionicSideMenuDelegate, $state) {
-        $scope.filter = {};
+(function (app) {
+    app.controller('carCtrl', ["$scope", "$ionicSideMenuDelegate", "$state", 'carService', 'msg', function ($scope, $ionicSideMenuDelegate, $state, carService, msg) {
+        $scope.filter = {
+            hasMore: false,
+            pageIndex: 0,
+            pageSize: 10,
+            type: 1,
+            begin_address: '',
+            end_address: '',
+            midway_address: ''
+        }
+        $scope.items = [];
+        $scope.load = function (init) {
+            if (init) {
+                $scope.filter.pageIndex = 1;
+                $scope.items = [];
+            }
+            carService.listCars($scope.filter).then(function (result) {
+
+                $scope.filter.pageIndex++;
+                var more = (result.data.data.length >= $scope.filter.pageSize);
+                $scope.filter.hasMore = more;
+                $scope.items = $scope.items.concat(result.data.data);
+                if (init) {
+                    $scope.$broadcast('scroll.refreshComplete');
+                } else {
+                    $scope.$broadcast('scroll.infiniteScrollComplete');
+                }
+            }, function (erro) {
+                msg.error(JSON.stringify(erro.data));
+            });
+        }
         $scope.toggleRight = function () {
-            //$scope.load(true);
+            $scope.load(true);
             $ionicSideMenuDelegate.toggleRight();
         };
-        $scope.load=function (init) {
-    
+        $scope.detail = function (item) {
+            $state.go('wl.car_detail', { item: item })
         }
-        $scope.godetail = function () {
-            $state.go('wl.car_detail');
+        $scope.add = function () {
+            $state.go('wl.car_add');
         }
-    }
-
-    ]);
-    app.controller('carDetailCtrl', ['$scope', function ($scope) {
+        $scope.load(true);
+    }]);
+    app.controller('carAddCtrl', ["$scope", "$state", "carService", "msg", function ($scope, $state, carService, msg) {
+        $scope.vm = { type: 1 };
+        $scope.save = function () {
+            var price = new Number($scope.vm.price);
+            if (!price) {
+                msg.text('输入价格');
+                return;
+            }
+            if (!$scope.vm.begin_address) {
+                msg.text('请输入出发地址');
+                return;
+            }
+            if (!$scope.vm.end_address) {
+                msg.text('请输入到达地址');
+                return;
+            }
+            if (!$scope.vm.midway_address) {
+                msg.text('请输入途经地址');
+                return;
+            }
+            if (!$scope.vm.detail) {
+                msg.text('请输入详情');
+                return;
+            }
+            msg.loading('提交中...');
+            carService.addCar($scope.vm).then(function (result) {
+                $state.go('wl.car');
+                msg.hide();
+            }, function (erro) {
+                msg.hide();
+                msg.error(JSON.stringify(erro.data));
+            });
+        }
+    }]);
+    app.controller('carDetailCtrl', ["$scope", '$stateParams', 'msg', 'orderService', '$state', function ($scope, $stateParams, msg, orderService, $state) {
+        $scope.vm = $stateParams.item;
+        //下单
+        $scope.bill = function () {
+            msg.confirm('下单提示', '确定下单?').then(function (res) {
+                if (res) {
+                    msg.loading('下单中...');
+                    orderService.addOrder({ message_id: $scope.vm.id }).then(function (result) {
+                        msg.hide();
+                        $state.go('wl.car_success', { item: $scope.vm });
+                    }, function (erro) {
+                        msg.hide();
+                        msg.error(JSON.stringify(erro.data));
+                    })
+                } else {
 
+                }
+            });
+        }
+    }]);
+    app.controller('carSuccessCtrl', ['$scope', '$state', '$ionicHistory', '$stateParams', function ($scope, $state, $ionicHistory, $stateParams) {
+        $scope.vm = $stateParams.item;
+        //下单成功
+        $scope.back = function () {
+            $ionicHistory.clearHistory();
+            $state.go('wl.car');
+        }
     }]);
 })(angular.module('app.controllers'));
 

+ 10 - 2
wl/www/js/services/carservice.js

xqd
@@ -1,13 +1,21 @@
 (function (app) {
     app.factory('carService', ['$http', 'config', "util", 'data', function ($http, config, util, data) {
         return {
-            //发布源信息
-            addGoods: function (model) {
+            //发布源信息
+            addCar: function (model) {
                 return $http({
                     url: config.server + 'api/messages',
                     method: "post",
                     data: model
                 })
+            },
+            //车源列表
+            listCars: function (model) {
+                return $http({
+                    url: config.server + 'api/messages/search',
+                    method: "get",
+                    data: model
+                })
             }
             
         };

+ 27 - 0
wl/www/templates/car/add.html

xqd
@@ -0,0 +1,27 @@
+<ion-view view-title="发布车源">
+    <ion-content>
+        <div class="list">
+            <div class="item item-divider">
+                <span>请填写您要发布的车源信息</span>
+            </div>
+            <label class="item item-input">
+                <input ng-model="vm.price"   type="number" placeholder="价格">
+            </label>
+            <label class="item item-input ">
+                <input  ng-model="vm.begin_address"   type="text" placeholder="出发地址">
+            </label>
+            <label class="item item-input ">
+                <input  ng-model="vm.end_address" type="text" placeholder="抵达地址">
+            </label>
+            <label class="item item-input ">
+                <input  ng-model="vm.midway_address" type="text" placeholder="途经地址">
+            </label>
+            <label class="item item-input">
+                <textarea placeholder="详情" rows="8" ng-model="vm.detail"></textarea>
+            </label>
+            <div class="padding">
+                <button type="button" ng-click="save()" class="button button-full button-positive">提交</button>
+            </div>
+        </div>
+    </ion-content>
+</ion-view>

+ 22 - 43
wl/www/templates/car/detail.html

xqd
@@ -1,48 +1,27 @@
-<ion-view view-title="账单明细">
+<ion-view view-title="货源信息">
     <ion-content>
-            <div class="list">
-            <div class="casehistory-item">
-    
-            <div class="casehistory-item-photo selftest-item-photo">
-                <img src="../../img/demo/test_pic1.jpg" />
-            </div>
-            <div class="casehistory-item-info  casehistory-photo-item-info">
-                <p><span>成都华美美容整形----春熙店</span></p>
-                <p>6890元|6期,正常</p>
-                <p>应还款日:2016/8/3</p>
-                <p>本期待还款金额:1350元</p>
-            </div>
-                
-        </div>
-                <div class="list list-pay">
-                    <div class="item item-divider">还款计划 </div>
-                    <div class="item item-avatar">
-                        <h2>应还款1350元</h2>
-                        <p>2016/8/3</p>
-                        <b class="color-red">未还款</b>
-                    </div>
-                    <div class="item item-avatar">
-                        <h2>应还款1350元</h2>
-                        <p>2016/8/3</p>
-                        <b class="color-green">已还款</b>
-                    </div>
-                    <div class="item item-avatar">
-                        <h2>应还款1350元</h2>
-                        <p>2016/8/3</p>
-                        <b >待还款</b>
-                    </div>
-                    <div class="item item-avatar">
-                        <h2>应还款1350元</h2>
-                        <p>2016/8/3</p>
-                        <b>待还款</b>
-                    </div>
+        <div class="list">
+            <div class="list card">
+                <div class="item item-avatar">
+                    <img src="../../img/photo_default_turquoise.jpg" />
+                    <h2>{{vm.contact_name}}、{{vm.contact_phone}}</h2>
+                    <p>价格:<b style="color:red">¥{{vm.begin_address}}</b></p>
                 </div>
-                <div class="padding">
-                    <button type="submit"  class="button button-full button-positive">
-                        提前结清
-                    </button>
-                    
+
+                <div class="item item-body">
+                    <p style="font-weight:bold">从{{vm.begin_address}}到{{vm.end_address}},途径{{vm.midway_address}}</p>
+                    <p>
+                        {{vm.detail}}
+                    </p>
+                    <p> 
+                     {{vm.created_at}}
+                    </p>
                 </div>
-    </div>      
+
+            </div>
+            <div class="padding">
+                <button type="button" ng-click="bill()" class="button button-full button-positive">下单</button>
+            </div>
+        </div>   
     </ion-content>
 </ion-view>

+ 33 - 51
wl/www/templates/car/index.html

xqd xqd
@@ -1,4 +1,4 @@
-<ion-view view-title="UF7账单">
+<ion-view view-title="车源">
     <ion-nav-buttons side="right">
         <button class="button ion-navicon  icon-right button-clear " ng-click="toggleRight()"></button>
     </ion-nav-buttons>
@@ -8,64 +8,46 @@
                 <!--下拉刷新-->
                 <ion-refresher pulling-text="下拉刷新" on-refresh="load(true)">
                 </ion-refresher>
-                <div class="padding">
-                    <div class="casehistory-item">
-                        <div class="clearfix">
-                            <div class="casehistory-item-photo selftest-item-photo">
-                                <img src="../img/demo/test_pic1.jpg" />
+                <div class="app-link-bottom"></div>
+                <div class="row app-link">
+                    <div class="col-25">
+                        <a ng-click="add()">
+                            <div class="app-link-item">
+                                <i class="i-applink-add"></i>
+                                <span>发布车源</span>
                             </div>
-                            <div class="casehistory-item-info  casehistory-photo-item-info">
-                                <p><span>成都华美美容整形----春熙店</span></p>
-                                <p>6890元|6期,正常</p>
-                                <p>应还款日:2016/8/3</p>
-                                <p>本期待还款金额:1350元</p>
-                            </div>
-                        </div>
-                        <div class="row row-border">
-                            <button class="button  button-clear button-positive  button-block button-small" ng-click="godetail()">查看详细</button>
-                        </div>
-                    </div>
-                    <div class="casehistory-item">
-                        <div class="clearfix">
-                            <div class="casehistory-item-photo selftest-item-photo">
-                                <img src="../img/demo/test_pic2.jpg" />
-                            </div>
-                            <div class="casehistory-item-info  casehistory-photo-item-info">
-                                <p><span>平安车险----华泰保险代理</span></p>
-                                <p> 5420元|6期,<span style="color:red">逾期3天</span></p>
-                                <p>应还款日:2016/8/3</p>
-                                <p>本期待还款金额:950元</p>
-                            </div>
-                        </div>
-                        <div class="row row-border">
-                            <button class="button  button-clear button-positive  button-block button-small" ng-click="godetail()">查看详细</button>
-                        </div>
-                    </div>
-                    <div class="casehistory-item">
-                        <div class="clearfix">
-                            <div class="casehistory-item-photo selftest-item-photo">
-                                <img src="../img/demo/test_pic3.jpg" />
-                            </div>
-                            <div class="casehistory-item-info  casehistory-photo-item-info">
-                                <p><span>亚飞牙科----琴台路店</span></p>
-                                <p> 3000元|6期,正常</p>
-                                <p>应还款日:2016/8/3</p>
-                                <p>本期待还款金额:550元</p>
-                            </div>
-                        </div>
-                        <div class="row row-border">
-                            <button class="button  button-clear button-positive  button-block button-small" ng-click="godetail()">查看详细</button>
-                        </div>
+                        </a>
                     </div>
                 </div>
-            </ion-content>
-            <!--上拉更多-->
-            <ion-infinite-scroll ng-if="filter.hasMore" on-infinite="load(false)" distance="10%"></ion-infinite-scroll>
+                <div class="app-link-bottom"></div>
+                <div class="list">
+                    <a class="item" ng-repeat="item in items" ng-click="detail(item)">
+
+                        <h2>从{{item.begin_address}}到{{item.end_address}}</h2>
+                        <p>价格:{{item.price}},途经:{{item.midway_address}}</p>
+                        <p>联系人:{{item.contact_name}},电话{{item.contact_phone}}</p>
+                    </a>
+
+                </div>
+
+                <!--上拉更多-->
+                <ion-infinite-scroll ng-if="filter.hasMore" on-infinite="load(false)" distance="10%"></ion-infinite-scroll>
+
+            </ion-content>   
         </ion-side-menu-content>
         <ion-side-menu side="right">
             <ion-content>
                 <div class="list">
                     <div class="padding">
+                        <label class="item item-input">
+                            <input ng-model="filter.begin_address" type="text" placeholder="出发地">
+                        </label>
+                        <label class="item item-input">
+                            <input ng-model="filter.end_address" type="text" placeholder="抵达地">
+                        </label>
+                        <label class="item item-input">
+                            <input ng-model="filter.midway_address" type="text" placeholder="途经地">
+                        </label> 
                         <button class="button button-assertive button-block button-radius-full" ng-click="toggleRight()">应用</button>
                     </div>
                 </div>

+ 15 - 0
wl/www/templates/car/success.html

xqd
@@ -0,0 +1,15 @@
+<ion-view view-title="下单成功">
+    <ion-content>
+        <div class="card">
+            <div class="item item-text-wrap">
+                <p><img src="../../img/icon/ok_apply.png" /></p>
+                <p>价格:<b style="color:red">¥{{vm.begin_address}}</b></p>
+                <p>从{{vm.begin_address}}到{{vm.end_address}},途径{{vm.midway_address}}</p>
+                <p>联系人:{{vm.contact_name}},联系电话:{{vm.contact_phone}}</p>
+            </div>
+        </div>
+        <div class="padding">
+            <button type="button" ng-click="back()" class="button button-full button-positive">返回</button>
+        </div>
+    </ion-content>
+</ion-view>