Page({ data: { date: '', items: [], itemsId: [1, 2], yuIndex: 0, arr: [], list: [], fenhao: false, number: '', nos: [], fanqian:false, money:'', userId:'', order_id:'' }, bindDateChange: function (e) { console.log(e) this.setData({ date: e.detail.value }) this.methods(this.data.date, this.data.itemsId) }, getNowFormatDate: function () { var date = new Date(); var seperator1 = "-"; var year = date.getFullYear(); var month = date.getMonth() + 1; var strDate = date.getDate(); if (month >= 1 && month <= 9) { month = "0" + month; } if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; } var currentdate = year + seperator1 + month + seperator1 + strDate; console.log(currentdate) this.setData({ date: currentdate }) return currentdate; }, onLoad: function (options) { this.getNowFormatDate() var items = wx.getStorageSync('items'); var arr = [{ 'id': "", name: '全部' }]; for (var i = 0; i < items.length; i++) { var obj = {} obj.name = items[i].name; obj.id = items[i].id; console.log(obj) arr = arr.concat(obj) } this.setData({ items: arr }); this.methods(this.data.date, this.data.itemsId) }, dayin:function(e){ var data={ order_id:e.currentTarget.dataset.id } wx.request({ url: 'https://yutang.web.ximengnaikang.com/api/admin/printNo', method: 'POST', header: { 'content-type': 'application/x-www-form-urlencoded', 'Authorization': wx.getStorageSync('token') }, data:data, success: function (res) { console.log(res) } }) }, yutang: function (e) { console.log(e) var index = e.currentTarget.dataset.index this.setData({ yuIndex: index }) if (index == 0) { this.setData({ itemsId: [1, 2] }) } else if (index == 1) { this.setData({ itemsId: [this.data.items[index].id] }) } else if (index == 2) { this.setData({ itemsId: [this.data.items[index].id] }) } this.methods(this.data.date, this.data.itemsId) }, methods: function (time, arr) { var that = this; wx.request({ url: 'https://yutang.web.ximengnaikang.com/api/admin/byDateUsers?date=' + time + '&sate=' + arr, method: 'GET', header: { 'content-type': 'application/x-www-form-urlencoded', 'Authorization': wx.getStorageSync('token') }, success: function (res) { console.log(res) that.setData({ list: res.data.data }) } }) }, input: function (e) { var value = e.detail.value; var arr = value.split("-"); this.setData({ nos: arr }) }, quxiao: function () { this.setData({ fenhao: false, number: '', fanqian:false }) }, money:function(e){ this.setData({money:e.detail.value}) }, fanqian:function(e){ this.setData({fanqian:true,userId:e.currentTarget.dataset.user_id}) }, return_money:function(){ var data = { 'user_id': this.data.userId, 'money': this.data.money } console.log(this.data.data) wx.request({ url: 'https://yutang.web.ximengnaikang.com/api/admin/refundUserMoney', method: 'POST', header: { 'content-type': 'application/x-www-form-urlencoded', 'Authorization': wx.getStorageSync('token') }, data: data, success: function (res) { console.log(res) // that.setData({list:res.data.data}) if(res.data.code==200){ wx.showToast({ title: '操作成功~', icon:'none' }) }else{ wx.showToast({ title: res.data.message, icon:'none' }) } that.setData({fanqian:false}) } }) }, queding: function () { var that = this; var data = { 'order_id': this.data.order_id, 'nos': this.data.nos } console.log(this.data.nos) wx.request({ url: 'https://yutang.web.ximengnaikang.com/api/admin/makeUserNo', method: 'POST', header: { 'content-type': 'application/x-www-form-urlencoded', 'Authorization': wx.getStorageSync('token') }, data: data, success: function (res) { console.log(res) // that.setData({list:res.data.data}) if(res.data.code==200){ wx.showToast({ title: '分号成功', icon:'none' }) that.methods(that.data.date, that.data.itemsId) }else{ wx.showToast({ title: '请求失败请重试', icon:'none' }) } that.setData({ fenhao: false }) } }) }, fenhao: function (e) { console.log(e) this.setData({ fenhao: true, number: e.currentTarget.dataset.number, order_id:e.currentTarget.dataset.id }) }, onReady: function () { }, onShow: function () { }, onHide: function () { }, onUnload: function () { }, onPullDownRefresh: function () { }, onReachBottom: function () { console.log('没有更多了~') }, onShareAppMessage: function () { } })