ZhouFeng %!s(int64=3) %!d(string=hai) anos
pai
achega
bce5867337
Modificáronse 3 ficheiros con 75 adicións e 8 borrados
  1. 9 0
      src/api/order.js
  2. 28 0
      src/api/tool.js
  3. 38 8
      src/components/Home.vue

+ 9 - 0
src/api/order.js

@@ -1,5 +1,14 @@
 import { get, post, postJson } from './http.js';
 
+// 订单列表&订单查询
+
 export const getOrderList = ( params ) => {
   return get( 'app/order/listNew', params )
 }
+// 订单角标
+
+export const getOrderMarker = ( params ) => {
+  return get( 'app/order/markerNew', params )
+}
+
+

+ 28 - 0
src/api/tool.js

@@ -9,4 +9,32 @@ export default{
           return `${time3[1]}/${time3[2]} ${time2[0]-Math.ceil(disparityTime)}:30`
         }
     },
+    timeago(hisTime){ 
+        var diffValue = new Date().getTime() - hisTime,
+        result='',
+
+        minute = 1000 * 60,
+        hour = minute * 60,
+        day = hour * 24,
+        halfamonth = day * 15,
+        month = day * 30,
+        year = month * 12,
+
+        _year = diffValue/year,
+        _month =diffValue/month,
+        _week =diffValue/(7*day),
+        _day =diffValue/day,
+        _hour =diffValue/hour,
+        _min =diffValue/minute;
+
+        if(_year>=1) result=parseInt(_year) + "年";
+        else if(_month>=1) result=parseInt(_month) + "个月";
+        else if(_week>=1) result=parseInt(_week) + "周";
+        else if(_day>=1) result=parseInt(_day) +"天";
+        else if(_hour>=1) result=parseInt(_hour) +"个小时";
+        else if(_min>=1) result=''+parseInt(_min) +"分钟";
+        else result="1分钟";
+        return result;
+    }
+    
 }

+ 38 - 8
src/components/Home.vue

@@ -25,15 +25,22 @@
       <el-col :span="18">
         <order-list :list='orderList' :tabNum='tab_ac'></order-list>
       </el-col>
-      <el-col :span="6" v-if="orderList.length">
-        <div class="order_detail">
+      <el-col :span="6" v-if="orderList.length&&clickBool">
+        <div class="order_detail" v-if="needTrack">
           <div class="detail_title">
-            <div class="detail_txt" @click="orderDetailStutus=0" v-if="needTrack" :class="{'detail_txt_ac':orderDetailStutus==0?true:false}">订单跟踪</div>
+            <div class="detail_txt" @click="orderDetailStutus=0" :class="{'detail_txt_ac':orderDetailStutus==0?true:false}">订单跟踪</div>
             <div class="detail_txt" @click="orderDetailStutus=1" :class="{'detail_txt_ac':orderDetailStutus==1?true:false}">订单详情</div>
           </div>
           <order-detail :tabNum='tab_ac' v-if="orderDetailStutus==1"></order-detail>
           <order-track :tabNum='tab_ac' v-if="orderDetailStutus==0"></order-track>
         </div>
+        <div class="order_detail" v-else>
+          <div class="detail_title">
+            <div class="detail_txt" @click="orderDetailStutus=1">订单详情</div>
+          </div>
+          <order-detail :tabNum='tab_ac' v-if="orderDetailStutus==1"></order-detail>
+          <order-track :tabNum='tab_ac' v-if="orderDetailStutus==0"></order-track>
+        </div>
       </el-col>
     </el-row>
     <!-- <order-map></order-map> -->
@@ -46,7 +53,7 @@
   import orderMap from './orderComponents/orderAMap.vue';
   import OrderList from './orderComponents/orderList.vue';
   import orderTrack from './orderComponents/orderTrack.vue'
-  import { getOrderList} from '../api/order.js';
+  import { getOrderList,getOrderMarker } from '../api/order.js';
   export default {
     data() {
       return {
@@ -69,7 +76,9 @@
           pageNum: 1,
           pageSize: 10
         },
-        needTrack:false
+        needTrack:false,
+        markerNum:'',
+        clickBool:false
       }
     },
     components: {
@@ -81,9 +90,23 @@
     },
     mounted() {
       this.getOrder();
+      this.getMarker();
       console.log(this.$tool.eosFormatTime2("2017-07-10 16:00:00",2.5))
     },
     methods: {
+      getMarker(){
+        getOrderMarker().then(res => {
+          this.markerNum = res.data;
+          this.tab_list[0].num = res.data.toBeBillNum;
+          this.tab_list[1].num = res.data.appointNum;
+          this.tab_list[2].num = res.data.toBeReceivedNum;
+          this.tab_list[3].num = res.data.toBePickedNum;
+          this.tab_list[4].num = res.data.inDeliveryNum;
+          this.tab_list[5].num = res.data.exceptionNum;
+          this.tab_list[6].num = res.data.cancelNum;
+          console.log(this.markerNum);
+        })
+      },
       sendOrder() {
         this.$refs.sendOrderPopup.init();
       },
@@ -101,15 +124,22 @@
       },
       getOrder() {
         let _this = this;
+        var minute = 1000 * 60;
+        var hour = minute * 60;
+        var day = hour * 24;
         getOrderList(this.params).then(res => {
           res.data.data.forEach(element => {
-            if(_this.tab_ac = 1){
-              element.timeTxt = _this.$tool.eosFormatTime2(element.exceptTime,element.delayTime);
+            element.takeTimeTxt = this.$tool.timeago((new Date(element.takeTime)).getTime());
+            if(_this.tab_ac == 1){
+              if(element.exceptTime){
+                element.timeTxt = _this.$tool.eosFormatTime2(element.exceptTime,element.delayTime);
+              }else{
+                element.timeTxt = '';
+              }
               
             }
             this.orderList.push(element)
           });
-          console.log(this.orderList);
         })
       },
     }