myorder.js 3.7 KB
var state = GetQueryString("state");
console.log(state);

new Vue({
	el: '#myorder',
	filters:{
		orderType: function(value,type){
			return value=='1'?'未付款':value=='2'?'制作中':value=='3'?'待取货':value=='4'?'待评价':value=='5'?'已完成':""
		},
		stoptype:function(type){
			return type=='1'?'自提':type=='2'?'堂食':""
		}
	},

	data: {
		orderinfo: [],
		tempInfo: [],
		status: '',
		current: 0,
		tapType: 0
	},
	created: function() {
		//获取所有订单列表
		if(state){
			this.tapType = state
			this.allfood(state)
		}else{
			this.allfood();
		}
	},
	methods: {
		orderInfo(item) {
			var type = item == '0' ? '' : item
			this.tapType = item
			this.allfood(type);
//			this.showPosition();
		},
		//全部食品
		allfood: function(status) {
			this.orderinfo = []
			var that = this;
			var url = '/UserCenter/myOrderList';
			var params = {
				unique_id: localStorage.getItem('unique_id'),
				status: status
			}
			ajaxsend(url, params, function(res) {
				console.log(res);
				if(res.status) {
					var data = res.data;
					that.orderinfo = data;
					var orderlist = that.orderinfo;
					console.log(that.orderinfo);
					var orderlist = that.orderinfo;	
				}

			})
		},
		//未支付订单的去支付
		unpaypay:function(){
			window.event.stopPropagation();
			alert("支付");
		},
		//未支付订单的取消订单
		cancelorder:function(obj){
			window.event.stopPropagation();
			//alert("取消订单");
			console.log(obj);
            var con=confirm("是否删除该订单");
            if(con==true){
                var oid=obj.oid;
                var url = '/UserCenter/cancelOrder'
                var params = {
                    unique_id: localStorage.getItem('unique_id'),
                    oid: oid
                }
                ajaxsend(url, params, function(res) {
                    console.log(res);
                    if(res.status==true) {
                        alert("取消成功");
                        window.location.reload();
                    }else if(res.status==false){
                        alert("取消失败");
                        window.location.reload();
                    }

                })
            }

			
		},
		//去评价
		goevalute:function(obj){
			window.event.stopPropagation();
//			console.log(obj);
			var oid=obj.oid;
			window.location.href=linkPath+'/myorder/evaluate.html?oid=' + oid
		},
		//再来一单
		againorder:function(obj){
			window.event.stopPropagation();
			
			window.location.href=linkPath+'/index.html'
		},
		//导航去取货
		navigation:function(obj){
			window.event.stopPropagation();
			var that=this;
			var oid=obj.oid;
			var url = '/Map/goMap'
			var params = {
				oid:oid	
			}
			ajaxsend(url, params, function(res) {
				/*console.log(JSON.stringify(res))*/
				console.log(res);
			})
			
		},
		
		//定位
//		showPosition:function(position){ 
//		var lat = position.coords.latitude; //纬度 
//		var lag = position.coords.longitude; //经度 
//		alert('纬度:'+lat+',经度:'+lag); 
//		},
		//订单详情
		orderdetail: function(obj) {
			var that = this;
			console.log(obj)
			var oid = obj.oid;
			var status = obj.status;
			if(status == "1") {
				window.location.href = linkPath+'/myorder/paydetails.html?oid=' + oid
			} else if(status == "2") {
				window.location.href = linkPath+'/myorder/makedetails.html?oid=' + oid
			} else if(status == "3") {
				window.location.href = linkPath+'/myorder/takedetails.html?oid=' + oid
			} else if(status == "4") {
				window.location.href =linkPath+'/myorder/evaluatedetails.html?oid=' + oid
			} else if(status == "5") {
		    	window.location.href = linkPath+'/myorder/finishdetails.html?oid=' + oid
			
			}
		}
	}

})

//});