USER-20230908AJ\Administrator 1 سال پیش
والد
کامیت
c53304edc5
2فایلهای تغییر یافته به همراه67 افزوده شده و 5 حذف شده
  1. 53 2
      pages/statistics/module/head_filter.vue
  2. 14 3
      pages/statistics/statistics.vue

+ 53 - 2
pages/statistics/module/head_filter.vue

@@ -31,6 +31,7 @@
 
 <script>
 	import EnSelect from "@/components/en-utils/en-select/en-select.vue";
+  import tools from "@/service/tools";
 
 	export default {
 		name: 'head_filter',
@@ -54,14 +55,16 @@
         newUserTypeName:'',
         dateName:'日数据',
         dateData:[{'id':1,'name':'日数据'},{'id':2,'name':'周数据'},{'id':3,'name':'月数据'},{'id':4,'name':'年数据'}],
+
         dateTypeObj:{
-          dateType:1,//时间类型
+          dateType:4,//时间类型
           selectDate:'2023-02-25',//自定义的时候传数组,其它传开始日期
           money_type:1,
           censusUserType:1,
           product_id:5,
         },
-        selectType:1
+        selectType:1,
+        maxData:'',
 
 			};
 		},
@@ -69,11 +72,58 @@
       'userStatusList':function () {
         console.log(this.userStatusList)
         this.setCensusUserType(0)
+      },
+      'dateTypeObj':function (){
+        this.$emit('input',this.dateTypeObj)
       }
     },
     mounted() {
+      this.getDateStatus()
     },
 		methods: {
+      getDateStatus(){
+        let myDate = new Date();
+        let myYear = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
+        let myMonth = myDate.getMonth() + 1; //获取当前月份(0-11,0代表1月)
+        let myToday = myDate.getDate(); //获取当前日(1-31)
+        let time = myYear+'/'+(myMonth>=10?myMonth:'0'+myMonth)+'/'+(myToday>=10?myToday:'0'+myToday)
+        let maxDataTime = new Date(this.maxData.replace(/-/g, "/")).getTime()
+        let myDataTime = new Date(time).getTime()
+
+        if(maxDataTime<myDataTime){
+          this.dateTypeObj.selectDate = this.maxData
+        }else{
+          this.dateTypeObj.selectDate = myYear+'/'+myMonth+'/'+myToday
+        }
+        this.setTimeData( this.dateTypeObj.selectDate,0)
+      },
+      setTimeData(date,num){
+        //时间初始化
+        let ret=null;
+        if(this.dateTypeObj.dateType===1){
+          ret= tools.getStatisticsDate(date,num)
+        }else if(this.dateTypeObj.dateType===2){
+          ret= tools.getNextWeek(date,num)
+        }else if(this.dateTypeObj.dateType===3){
+          ret= tools.dateTypeObj.getNextMonth(date,num)
+        }else if(this.dateTypeObj.dateType===4){
+          ret= tools.getNextYear(date,num)
+        }
+        console.log(ret)
+        if(ret){
+          // let maxDataTime = new Date(this.maxData.replace(/-/g, "/")).getTime()
+          // let time = (ret[1].y + ''+'/') + (ret[1].m + '') + ('/'+ret[1].d + '')
+          // let myDataTime = new Date(time).getTime()
+          this.dateTypeObj.selectDate=ret[0]['y']+'-'+ret[0]['m']+'-'+ret[0]['d'];
+          let timeData=[ret[0]['y']+' | '+ret[0]['m']+'.'+ret[0]['d']];
+          if(ret[0]['y']*1===ret[1]['y']*1){
+            timeData[1]=ret[1]['m']+'.'+ret[1]['d']
+          }else {
+            timeData[1]=ret[1]['y']+' | '+ret[1]['m']+'.'+ret[1]['d']
+          }
+          this.$emit('setTimeDate',timeData)
+        }
+      },
       setCensusUserType(index){
         this.dateTypeObj.censusUserType=this.userStatusList[index].id
         this.newUserTypeName=this.userStatusList[index].name
@@ -82,6 +132,7 @@
       setDateType(index){
         this.dateTypeObj.dateType=this.dateData[index].id
         this.dateName=this.dateData[index].name
+        this.getDateStatus()
         this.endPopup()
       },
 			endPopup() {

+ 14 - 3
pages/statistics/statistics.vue

@@ -1,9 +1,9 @@
 <template>
 	<view class="total-page page_env page-box container">
-		<Nav :title="'2024-3.12-3.18'+ statType" :back="false" is_icons is_fixed :bgHeight="bgHeight"
+		<Nav :title="timeData[0]+'--'+timeData[1]" :back="false" is_icons is_fixed :bgHeight="bgHeight"
 			:navsHeight="navsHeight" :opacity="scrollTop" :justify="'left'" :color="'#fff'" :fixedHeight="160">
 			<view class="task-tabs m-t20" :style="{top:`${$tools.topHeight()}px`}">
-				<HeadFilter @onTopSelect="onTopSelect" :user-status-list="userStatusList"></HeadFilter>
+				<HeadFilter v-model="dateTypeObj" @onTopSelect="onTopSelect" :user-status-list="userStatusList" @setTimeDate="setTimeDate"></HeadFilter>
 				<view class="m-lr30 m-tb30 bor-255 r-100" v-if="statType === 7">
 					<uv-subsection :list="list" :bgColor="'rgba(255,255,255,0.1)'" :activeColor="'#0FB160'"
 						:inactiveColor="'#004615'" :fontSize="14" custom-style="height: 70rpx;border-radius: 30rpx;"
@@ -96,6 +96,7 @@
 		},
 		data() {
 			return {
+        timeData:['',''],
 				is_single_data: false, // 顶部单行统计是否显示
 				is_tabs_fixed: false, // tabs是否固定
 				scrollTop: 0,
@@ -114,7 +115,14 @@
 				navsHeight: 65,
 				positionHeight: 50,
 				list: ['中银消费', '中邮消费', '新网车抵'],
-				userStatusList: []
+				userStatusList: [],
+        dateTypeObj:{
+          dateType:4,//时间类型
+          selectDate:'2023-02-25',//自定义的时候传数组,其它传开始日期
+          money_type:1,
+          censusUserType:0,
+          product_id:5,
+        },
 			}
 		},
 		onLoad() {
@@ -143,6 +151,9 @@
 			// },
 		},
 		methods: {
+      setTimeDate(timeDate){
+        this.timeData=timeDate
+      },
 			getUserType() {
 				getUserType().then((res) => {
 					if (res.code === 1) {