Browse Source

检测: 解决苹果浏览器new date字段,不兼容的问题

shenjunjie 7 years ago
parent
commit
9681b7c667
2 changed files with 26 additions and 20 deletions
  1. 2 2
      app.html
  2. 24 18
      pages/mobile/center/vendor/btobapCheck.vue

+ 2 - 2
app.html

@@ -9,10 +9,10 @@
   <link rel="stylesheet" type="text/css" href="https://at.alicdn.com/t/font_452262_6koxroe1k5l.css">
   <link rel="stylesheet" type="text/css" href="https://at.alicdn.com/t/font_452262_6koxroe1k5l.css">
   <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/3.4.2/css/swiper.min.css" />
   <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/3.4.2/css/swiper.min.css" />
   <link rel="stylesheet" href="https://unpkg.com/mint-ui@1/lib/style.css">
   <link rel="stylesheet" href="https://unpkg.com/mint-ui@1/lib/style.css">
-  <!--<script src="https://wechatfe.github.io/vconsole/lib/vconsole.min.js?v=3.2.0"></script>-->
+  <script src="https://wechatfe.github.io/vconsole/lib/vconsole.min.js?v=3.2.0"></script>
   {{ HEAD }}
   {{ HEAD }}
   <script>
   <script>
-    // var vConsole = new VConsole();
+    var vConsole = new VConsole();
     var _hmt = _hmt || [];
     var _hmt = _hmt || [];
     var _paq = _paq || [];
     var _paq = _paq || [];
     /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
     /* tracker methods like "setCustomDimension" should be called before "trackPageView" */

+ 24 - 18
pages/mobile/center/vendor/btobapCheck.vue

@@ -457,10 +457,6 @@
       resultMonth() {
       resultMonth() {
         this.isShowMonthChoose = false
         this.isShowMonthChoose = false
         if (this.$monthType === 'out') {
         if (this.$monthType === 'out') {
-          // let _time2 = new Date(this.$value)
-          // _time2.setDate(1)
-          // _time2.setMonth(_time2.getMonth() + 1)
-          // _time2.setDate(_time2.getDate() - 1)
           let _time2 = this.computedTime(this.$value)
           let _time2 = this.computedTime(this.$value)
           let _d = this.computedTime(new Date())
           let _d = this.computedTime(new Date())
           if (_time2.getTime() > _d.getTime()) {
           if (_time2.getTime() > _d.getTime()) {
@@ -477,10 +473,6 @@
           this.filterParams.page = 1
           this.filterParams.page = 1
           this.setSelect('', '', true)
           this.setSelect('', '', true)
         } else {
         } else {
-          // let _time2 = new Date(this.$value)
-          // _time2.setDate(1)
-          // _time2.setMonth(_time2.getMonth() + 1)
-          // _time2.setDate(_time2.getDate() - 1)
           let _time2 = this.computedTime(this.$value)
           let _time2 = this.computedTime(this.$value)
           let _d = this.computedTime(new Date())
           let _d = this.computedTime(new Date())
           if (_time2.getTime() > _d.getTime()) {
           if (_time2.getTime() > _d.getTime()) {
@@ -512,6 +504,7 @@
       setDate (type) {
       setDate (type) {
         if (this.dateObj[type]) {
         if (this.dateObj[type]) {
           // 初始化为00:00:00
           // 初始化为00:00:00
+          alert(this.dateObj[type])
           this.dateObj[type] = new Date(this.dateObj[type]).getTime() - 8 * 60 * 60 * 1000
           this.dateObj[type] = new Date(this.dateObj[type]).getTime() - 8 * 60 * 60 * 1000
           if (this.dateObj.fromDate && this.dateObj.toDate && this.dateObj.fromDate > this.dateObj.toDate) {
           if (this.dateObj.fromDate && this.dateObj.toDate && this.dateObj.fromDate > this.dateObj.toDate) {
             if (type === 'fromDate') {
             if (type === 'fromDate') {
@@ -763,21 +756,29 @@
               }
               }
             }
             }
             if (this.ShowApcheckChooseTime) {
             if (this.ShowApcheckChooseTime) {
-              let _start = new Date(this.isShowApcheckList.objTime.value.fromDate)
-              let _end = new Date(this.isShowApcheckList.objTime.value.toDate)
+              let _time1 = this.isShowApcheckList.objTime.value.fromDate
+              _time1 = _time1.replace('-', '/')
+              let _start = new Date(_time1)
+              let _time2 = this.isShowApcheckList.objTime.value.fromDate
+              _time2 = _time2.replace('-', '/')
+              let _end = new Date(_time2)
               // 获取筛选时间的开始时间为对账的开始时间
               // 获取筛选时间的开始时间为对账的开始时间
               apCheck.beginDate = _start.getTime()
               apCheck.beginDate = _start.getTime()
               // 获取筛选的截止时间为对账的截止时间
               // 获取筛选的截止时间为对账的截止时间
               apCheck.endDate = _end.getTime()
               apCheck.endDate = _end.getTime()
             } else {
             } else {
               this.isShowApcheckList.startTime = this.isShowApcheckList.thisMonth + '-01'
               this.isShowApcheckList.startTime = this.isShowApcheckList.thisMonth + '-01'
-              let _d = new Date(this.isShowApcheckList.startTime)
+              let _time1 = this.isShowApcheckList.startTime
+              _time1 = _time1.replace('-', '/')
+              let _d = new Date(_time1)
               _d.setDate(1)
               _d.setDate(1)
               _d.setMonth(_d.getMonth() + 1)
               _d.setMonth(_d.getMonth() + 1)
               _d.setDate(_d.getDate() - 1)
               _d.setDate(_d.getDate() - 1)
 
 
               // 获取筛选时间的开始时间为对账的开始时间
               // 获取筛选时间的开始时间为对账的开始时间
-              apCheck.beginDate = new Date(this.isShowApcheckList.startTime).getTime()
+              let _time2 = this.isShowApcheckList.startTime
+              _time2 = _time2.replace('-', '/')
+              apCheck.beginDate = new Date(_time2).getTime()
               // 获取筛选的截止时间为对账的截止时间
               // 获取筛选的截止时间为对账的截止时间
               apCheck.endDate = _d.getTime()
               apCheck.endDate = _d.getTime()
             }
             }
@@ -831,8 +832,12 @@
             this.isShowApcheckList.id = res.data.id
             this.isShowApcheckList.id = res.data.id
             this.isShowApcheckList.showApcheck = true
             this.isShowApcheckList.showApcheck = true
             if (this.ShowApcheckChooseTime) {
             if (this.ShowApcheckChooseTime) {
-              let _start = new Date(this.isShowApcheckList.objTime.value.fromDate)
-              let _end = new Date(this.isShowApcheckList.objTime.value.toDate)
+              let _time1 = this.isShowApcheckList.objTime.value.fromDate
+              _time1 = _time1.replace('-', '/')
+              let _start = new Date(_time1)
+              let _time2 = this.isShowApcheckList.objTime.value.toDate
+              _time2 = _time1.replace('-', '/')
+              let _end = new Date(_time2)
               this.isShowApcheckList.startTime = _start.getFullYear() + '-' + (_start.getMonth() + 1) + '-' + _start.getDate()
               this.isShowApcheckList.startTime = _start.getFullYear() + '-' + (_start.getMonth() + 1) + '-' + _start.getDate()
               this.isShowApcheckList.endTime = _end.getFullYear() + '-' + (_end.getMonth() + 1) + '-' + _end.getDate()
               this.isShowApcheckList.endTime = _end.getFullYear() + '-' + (_end.getMonth() + 1) + '-' + _end.getDate()
             } else {
             } else {
@@ -917,6 +922,9 @@
         }
         }
       },
       },
       computedTime(num, val) {
       computedTime(num, val) {
+        if ((typeof num === 'object') && num.constructor === Date) {} else {
+          num = num.replace('-', '/')
+        }
         let _d = new Date(num)
         let _d = new Date(num)
         if (val !== undefined) {
         if (val !== undefined) {
           _d.setMonth(_d.getMonth() + val)
           _d.setMonth(_d.getMonth() + val)
@@ -931,13 +939,11 @@
         let itemL = {}
         let itemL = {}
         if (this.activeType === 'all') {
         if (this.activeType === 'all') {
           let _fromDate = this.outTimeMonth + '-01 00:00:00'
           let _fromDate = this.outTimeMonth + '-01 00:00:00'
-          // let _d = new Date(_fromDate)
           let _d = this.computedTime(_fromDate)
           let _d = this.computedTime(_fromDate)
-          // _d.setDate(1)
-          // _d.setMonth(_d.getMonth() + 1)
-          // _d.setDate(_d.getDate() - 1)
           let _endDate = _d.getFullYear() + '-' + (_d.getMonth() + 1) + '-' + _d.getDate() + ' 00:00:00'
           let _endDate = _d.getFullYear() + '-' + (_d.getMonth() + 1) + '-' + _d.getDate() + ' 00:00:00'
+          _endDate.replace('-', '/')
           _endDate = new Date(_endDate).getTime()
           _endDate = new Date(_endDate).getTime()
+          _fromDate = _fromDate.replace('-', '/')
           _fromDate = new Date(_fromDate).getTime()
           _fromDate = new Date(_fromDate).getTime()
            _url = '/sale/apCheck/customer'
            _url = '/sale/apCheck/customer'
           itemL = {
           itemL = {