// pages/admin/admin.js const app = getApp() const link = app.globalData.url Page({ /** * 页面的初始数据 */ data: { page:1, pageSize:10, openId:"", userStatus:0, goodsList:[], count:0 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { //获取金额 var that = this that.page = 1 that.pageSize = 10 that.openId = wx.getStorageSync('openId') that.userStatus = 3 wx.request( { url: link + "/v1/forward/lhf", header: { "Content-Type": "application/json", "function":"/v1/admin/data" }, method: "POST", data: { openId: "" }, success (res) { console.log(res) that.setData({ wallet: res.data.data, order:true, trans:false, adminTrans:false }) } }) wx.request( { url: link + "/v1/forward/lhf", header: { "Content-Type": "application/json", "function":"/v1/user/order/list" }, method: "POST", data: { openId: "o0PAf400H9fbwDN6-a8ndU4di0JI",pageIndex:that.page,pageSize: that.pageSize,userStatus:that.userStatus}, complete: function( res ) { console.log(res) if( res == null || res.data == null ) { console.error( '网络请求失败' ); return; } console.log(res.data.data.rows) //that.count = res.data.data.count if (res.data.data.rows.orderInfo == null){ that.count = res.data.data.count that.setData({ goodsList: res.data.data.rows.orderInfo, lType:"end" }) } else{ that.count = res.data.data.count that.data.goodsList = res.data.data.rows.orderInfo that.setData({ goodsList: that.data.goodsList, lType:"false" }) } } }) var opneId = wx.getStorageSync('openId') wx.request( { url: link + "/v1/forward/lhf", header: { "Content-Type": "application/json", "function":"/v1/user/open.id/get" }, method: "POST", data: { openId: opneId }, success (res) { console.log(res) wx.setStorageSync('nickName', res.data.data.user.nickName) wx.setStorageSync('userId', res.data.data.user.id) if (res.data.data.user.admin == 2){ that.setData({ admin:true }) } } }) }, copy:function (options) { console.log(options) wx.setClipboardData({ data: options.currentTarget.dataset.pay, success (res) { //点击确定 wx.showToast({ title: '复制成功',//提示文字 duration:2000,//显示时长 mask:true,//是否显示透明蒙层,防止触摸穿透,默认:false icon:'success', //图标,支持"success"、"loading" success:function(){ },//接口调用成功 fail: function () { }, //接口调用失败的回调函数 complete: function () { } //接口调用结束的回调函数 }) } }) }, statusFail:function (options) { console.log(options) var that = this var item = options.target.dataset.item wx.showModal({ title: '拒绝提现', content: '金额等数据异常,拒绝发放提现', showCancel: true,//是否显示取消按钮 cancelText:"取消",//默认是“取消” confirmText:"确定",//默认是“确定” success: function (res) { if (res.cancel) { //点击取消,默认隐藏弹框 } else { wx.request( { url: link + "/v1/forward/lhf", header: { "Content-Type": "application/json", "function":"/v1/user/trans/update" }, method: "POST", data: { pidStatus: item.pid_status,pay:item.pay,userId:item.userId,payName:item.payName,pid:item.pid,openId:item.openId,transStatus:2,id:item.id }, success (res) { console.log(res) wx.request( { url: link + "/v1/forward/lhf", header: { "Content-Type": "application/json", "function":"/v1/user/trans/list" }, method: "POST", data: { pageIndex:1,pageSize:999 }, complete: function( res ) { console.log(res) if( res == null || res.data == null ) { console.error( '网络请求失败' ); return; } that.setData({ transList: res.data.data.rows, order:false, trans:true, adminTrans:false }) } }) } }) } }, fail: function (res) { },//接口调用失败的回调函数 complete: function (res) { },//接口调用结束的回调函数(调用成功、失败都会执行) }) }, statusSuccess:function (options) { console.log(options) var that = this var item = options.target.dataset.item wx.showModal({ title: '提现已发放', content: '金额已发放', showCancel: true,//是否显示取消按钮 cancelText:"取消",//默认是“取消” confirmText:"确定",//默认是“确定” success: function (res) { if (res.cancel) { //点击取消,默认隐藏弹框 } else { wx.request( { url: link + "/v1/forward/lhf", header: { "Content-Type": "application/json", "function":"/v1/user/trans/update" }, method: "POST", data: { pidStatus: item.pid_status,pay:item.pay,userId:item.userId,payName:item.payName,pid:item.pid,openId:item.openId,transStatus:3,id:item.id }, success (res) { console.log(res) wx.request( { url: link + "/v1/forward/lhf", header: { "Content-Type": "application/json", "function":"/v1/user/trans/list" }, method: "POST", data: { pageIndex:1,pageSize:999 }, complete: function( res ) { console.log(res) if( res == null || res.data == null ) { console.error( '网络请求失败' ); return; } that.setData({ transList: res.data.data.rows, order:false, trans:true, adminTrans:false }) } }) } }) } }, fail: function (res) { },//接口调用失败的回调函数 complete: function (res) { },//接口调用结束的回调函数(调用成功、失败都会执行) }) }, changeTabs:function(options){ console.log(options) var that = this if (options.detail.activeKey == "one"){ //查询数据 that.setData({ order:true, trans:false, adminTrans:false }) } else if (options.detail.activeKey == "two"){ //查询提现数据 wx.request( { url: link + "/v1/forward/lhf", header: { "Content-Type": "application/json", "function":"/v1/user/trans/list" }, method: "POST", data: { pageIndex:1,pageSize:999 }, complete: function( res ) { console.log(res) if( res == null || res.data == null ) { console.error( '网络请求失败' ); return; } that.setData({ transList: res.data.data.rows, order:false, trans:true, adminTrans:false }) } }) } else if (options.detail.activeKey == "three"){ wx.request( { url: link + "/v1/forward/lhf", header: { "Content-Type": "application/json", "function":"/v1/admin/amount/list" }, method: "POST", data: { pageIndex:1,pageSize:999 }, complete: function( res ) { console.log(res) if( res == null || res.data == null ) { console.error( '网络请求失败' ); return; } that.setData({ adminTransList: res.data.data.rows, order:false, trans:false, adminTrans:true }) } }) } }, adminAmount:function (options) { var that = this wx.request( { url: link + "/v1/forward/lhf", header: { "Content-Type": "application/json", "function":"/v1/admin/amount" }, method: "POST", data: { }, success (res) { console.log(res) wx.request( { url: link + "/v1/forward/lhf", header: { "Content-Type": "application/json", "function":"/v1/admin/data" }, method: "POST", data: { openId: "" }, success (res) { console.log(res) that.setData({ wallet: res.data.data, }) } }) } }) }, trans:function(){ console.log('trans') }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { //获取数据 var that = this; if (that.page * that.pageSize >= that.count ){ //提示页码到了 that.setData({ lType:"end" }) return } that.page +=1 wx.request( { url: link + "/v1/forward/lhf", header: { "Content-Type": "application/json", "function":"/v1/user/order/list" }, method: "POST", data: { openId: "o0PAf400H9fbwDN6-a8ndU4di0JI",pageIndex:that.page,pageSize: that.pageSize,userStatus:that.userStatus}, complete: function( res ) { wx.hideLoading(); console.log(res) for (var i = 0; i < res.data.data.rows.orderInfo.length; i++) { that.data.goodsList.push( res.data.data.rows.orderInfo[i]); } that.setData({ goodsList: that.data.goodsList, }) console.log(res.data.data.goods_search_response) if( res == null || res.data == null ) { console.error( '网络请求失败' ); return; } } }) }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })