t_index.js 3.53 KB
var util = require('../../utils/util.js')
var uri=require('../../utils/uri.js')
import App from '../../utils/api.js'
Page({
    data:{
       totalfunction:[
           {
               imgurl:'../image/manage-total.png',
               title:'经营中心',
               isActive:true,
           },
           {
               imgurl:'../image/store-total.png',
               title:'门店管理',
               isActive:false
           }
       ],
    },
    onLoad:function(opt){
		let systeminfo=util.cache('system.info');
		let ratio=750/systeminfo.windowWidth;
		this.setData({
			contentHeight:systeminfo.windowHeight-util.cache('headerHeight')-120/ratio,
			sellerid:opt.sellerid ? opt.sellerid : util.cache('sellerid'),
			sellername:opt.sellername ? opt.sellername : ''
		})
		if(util.cache('dur')){
			wx.removeStorageSync('dur');
		}
		if(util.cache('select')){
			wx.removeStorageSync('select');
		}
		this.hasmore=true;
		this.page=0;
		this.getlist();
		
    },
	onShow(){
		if(util.cache('select')){
			if(util.cache('dur')){
				let dur=util.cache('dur');
				console.log(dur)
				let timestamp=Date.parse(new Date())/1000;
				let date=util.unixtoTime(timestamp,'YYYY-MM-DD'),mark='';
				if(dur.start.date==dur.end.date){
					if(dur.start.date==date){
						mark='今天'
					}
					if(dur.start.date==''){
						mark='今天'
					}
				}else{
					if(dur.start.date==date && dur.end.date==''){
						mark='今天'
					}
				}
				if(mark!=''){
					dur.mark=mark
				}
				this.setData({
					dur:dur
				})
			}
			wx.removeStorageSync('select');
			this.hasmore=true;
			this.page=0;
			this.getlist();
		}
		
	},
	getlist(){
		let parmdata={
			sellerid:this.data.sellerid,
			page:this.page,
			size:10
		}
		if(this.data.dur){
			if(!this.data.dur.mark){
				if(this.data.dur.start.date=='' || this.data.dur.end.date==''){
					if(this.data.dur.start.date==''){
						parmdata.stime=util.timetouUnix('2020-01-25 00:00:00','-');
						parmdata.etime=this.data.dur.end.timestamp;
					}else{
						parmdata.stime=this.data.dur.start.timestamp;
						let timestamp=Date.parse(new Date())/1000;
						let date=util.unixtoTime(timestamp,'YYYY-MM-DD');
						parmdata.etime=util.timetouUnix(date+' 23:59:59','-');
					}
				}else{
					parmdata.stime=this.data.dur.start.timestamp;
					parmdata.etime=this.data.dur.end.timestamp;
				}
				
			}
		}
		App.Orders.GetSellerSummaryOrder(parmdata).then((json)=>{
			console.log(json)
			if(json.ret==200){
				json.data.orderList.forEach((v,i)=>{
					let date=util.unixtoTime(v.cdate,'YYYY-MM-DD HH:II:SS');
					v.showdate=date.split(' ')[0];
					v.showtime=date.split(' ')[1];
					v.showdatetime=date;
				})
				let orderinfo=json.data;
				if(json.data.orderList.length<10){
					this.hasmore=false;
				}
				let orderlist=parmdata.page==0 ? [] : this.data.orderinfo.orderList;
				orderlist=orderlist.concat(json.data.orderList);
				orderinfo.orderList=orderlist;
				this.setData({
					orderinfo:json.data
				})
			}
			
		})
	},
	getnext(){
		this.page+=1;
		if(this.hasmore){
			this.getlist();
		}
		
	},
	sellermanage(){
		wx.redirectTo({
		    url:'s_index?sellerid='+this.data.sellerid
		})
	},
	totime(){
		if(this.data.dur){
			wx.navigateTo({
				url:'../report/r_time?sdate='+this.data.dur.start.date+'&edate='+this.data.dur.end.date
			})
		}else{
			wx.navigateTo({
				url:'../report/r_time'
			})
		}
		
	},
	//订单详情
	lookdetail(e){
		let orderidx=e.currentTarget.dataset.index;
		let id=e.currentTarget.dataset.id;
		wx.navigateTo({
			url:'../order/o_detail?id='+id+'&orderidx='+orderidx
		})
	},
})