// pages/splash/splash.js var app = getApp(); var flag = 0; Page({ /** * 页面的初始数据 */ data: { info: null }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { let id = options.id?options.id:0; if(id > 0){ this.showData(id); } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { var that = this; app.ajaxReadyCallback = res => { var apiname = res.data.apiname; if (apiname == 'info'){ that.setData({ info: res.data.data }); console.log(res.data.data); }else if(apiname == 'deal'){ wx.showToast({ title: '操作成功', icon: 'none', duration: 2000 }) setTimeout(() =>{ that.showData(that.data.info.id); },1000); } } }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, showData:function(id){ if(flag == 1){ return false; } app.ajax({ url: app.globalData.serverUrl + 'visitorOrder/detail', type: 'POST', apiname: 'info', data: { id: id } }); }, handleAgree(e){ var that = this; var type = Number(e.currentTarget.dataset.type); let msg = ""; let s = 0; if(type == 1){ msg = '确定要同意此条申请吗?'; s = 1; }else{ msg = '确定要拒绝此条申请吗?'; s = 4; } wx.showModal({ title: '提示', content: msg, success (res) { if (res.confirm) { console.log('用户点击确定') if(flag == 1){ return false; } app.ajax({ url: app.globalData.serverUrl + 'visitorOrder/deal', type: 'POST', apiname: 'deal', data: { id: that.data.info.id, s: s } }); } else if (res.cancel) { console.log('用户点击取消') } } }) } })