From f6088a5a51fd0b8d7dcbc471f6713bbd3710fc84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E7=81=BF=E6=A1=A2?= Date: Sun, 19 Jun 2016 23:33:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E6=B6=88=E6=81=AF=E6=8F=90=E9=86=92?= =?UTF-8?q?=E9=83=A8=E5=88=86=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Order/OrderController.php | 28 +++--- public/js/company/cpy_index.js | 4 - public/js/create_records/order.js | 92 +++++-------------- public/js/layouts/cpy_sidebar/cpy_sidebar.js | 67 ++++++++------ resources/views/layouts/cpy_sidebar.blade.php | 3 +- 5 files changed, 77 insertions(+), 117 deletions(-) diff --git a/app/Http/Controllers/Order/OrderController.php b/app/Http/Controllers/Order/OrderController.php index 75f4d80..c15655a 100644 --- a/app/Http/Controllers/Order/OrderController.php +++ b/app/Http/Controllers/Order/OrderController.php @@ -4,6 +4,7 @@ use Illuminate\Http\Request; +use App\Order; use App\Http\Requests; use App\Http\Controllers\Controller; @@ -36,21 +37,18 @@ public function addOrder(){ ->where('id', $curAlbum) ->pluck('name'); - $eid = \DB::table('orders') - ->insertGetId( - array( - 'user_name' => $curUserName[0], - 'album_name' =>$curAlbumName[0], - 'price' => $oPrice, - 'quantity' => $oNum, - 'address' => $oAddress, - 'status' => "未付款", - 'order_date' => $orderTime, - 'delivery_date' => $orderTime, - 'comment' => $oComment, - 'template' => $oTem - ) - ); + $newOrder = new Order; + $newOrder->user_name = $curUserName[0]; + $newOrder->album_name = $curAlbumName[0]; + $newOrder->price = $oPrice; + $newOrder->quantity = $oNum; + $newOrder->address = $oAddress; + $newOrder->status = "未付款"; + $newOrder->order_date = $orderTime; + $newOrder->delivery_date = $oComment; + $newOrder->comment = ""; + $newOrder->template = $oTem; + $eid = $newOrder->save(); //模版使用次数自增 \DB::table('templates')->where('id', $oTem)->increment('count'); diff --git a/public/js/company/cpy_index.js b/public/js/company/cpy_index.js index 2e672a3..546685a 100644 --- a/public/js/company/cpy_index.js +++ b/public/js/company/cpy_index.js @@ -31,7 +31,6 @@ yinjiApp.controller('cpyIndexController', $http.get("/cpy/getOrders") .success(function (response) { - console.log("Nihao "); //首页这里只显示前5个订单 for (var i = 0 ; i < 5; i++){ if(response[i] != null) @@ -39,10 +38,8 @@ yinjiApp.controller('cpyIndexController', } //获取首页报表数据 var date,quantity,orderDate,data=new Object(); - console.log (response.length); for (i=0; i>>>>>> d66a417a02acaa3755d91df5b496faa927fb490d + $scope.addOrder = function() { + if ($("#text_box2").val() == 0 || $("#text_box1").val() == 0 || + ($("#text_box2").val() < $("#text_box1").val())) { alert("页码错误"); - }else{ - if($("#text_box2").val() < $("#text_box1").val()){ - - } - else{ - var pageRange = $("#text_box1").val() + "-" + $("#text_box2").val(); - var pagePrice = ($("#text_box2").val() - $("#text_box1").val()) * 10;//单价10块一张。。。 - - var commentText = $scope.oComment; - if(commentText == "" || commentText == null){ - commentText = "无"; - } - -<<<<<<< HEAD - if(temId == 0){ - var oTem = 0; - }else{ - var oTem = temId.substring(3,4); + } else { + var pageRange = $("#text_box1").val() + "-" + $("#text_box2").val(); + var pagePrice = ($("#text_box2").val() - $("#text_box1").val()) * 10;//单价10块一张。。。 - } - - $http({ - method: 'GET',//注意,这里必须要用GET方法 - url:'/addOrder', - params:{ - 'oName': $scope.oName, - 'oPhone': $scope.oPhone, - 'oAddress' : $scope.oAddress, - 'oComment' : commentText, - 'oNum' : 1, - 'oPrice' : pagePrice, - 'oTemplate' : oTem - } - }) - .success(function(data) { - if(data != null){ - console.log(data); - alert("成功!"); - window.location.href = "/"; - } - else{ - console.log("false"); - } - }); + var commentText = $scope.oComment; + if (commentText == "" || commentText == null) { + commentText = "无"; } -======= - if(temId == 0){ + if (temId == 0) { //console.log("00000"); var oTem = 0; - }else{ - var oTem = temId.substring(3,4); + } else { + var oTem = temId.substring(3, 4); } - + $http({ method: 'GET',//注意,这里必须要用GET方法 - url:'/addOrder', - params:{ + url: '/addOrder', + params: { 'oName': $scope.oName, 'oPhone': $scope.oPhone, - 'oAddress' : $scope.oAddress, - 'oComment' : commentText, - 'oNum' : pageRange, - 'oPrice' : pagePrice, - 'oTemplate' : oTem + 'oAddress': $scope.oAddress, + 'oComment': commentText, + 'oNum': pageRange, + 'oPrice': pagePrice, + 'oTemplate': oTem } - }) - .success(function(data) { - if(data != null){ + }).success(function (data) { + if (data != null) { console.log(data); alert("成功!"); window.location.href = "/orderInfo"; } - else{ + else { console.log("false"); } }); ->>>>>>> d66a417a02acaa3755d91df5b496faa927fb490d } - - } }); \ No newline at end of file diff --git a/public/js/layouts/cpy_sidebar/cpy_sidebar.js b/public/js/layouts/cpy_sidebar/cpy_sidebar.js index 7369df3..061548f 100644 --- a/public/js/layouts/cpy_sidebar/cpy_sidebar.js +++ b/public/js/layouts/cpy_sidebar/cpy_sidebar.js @@ -50,12 +50,12 @@ yinjiApp.controller('cpyNavController', $scope.odSecond = ""; var date = new Date(), - currentYear = date.getFullYear(), - currentMonth = date.getMonth(), - currentDay = date.getDay(), - currentHour = date.getHours(), - currentMinute = date.getMinutes(), - currentSecond = date.getSeconds(), + currentYear = parseInt(date.getFullYear()), + currentMonth = parseInt(date.getMonth()+1), + currentDay = parseInt(date.getDate()), + currentHour = parseInt(date.getHours()), + currentMinute = parseInt(date.getMinutes()), + currentSecond = parseInt(date.getSeconds()), latestOrderTime,latestEvaTime; @@ -63,17 +63,22 @@ yinjiApp.controller('cpyNavController', $http.get("/cpy/getEvaluations") .success(function (response) { - var fullDateInfo = response[response.length-1].created_at.split(" "); - var date = fullDateInfo[0].split("-"); - if (date[0]==currentYear && - date[1]==currentMonth && - date[1]==currentDay){ - latestEvaTime = fullDateInfo[1].split(":"); - $scope.evaHour = currentHour - latestEvaTime[0]; - if ($scope.evaHour < 1){ - $scope.evaMinute = currentMinute - latestEvaTime[1]; - if ($scope.evaMinute < 1) - $scope.evaSecond = currentSecond - latestEvaTime[2]; + if (response != null && response.length > 0){ + var fullDateInfo = response[response.length-1].created_at.split(" "); + var date = fullDateInfo[0].split("-"); + date[0]=parseInt(date[0]); + date[1]=parseInt(date[1]); + date[2]=parseInt(date[2]); + if (date[0]==currentYear && + date[1]==currentMonth && + date[2]==currentDay){ + latestEvaTime = fullDateInfo[1].split(":"); + $scope.evaHour = currentHour - latestEvaTime[0]; + if ($scope.evaHour < 1){ + $scope.evaMinute = currentMinute - latestEvaTime[1]; + if ($scope.evaMinute < 1) + $scope.evaSecond = currentSecond - latestEvaTime[2]; + } } } }); @@ -83,19 +88,25 @@ yinjiApp.controller('cpyNavController', $http.get("/cpy/getOrders") .success(function (response) { - var fullDateInfo = response[response.length-1].created_at.split(" "); - var date = fullDateInfo[0].split("-"); - if (date[0]==currentYear && - date[1]==currentMonth && - date[1]==currentDay) { - latestOrderTime = fullDateInfo[1].split(":"); - $scope.odHour = currentHour - latestOrderTime[0]; - if ($scope.odHour < 1) { - $scope.odMinute = currentMinute - latestOrderTime[1]; - if ($scope.odMinute < 1) - $scope.odSecond = currentSecond - latestOrderTime[2]; + if (response != null && response.length > 0) { + var fullDateInfo = response[response.length - 1].created_at.split(" "); + var date = fullDateInfo[0].split("-"); + date[0]=parseInt(date[0]); + date[1]=parseInt(date[1]); + date[2]=parseInt(date[2]); + if (date[0] == currentYear && + date[1] == currentMonth && + date[2] == currentDay) { + latestOrderTime = fullDateInfo[1].split(":"); + $scope.odHour = currentHour - latestOrderTime[0]; + if ($scope.odHour < 1) { + $scope.odMinute = currentMinute - latestOrderTime[1]; + if ($scope.odMinute < 1) + $scope.odSecond = currentSecond - latestOrderTime[2]; + } } } + console.log('Hour:'+$scope.odHour+'\nMinute:'+$scope.odMinute+'\nSecond:'+$scope.odSecond); }); diff --git a/resources/views/layouts/cpy_sidebar.blade.php b/resources/views/layouts/cpy_sidebar.blade.php index 1e174bc..738a8ab 100644 --- a/resources/views/layouts/cpy_sidebar.blade.php +++ b/resources/views/layouts/cpy_sidebar.blade.php @@ -55,7 +55,8 @@