Ben преди 9 години
родител
ревизия
01cec36d9a

+ 4 - 1
wl/www/index.html

xqd
@@ -31,4 +31,7 @@
 <script src="js/services/msgservice.js"></script>
 <script src="js/services/dataservice.js"></script>
 <script src="js/services/utilservice.js"></script>
-<script src="js/services/userservice.js"></script>
+<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>

+ 1 - 1
wl/www/js/app.js

xqd
@@ -11,7 +11,7 @@
    }])
  .config(["$httpProvider", function ($httpProvider) {
      //http配置
-     
+     $httpProvider.defaults.headers.common['Authorization'] = 'Bearer ' + window.localStorage['token'];
  }])
 .run(["$ionicPlatform", "$location", "msg", "$rootScope", "$timeout", "$ionicHistory", "userService","$state",
     function ($ionicPlatform, $location, msg, $rootScope, $timeout, $ionicHistory, userService, $state) {

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

xqd
@@ -42,6 +42,7 @@
         })
         .state('wl.goods_detail', {
             url: '/goods/detail',
+            params: { item: null },
             views: {
                 'wl-goods': {
                     templateUrl: 'templates/goods/detail.html',

+ 77 - 4
wl/www/js/controllers/goods.js

xqd
@@ -1,14 +1,87 @@
 (function (app) {
-    app.controller('goodsCtrl', ["$scope","$state", function ($scope,$state) {
+    app.controller('goodsCtrl', ["$scope", "$state", 'goodsService', '$ionicSideMenuDelegate', 'msg', function ($scope, $state, goodsService, $ionicSideMenuDelegate, 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 = [];
+            }
+            goodsService.listGoods($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);
+            $ionicSideMenuDelegate.toggleRight();
+        };
+        $scope.detail = function (item) {
+            $state.go('wl.goods_detail', {item:item})
+        }
         $scope.add = function () {
             $state.go('wl.goods_add');
         }
+        $scope.load(true);
     }]);
-    app.controller('goodsAddCtrl', ["$scope", "$state",function ($scope,$state) {
-     
+    app.controller('goodsAddCtrl', ["$scope", "$state", "goodsService", "msg", function ($scope, $state, goodsService, 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('提交中...');
+            goodsService.addGoods($scope.vm).then(function (result) {
+                $state.go('wl.goods');
+                msg.hide();
+            }, function (erro) {
+                msg.hide();
+                msg.error(JSON.stringify(erro.data));
+            });
+        }
     }]);
-    app.controller('goodsDetailCtrl', ["$scope", function ($scope) {
+    app.controller('goodsDetailCtrl', ["$scope", '$stateParams', function ($scope, $stateParams) {
+        $scope.vm = $stateParams.item;
+        //下单
+        $scope.bill = function () {
 
+        }
     }]);
 
 })(angular.module('app.controllers'));

+ 15 - 0
wl/www/js/services/carservice.js

xqd
@@ -0,0 +1,15 @@
+(function (app) {
+    app.factory('carService', ['$http', 'config', "util", 'data', function ($http, config, util, data) {
+        return {
+            //发布货源信息
+            addGoods: function (model) {
+                return $http({
+                    url: config.server + 'api/messages',
+                    method: "post",
+                    data: model
+                })
+            }
+            
+        };
+    }]);
+})(angular.module('app.services'));

+ 22 - 0
wl/www/js/services/goodsservice.js

xqd
@@ -0,0 +1,22 @@
+(function (app) {
+    app.factory('goodsService', ['$http', 'config', "util", 'data', function ($http, config, util, data) {
+        return {
+            //发布货源信息
+            addGoods: function (model) {
+                return $http({
+                    url: config.server + 'api/messages',
+                    method: "post",
+                    data: model
+                })
+            },
+            //货源列表
+            listGoods: function (model) {
+                return $http({
+                    url: config.server + 'api/messages/search',
+                    method: "get",
+                    data: model
+                })
+            }
+        };
+    }]);
+})(angular.module('app.services'));

+ 15 - 0
wl/www/js/services/orderservice.js

xqd
@@ -0,0 +1,15 @@
+(function (app) {
+    app.factory('orderService', ['$http', 'config', "util", 'data', function ($http, config, util, data) {
+        return {
+            //下单
+            addOrder: function (model) {
+                return $http({
+                    url: config.server + 'api/orders',
+                    method: "post",
+                    data: model
+                })
+            }
+
+        };
+    }]);
+})(angular.module('app.services'));

+ 8 - 10
wl/www/templates/goods/add.html

xqd
@@ -3,23 +3,21 @@
         <div class="list">
             <div class="item item-divider">
                 <span>请填写您要发布的货源信息</span>
-                 
             </div>
-            <label class="item item-input ">
-                <span class="input-label">银行卡号</span>
-                <input style="text-align:right" type="text" placeholder="银行卡号">
+            <label class="item item-input">
+                <input ng-model="vm.price"   type="number" placeholder="价格">
             </label>
             <label class="item item-input ">
-                <span class="input-label">所属银行</span>
-                <input style="text-align:right" type="text" placeholder="所属银行">
+                <input  ng-model="vm.begin_address"   type="text" placeholder="出发地址">
             </label>
             <label class="item item-input ">
-                <span class="input-label">开户行所在地</span>
-                <input style="text-align:right" type="text" placeholder="开户行所在地">
+                <input  ng-model="vm.end_address" type="text" placeholder="抵达地址">
             </label>
             <label class="item item-input ">
-                <span class="input-label">预留手机</span>
-                <input style="text-align:right" type="text" placeholder="开户行所在地">
+                <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>

+ 53 - 43
wl/www/templates/goods/detail.html

xqd
@@ -1,48 +1,58 @@
-<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 class="list">
+            <div class="item item-divider">
+                货源
             </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>
+            <label class="item">
+                <span class="input-label">
+                   出发地:
+                </span>
+               <span style="text-align:right">{{vm.begin_address}}</span>
+            </label>
+            <label class="item">
+                <span class="input-label">
+                    抵达地:
+                </span>
+                <span  style="text-align:right">{{vm.end_address}}</span>
+            </label>
+            <label class="item">
+                <span class="input-label">
+                    途经地:
+                </span>
+                <span style="text-align:right">{{vm.midway_address}}</span>
+            </label>
+            <label class="item item-input">
+              <span class="input-label">
+        到达时间:
+    </span>
+    <span style="text-align:right">{{vm.goods_arrive_time}}</span>
+        </label> 
+            <label class="item">
+                <span class="input-label">
+                    价格(元):
+                </span>
+                <span style="text-align:right">¥{{vm.begin_address}}</span>
+            </label>
+            <label class="item">
+                <span class="input-label">
+                    联系人:
+                </span>
+                <span style="text-align:right">{{vm.contact_name}}</span>
+            </label>
+            <label class="item">
+                <span class="input-label">
+                    联系电话:
+                </span>
+                <span style="text-align:right">{{vm.contact_phone}}</span>
+            </label> 
+            <label class="item">
+             {{vm.detail}}
+            </label> 
+            
+            <div class="padding">
+                <button type="button" ng-click="bill()" class="button button-full button-positive">下单</button>
             </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>
-                <div class="padding">
-                    <button type="submit"  class="button button-full button-positive">
-                        提前结清
-                    </button>
-                    
-                </div>
-    </div>      
+        </div>   
     </ion-content>
 </ion-view>

+ 51 - 40
wl/www/templates/goods/index.html

xqd
@@ -1,46 +1,57 @@
 <ion-view view-title="货源">
-    <ion-content>
-        <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>
+    <ion-nav-buttons side="right">
+        <button class="button ion-navicon  icon-right button-clear " ng-click="toggleRight()"></button>
+    </ion-nav-buttons>
+    <ion-side-menus enable-menu-with-back-views="false">
+        <ion-side-menu-content>
+            <ion-content>
+                <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>
+                        </a>
                     </div>
-                </a>
-            </div>
-        </div>
-        <div class="app-link-bottom"></div>
-        <div class="list">
-            <!--下拉刷新-->
-            <!--<ion-refresher pulling-text="下拉刷新" on-refresh="load(true)">
-            </ion-refresher>-->
-            <a class="item item-thumbnail-left" href="#">
-                <img src="../../img/photo_default_orange.jpg" />
-                <h2>Pretty Hate Machine</h2>
-                <p>Nine Inch Nails</p>
-            </a>
-            <a class="item item-thumbnail-left" href="#">
-                <img src="../../img/photo_default_orange.jpg" />
-                <h2>Pretty Hate Machine</h2>
-                <p>Nine Inch Nails</p>
-            </a>
-            <a class="item item-thumbnail-left" href="#">
-                <img src="../../img/photo_default_orange.jpg" />
-                <h2>Pretty Hate Machine</h2>
-                <p>Nine Inch Nails</p>
-            </a>
-            <a class="item item-thumbnail-left" href="#">
-                <img src="../../img/photo_default_orange.jpg" />
-                <h2>Pretty Hate Machine</h2>
-                <p>Nine Inch Nails</p>
-            </a>
-        </div>
+                </div>
+                <div class="app-link-bottom"></div>
+                <div class="list">
+                    <!--下拉刷新-->
+                    <ion-refresher pulling-text="下拉刷新" on-refresh="load(true)">
+                    </ion-refresher>
+                    <a class="item" ng-repeat="item in items" ng-click="detail(item)">
 
-        <!--上拉更多-->
-        <ion-infinite-scroll ng-if="filter.hasMore" on-infinite="load(false)" distance="10%"></ion-infinite-scroll>
+                        <h2>从{{item.begin_address}}到{{item.end_address}}</h2>
+                        <p>价格:{{item.price}},途经:{{item.midway_address}}</p>
+                        <p>联系人:{{item.contact_name}},电话{{item.contact_phone}}</p>
+                    </a>
 
-    </ion-content>
+                </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>
+            </ion-content>
+        </ion-side-menu>
+    </ion-side-menus>
 </ion-view>