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

new Vue({
	el: '#mineorder',
	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(obj){
            var oid=obj.oid;
			window.event.stopPropagation();
            $.ajax({
                url:"/index.php/Flow/goPayFromUserCenter2",
                data:{
                    unique_id:localStorage.getItem('unique_id'),
                    oid:oid,
                    from:2
				},
                type:"POST",
                dataType:"JSON",

                success: function (data) {
                	console.log(data);
                    wx.chooseWXPay({
                        timestamp: data.data.timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
                        nonceStr: data.data.nonceStr, // 支付签名随机串,不长于 32 位
                        package: data.data.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
                        signType: data.data.signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
                        paySign: data.data.paySign, // 支付签名
                        success: function (res) {
// 支付成功后的回调函数
                        }
                    });
                }
            })
		},
		//未支付订单的取消订单
		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='/index.php?g=&m=template&a=evaluate&oid=' + oid
		},
		//再来一单
		againorder:function(obj){
			window.event.stopPropagation();

            window.location.href = '/index.php?g=&m=template&a=index';
		},
		//导航去取货
		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 = '/index.php?g=&m=template&a=paydetails&oid=' + oid
			} else if(status == "2") {
				window.location.href = '/index.php?g=&m=template&a=makedetails&oid=' + oid
			} else if(status == "3") {
				window.location.href = '/index.php?g=&m=template&a=takedetails&oid=' + oid
			} else if(status == "4") {
				window.location.href ='/index.php?g=&m=template&a=evaluatedetails&oid=' + oid
			} else if(status == "5") {
		    	window.location.href = '/index.php?g=&m=template&a=finishdetails&oid=' + oid
			
			}
		}
	}

})

//});