const util = require("../../../utils/util") Page({ data: { aid:'', orderList:[], showData:false, firstPagePath:'' // checkedIndex:-1, }, onLoad: function (options) { // if (!util.isObjEmpty(options)) { // // 活动详情页进入 // console.log('options',options) // if (!util.isEmpty(options.aid)) { // this.setData({aid:options.aid}) // } // // 小程序码进入 // if (!util.isEmpty(options.scene)) { // let that=this; // util.codeGetAid(options.scene).then(res=>{ // that.setData({aid:res.data}) // }) // } // if (!util.isEmpty(options.orderId)) { // this.jumpPage(options.orderId) // }else{ // this.getOrderList(); // } // } }, onShow: function () { let pages = getCurrentPages();//页面对象 let options = pages[pages.length-1].options; let prevpage = pages[pages.length - 2]; //上一个页面对象 if (!util.isEmpty(prevpage)) { let path = prevpage.route; this.setData({firstPagePath:path}) } console.log(options,prevpage,this.data.firstPagePath) if (!util.isObjEmpty(options)) { // 活动详情页进入 console.log('options',options) if (!util.isEmpty(options.aid)) { this.setData({aid:options.aid}) } // 小程序码进入 if (!util.isEmpty(options.scene)) { let that=this; util.codeGetAid(options.scene).then(res=>{ that.setData({aid:res.data}) }) } if (!util.isEmpty(options.orderId)) { this.jumpPage(options.orderId) }else{ setTimeout(() => { this.getOrderList(); }, 600); } } }, // 获取订单信息 getOrderList(){ let that =this; util.ajax({ func: "v2/order/list_by_aid", data: { "aid": that.data.aid } },function (res) { console.log(res) if (res.code==0) { that.setData({orderList:res.data,showData:true}) if (!util.isEmpty(res.data) && res.data.length==1 && util.isEmpty(that.data.firstPagePath)) { setTimeout(() => { that.jumpPage(res.data[0].orderid); }, 500); } console.log(that.data.orderList) }else{ util.showTips(res.reason); } }) }, // 跳转至订单信息详情 jumpPage(id){ wx.navigateTo({ url: '/pages/order/editOrderDetail/index?orderId='+id, }) }, // 跳转至首页 jumpToHome(){ wx.reLaunch({ url: '/pages/home/index', }) }, radioChange(e){ console.log(e) this.jumpPage(e.detail.value); }, onShareAppMessage: function () { } })