Ben преди 9 години
родител
ревизия
23e6ff823e

+ 4 - 2
wl/www/index.html

xqd xqd
@@ -18,10 +18,11 @@
 <script src="js/platformOverrides.js"></script>
 <script src="lib/ionic/js/ionic.bundle.js"></script>
 <!--<script src="lib/ionic/js/ionic.bundle.min.js"></script>-->
-<!--<script src="cordova.js"></script>-->
+<script src="cordova.js"></script>
 <script src="js/app.js"></script>
 <script src="js/config/config.js"></script>
 <script src="js/config/router.js"></script>
+<script src="js/controllers/frame.js"></script>
 <!--controllers-->
 <script src="js/controllers/account.js"></script>
 <script src="js/controllers/goods.js"></script>
@@ -34,4 +35,5 @@
 <script src="js/services/userservice.js"></script>
 <script src="js/services/carservice.js"></script>
 <script src="js/services/goodsservice.js"></script>
-<script src="js/services/orderservice.js"></script>
+<script src="js/services/orderservice.js"></script>
+<script src="js/services/myservice.js"></script>

+ 41 - 0
wl/www/js/config/router.js

xqd xqd xqd
@@ -19,8 +19,10 @@
           .state('wl', {
               url: '/wl',
               abstract: true,
+              controller: "frameCtrl",
               templateUrl: 'templates/tabs.html'
           })
+
          //货源管理
         .state('wl.goods', {  
             url: '/goods',
@@ -147,6 +149,7 @@
        })
        .state('wl.my_truck_add', {
            url: '/my/truck/add',
+           params:{item:null},
              views: {
                  'wl-my': {
                      templateUrl: 'templates/my/truck-add.html',
@@ -163,6 +166,44 @@
                  }
              }
          })
+         .state('wl.my_message', {
+             url: '/my/message',
+             views: {
+                 'wl-my': {
+                     templateUrl: 'templates/my/message.html',
+                     controller: 'myMessageCtrl'
+                 }
+             }
+         })
+        .state('wl.my_message_detail', {
+            url: '/my/message/detail',
+            params:{item:null},
+            views: {
+                'wl-my': {
+                    templateUrl: 'templates/my/message-detail.html',
+                    controller: 'myMessageDetailCtrl'
+                }
+            }
+        })
+         .state('wl.my_order', {
+             url: '/my/order',
+             views: {
+                 'wl-my': {
+                     templateUrl: 'templates/my/order.html',
+                     controller: 'myOrderCtrl'
+                 }
+             }
+         })
+        .state('wl.my_order_detail', {
+            url: '/my/order/detail',
+            params: { item: null },
+            views: {
+                'wl-my': {
+                    templateUrl: 'templates/my/order-detail.html',
+                    controller: 'myOrderDetailCtrl'
+                }
+            }
+        })
         $urlRouterProvider.otherwise('/wl/goods');
     }]);
 })(angular.module('app'));

+ 4 - 4
wl/www/js/controllers/account.js

xqd
@@ -8,12 +8,12 @@
             msg.loading('登录中...');
             userService.login($scope.vm.mobile, $scope.vm.password).then(function (result) {
                 msg.hide();
-                data.setObject('user', result.data.data);
-                data.set('token', result.data.meta.token);
-                if (result.data.data.type == 1) {//托运方
+                data.setObject('user', result.data.user);
+                data.set('token', result.data.token);
+                if (result.data.user.type == 1) {//托运方
                     $state.go('wl.car');
                 }
-                if (result.data.data.type == 2) {//承运方
+                if (result.data.user.type == 2) {//承运方
                     $state.go('wl.goods');
                 }
             }, function (erro) {

+ 8 - 0
wl/www/js/controllers/frame.js

xqd
@@ -0,0 +1,8 @@
+(function (module) {
+    module.controller('frameCtrl', ["$scope", "$ionicHistory", "$state", function ($scope, $ionicHistory, $state) {
+        $scope.go = function (target) {
+            $ionicHistory.clearHistory();
+            $state.go(target);
+        };
+    }]);
+})(angular.module('app.controllers'));

+ 141 - 5
wl/www/js/controllers/my.js

xqd
@@ -76,14 +76,150 @@
        
     }]);
     
-    app.controller('myTruckCtrl', ['$scope', function ($scope) {
-
+    app.controller('myTruckCtrl', ['$scope', '$state', 'myService', 'msg', function ($scope, $state, myService, msg) {
+        $scope.filter = {
+            hasMore: false,
+            page: 0,
+            pageSize: 10,
+        }
+        $scope.items = [];
+        $scope.load = function (init) {
+            if (init) {
+                $scope.filter.pageIndex = 1;
+                $scope.items = [];
+            }
+            myService.listTrucks($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.add = function () {
+            $state.go('wl.my_truck_add', { item: {}});
+        }
+        $scope.detail = function (item) {
+            $state.go('wl.my_truck_add', {item:item});
+        }
+        $scope.load(true);
     }]);
-    app.controller('myTruckAddCtrl', ['$scope', function ($scope) {
-
+    app.controller('myTruckAddCtrl', ['$scope', 'myService', 'msg', '$state', '$stateParams', function ($scope, myService, msg, $state, $stateParams) {
+        $scope.vm = {};
+        if ($stateParams.item) {
+            $scope.vm = $stateParams.item;
+        }
+        $scope.typeOpt = [
+            { name: '厢式货车', value: '厢式货车' },
+            { name: '面包车', value: '面包车' },
+            { name: '金杯车', value: '金杯车' },
+        { name: '中巴货车', value: '中巴货车' },
+        { name: '高栏车', value: '高栏车' },
+        { name: '低栏车', value: '低栏车' },
+        { name: '平板车', value: '平板车' },
+        { name: '高低板车', value: '高低板车' },
+        { name: '半挂车', value: '半挂车' },
+        { name: '自卸车', value: '自卸车' },
+        { name: '冷藏车', value: '冷藏车' },
+        { name: '保温车', value: '保温车' },
+        { name: '罐式车', value: '罐式车' },
+        { name: '铁笼车', value: '铁笼车' },
+        { name: '集装箱运输车', value: '集装箱运输车' },
+        { name: '大件运输车', value: '大件运输车' },
+        { name: '危险品车', value: '危险品车' },
+        { name: '全挂车', value: '全挂车' },
+        { name: '加长挂车', value: '加长挂车' },
+        { name: '其他', value: '其他' }];
+        $scope.save = function () {
+            msg.loading('保存中...')
+            myService.addTruck($scope.vm).then(function (result) {
+                msg.hide();
+                $state.go('wl.my_truck');
+            }, function (erro) {
+                msg.hide();
+                msg.error(JSON.stringify(erro.data));
+            });
+        }
+     
     }]);
     app.controller('myTruckDetailCtrl', ['$scope', function ($scope) {
 
     }]);
-    
+    app.controller('myMessageCtrl', ['$scope', 'myService', 'msg', function ($scope, myService, msg) {
+        $scope.filter = {
+            hasMore: false,
+            page: 0,
+            pageSize: 10,
+        }
+        $scope.items = [];
+        $scope.load = function (init) {
+            if (init) {
+                $scope.filter.pageIndex = 1;
+                $scope.items = [];
+            }
+            myService.listMessages($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.detail = function (item) {
+            $state.go('wl.my_message_detail', { item: item });
+        }
+        $scope.load(true);
+    }]);
+    app.controller('myMessageDetailCtrl', ['$scope', '$stateParams', function ($scope, $stateParams) {
+        $scope.vm = $stateParams.item;
+        
+    }]);
+    app.controller('myOrderCtrl', ['$scope', 'myService', 'msg', '$state', function ($scope, myService, msg, $state) {
+        $scope.filter = {
+            hasMore: false,
+            page: 0,
+            pageSize: 10,
+        }
+        $scope.items = [];
+        $scope.load = function (init) {
+            if (init) {
+                $scope.filter.pageIndex = 1;
+                $scope.items = [];
+            }
+            myService.listOrders($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.detail = function (item) {
+            $state.go('wl.my_order_detail', { item: item });
+        }
+        $scope.load(true);
+    }]);
+    app.controller('myOrderDetailCtrl', ['$scope', '$stateParams', function ($scope, $stateParams) {
+        $scope.vm = $stateParams.item;
+    }]);
 })(angular.module('app.controllers'));

+ 33 - 0
wl/www/js/services/myservice.js

xqd
@@ -0,0 +1,33 @@
+(function (app) {
+    app.factory('myService', ['$http', 'config', "util", 'data', function ($http, config, util, data) {
+        return {
+            //我的车辆信息
+            listTrucks: function (model) {
+                return $http({
+                    url: config.server + 'api/user/trucks',
+                    method: "get"
+                })
+            },
+            //添加车辆
+            addTruck: function (model) {
+                return $http({
+                    url: config.server + 'api/trucks',
+                    method: "post",
+                    data: model
+                })
+            },
+            listMessages: function () {
+                return $http({
+                    url: config.server + 'api/user/messages',
+                    method: "get"
+                })
+            },
+            listOrders: function () {
+                return $http({
+                    url: config.server + 'api/user/orders',
+                    method: "get"
+                })
+            }
+        };
+    }]);
+})(angular.module('app.services'));

+ 3 - 3
wl/www/templates/my/index.html

xqd
@@ -17,13 +17,13 @@
             <a class="item item-icon-left" ui-sref="wl.my_profile">
                 <i class="i-user-info"></i><em class="fl">基本信息</em>
             </a>
-            <a class="item item-icon-left" ui-sref="wl.my_apply">
+            <a class="item item-icon-left" ui-sref="wl.my_truck">
                 <i class="i-user-car"></i><em class="fl">车辆管理</em>
             </a>
-            <a class="item item-icon-left" ui-sref="wl.my_fenqi">
+            <a class="item item-icon-left" ui-sref="wl.my_message">
                 <i class="i-user-message"></i><em class="fl">我的发布</em>
             </a>
-            <a class="item item-icon-left" ui-sref="wl.my_sudai">
+            <a class="item item-icon-left" ui-sref="wl.my_order">
                 <i class="i-user-order"></i><em class="fl">我的订单</em>
             </a>
             <a class="item item-icon-left" ui-sref="wl.my_setpassword">

+ 22 - 0
wl/www/templates/my/message-detail.html

xqd
@@ -0,0 +1,22 @@
+<ion-view view-title="发布详情">
+    <ion-content>
+        <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="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>
+    </ion-content>
+</ion-view>

+ 14 - 0
wl/www/templates/my/message.html

xqd
@@ -0,0 +1,14 @@
+<ion-view view-title="我的发布">
+    <ion-content>
+        <!--下拉刷新-->
+        <ion-refresher pulling-text="下拉刷新" on-refresh="load(true)">
+        </ion-refresher>
+        <div class="list">
+            <a class="item" ng-repeat="item in items" ng-click="detail(item)">
+                标题{{item.title}},时间{{item.created_at}}
+            </a>
+        </div>
+        <!--上拉更多-->
+        <ion-infinite-scroll ng-if="filter.hasMore" on-infinite="load(false)" distance="10%"></ion-infinite-scroll>
+    </ion-content>
+</ion-view>

+ 22 - 0
wl/www/templates/my/order-detail.html

xqd
@@ -0,0 +1,22 @@
+<ion-view view-title="订单详情">
+    <ion-content>
+        <div class="list">
+            <div class="list card">
+                <div class="item item-avatar">
+                    <img src="../../img/photo_default_turquoise.jpg" />
+                    <h2>交易人:{{vm.trade_user_id}},交易时间{{vm.deal_confirm_time}}</h2>
+                    <p>状态:<b style="color:red">{{vm.state}}</b></p>
+                </div>
+                <div class="item item-body">
+                 
+                    <p>
+                       内容:{{vm.message_id}}
+                    </p>
+                    <p>
+                        {{vm.created_at}}
+                    </p>
+                </div>
+            </div>
+        </div>
+    </ion-content>
+</ion-view>

+ 14 - 0
wl/www/templates/my/order.html

xqd
@@ -0,0 +1,14 @@
+<ion-view view-title="我的订单">
+    <ion-content>
+        <!--下拉刷新-->
+        <ion-refresher pulling-text="下拉刷新" on-refresh="load(true)">
+        </ion-refresher>
+        <div class="list">
+            <a class="item" ng-repeat="item in items" ng-click="detail(item)">
+               状态:{{item.state}}, 时间{{item.created_time}},交易人:{{item.trade_user_id}}
+            </a>
+        </div>
+        <!--上拉更多-->
+        <ion-infinite-scroll ng-if="filter.hasMore" on-infinite="load(false)" distance="10%"></ion-infinite-scroll>
+    </ion-content>
+</ion-view>

+ 0 - 5
wl/www/templates/my/sudai.html

xqd
@@ -1,5 +0,0 @@
-<ion-view title="51速贷">
-    <ion-content>
-        51速贷
-    </ion-content>
-</ion-view>

+ 55 - 2
wl/www/templates/my/truck-add.html

xqd
@@ -1,5 +1,58 @@
- <ion-view view-title="添加车辆">
+ <ion-view view-title="车辆信息">
     <ion-content>
-
+        <div class="list">
+            <div class="item item-divider">
+                您的车辆
+            </div>
+            <a class="item item-input">
+                <span class="input-label">名称<span class="mustfill">*</span></span>
+                <input style="text-align:right" ng-model="vm.name" type="text" placeholder="名称">
+            </a>
+            <label class="item item-input item-select item-select-width">
+                <span class="input-label">
+                    类型<span class="mustfill">*</span>
+                </span>
+                <select ng-model="vm.type" ng-options="x.value as x.name for x in typeOpt"></select>
+            </label>
+            <label class="item item-input ">
+                <span class="input-label">车牌号<span class="mustfill">*</span></span>
+                <input style="text-align:right" ng-model="vm.truck_no" type="text" placeholder="车牌号">
+            </label>
+            <label class="item item-input">
+                <span class="input-label">车长<span class="mustfill">*</span></span>
+                <input style="text-align:right" ng-model="vm.length" type="number" placeholder="车长">
+            </label>
+            <label class="item item-input">
+                <span class="input-label">车宽<span class="mustfill">*</span></span>
+                <input style="text-align:right" ng-model="vm.width" type="number" placeholder="车宽">
+            </label>
+            <label class="item item-input ">
+                <span class="input-label">车高<span class="mustfill">*</span></span>
+                <input style="text-align:right" type="number" ng-model="vm.height" placeholder="车高">
+            </label>
+            <label class="item item-input ">
+                <span class="input-label">车辆自重<span class="mustfill">*</span></span>
+                <input style="text-align:right" type="number" ng-model="vm.truck_weight"  placeholder="车辆自重">
+            </label>
+            <label class="item item-input ">
+                <span class="input-label">车辆载重<span class="mustfill">*</span></span>
+                <input style="text-align:right" type="number" ng-model="vm.load_weight" placeholder="车辆载重">
+            </label>
+            <label class="item item-input ">
+                <span class="input-label">容量<span class="mustfill">*</span></span>
+                <input style="text-align:right" type="text" ng-model="vm.capacity" placeholder="容量">
+            </label>
+            <label class="item item-input ">
+                <span class="input-label">开始使用日期<span class="mustfill">*</span></span>
+                <input style="text-align:right" type="date" ng-model="vm.begin_use_date" placeholder="开始使用日期">
+            </label>
+            <label class="item item-input ">
+                <span class="input-label">报废日期<span class="mustfill">*</span></span>
+                <input style="text-align:right" type="date" ng-model="vm.expire_date" placeholder="报废日期">
+            </label>
+            <div class="padding">
+                <button type="button" ng-click="save()" class="button button-full button-positive">提交</button>
+            </div>
+        </div>
     </ion-content>
 </ion-view>

+ 15 - 18
wl/www/templates/my/truck.html

xqd
@@ -1,24 +1,21 @@
 <ion-view view-title="我的车辆">
+    <ion-nav-bar class="bar-positive nav-bar-container" nav-bar-transition="ios" nav-bar-direction="exit" nav-swipe="">
+        <ion-nav-back-button>
+        </ion-nav-back-button>
+        <ion-nav-buttons side="right">
+            <button class="button  button-icon icon ion-android-add" ng-click="add()"></button>
+        </ion-nav-buttons>
+    </ion-nav-bar>
     <ion-content>
-        <div class="bar bar-header">
-            <button class="button icon ion-navicon"></button>
-            <h1 class="title">Header Buttons</h1>
-            <button class="button">Edit</button>
-        </div>
+        <!--下拉刷新-->
+        <ion-refresher pulling-text="下拉刷新" on-refresh="load(true)">
+        </ion-refresher>
         <div class="list">
-
-            <a class="item" href="#">
-                Check mail
+            <a class="item"  ng-repeat="item in items" ng-click="detail(item)">
+             名称:{{item.name}},车牌:{{item.truck_no}}
             </a>
-            <a class="item" href="#">
-                Check mail
-            </a>
-            <a class="item" href="#">
-                Check mail
-            </a>
-            <a class="item" href="#">
-                Check mail
-            </a>
-    </div>
+         </div>
+        <!--上拉更多-->
+        <ion-infinite-scroll ng-if="filter.hasMore" on-infinite="load(false)" distance="10%"></ion-infinite-scroll>
 </ion-content>
 </ion-view>

+ 3 - 3
wl/www/templates/tabs.html

xqd
@@ -1,11 +1,11 @@
 <ion-tabs class="tabs-icon-top tabs-color-active-positive">
-  <ion-tab title="货源" icon-off="ion-ios-browsers-outline" icon-on="ion-ios-browsers" ui-sref="wl.goods" >
+  <ion-tab title="货源" icon-off="ion-ios-browsers-outline" icon-on="ion-ios-browsers" ng-click="go('wl.goods')" >
     <ion-nav-view name="wl-goods"></ion-nav-view>
   </ion-tab>
-  <ion-tab title="车源" icon-off="ion-ios-cart-outline" icon-on="ion-ios-cart"  ui-sref="wl.car">
+  <ion-tab title="车源" icon-off="ion-ios-cart-outline" ng-click="go('wl.car')" icon-on="ion-ios-cart">
         <ion-nav-view name="wl-car"></ion-nav-view>
   </ion-tab>
-  <ion-tab title="我的" icon-off="ion-ios-gear-outline" icon-on="ion-ios-gear"  ui-sref="wl.my">
+  <ion-tab title="我的" icon-off="ion-ios-gear-outline" icon-on="ion-ios-gear"  ng-click="go('wl.my')">
     <ion-nav-view name="wl-my"></ion-nav-view>
   </ion-tab>
 </ion-tabs>