admin.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. // pages/admin/admin.js
  2. const app = getApp()
  3. const link = app.globalData.url
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. page:1,
  10. pageSize:10,
  11. openId:"",
  12. userStatus:0,
  13. goodsList:[],
  14. count:0
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. //获取金额
  21. var that = this
  22. that.page = 1
  23. that.pageSize = 10
  24. that.openId = wx.getStorageSync('openId')
  25. that.userStatus = 3
  26. wx.request( {
  27. url: link + "/v1/forward/lhf",
  28. header: {
  29. "Content-Type": "application/json",
  30. "function":"/v1/admin/data"
  31. },
  32. method: "POST",
  33. data: { openId: "" },
  34. success (res) {
  35. console.log(res)
  36. that.setData({
  37. wallet: res.data.data,
  38. order:true,
  39. trans:false,
  40. adminTrans:false
  41. })
  42. }
  43. })
  44. wx.request( {
  45. url: link + "/v1/forward/lhf",
  46. header: {
  47. "Content-Type": "application/json",
  48. "function":"/v1/user/order/list"
  49. },
  50. method: "POST",
  51. data: { openId: "o0PAf400H9fbwDN6-a8ndU4di0JI",pageIndex:that.page,pageSize: that.pageSize,userStatus:that.userStatus},
  52. complete: function( res ) {
  53. console.log(res)
  54. if( res == null || res.data == null ) {
  55. console.error( '网络请求失败' );
  56. return;
  57. }
  58. console.log(res.data.data.rows)
  59. //that.count = res.data.data.count
  60. if (res.data.data.rows.orderInfo == null){
  61. that.count = res.data.data.count
  62. that.setData({
  63. goodsList: res.data.data.rows.orderInfo,
  64. lType:"end"
  65. })
  66. } else{
  67. that.count = res.data.data.count
  68. that.data.goodsList = res.data.data.rows.orderInfo
  69. that.setData({
  70. goodsList: that.data.goodsList,
  71. lType:"false"
  72. })
  73. }
  74. }
  75. })
  76. var opneId = wx.getStorageSync('openId')
  77. wx.request( {
  78. url: link + "/v1/forward/lhf",
  79. header: {
  80. "Content-Type": "application/json",
  81. "function":"/v1/user/open.id/get"
  82. },
  83. method: "POST",
  84. data: { openId: opneId },
  85. success (res) {
  86. console.log(res)
  87. wx.setStorageSync('nickName', res.data.data.user.nickName)
  88. wx.setStorageSync('userId', res.data.data.user.id)
  89. if (res.data.data.user.admin == 2){
  90. that.setData({
  91. admin:true
  92. })
  93. }
  94. }
  95. })
  96. },
  97. copy:function (options) {
  98. console.log(options)
  99. wx.setClipboardData({
  100. data: options.currentTarget.dataset.pay,
  101. success (res) {
  102. //点击确定
  103. wx.showToast({
  104. title: '复制成功',//提示文字
  105. duration:2000,//显示时长
  106. mask:true,//是否显示透明蒙层,防止触摸穿透,默认:false
  107. icon:'success', //图标,支持"success"、"loading"
  108. success:function(){ },//接口调用成功
  109. fail: function () { }, //接口调用失败的回调函数
  110. complete: function () { } //接口调用结束的回调函数
  111. })
  112. }
  113. })
  114. },
  115. statusFail:function (options) {
  116. console.log(options)
  117. var that = this
  118. var item = options.target.dataset.item
  119. wx.showModal({
  120. title: '拒绝提现',
  121. content: '金额等数据异常,拒绝发放提现',
  122. showCancel: true,//是否显示取消按钮
  123. cancelText:"取消",//默认是“取消”
  124. confirmText:"确定",//默认是“确定”
  125. success: function (res) {
  126. if (res.cancel) {
  127. //点击取消,默认隐藏弹框
  128. } else {
  129. wx.request( {
  130. url: link + "/v1/forward/lhf",
  131. header: {
  132. "Content-Type": "application/json",
  133. "function":"/v1/user/trans/update"
  134. },
  135. method: "POST",
  136. 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 },
  137. success (res) {
  138. console.log(res)
  139. wx.request( {
  140. url: link + "/v1/forward/lhf",
  141. header: {
  142. "Content-Type": "application/json",
  143. "function":"/v1/user/trans/list"
  144. },
  145. method: "POST",
  146. data: { pageIndex:1,pageSize:999 },
  147. complete: function( res ) {
  148. console.log(res)
  149. if( res == null || res.data == null ) {
  150. console.error( '网络请求失败' );
  151. return;
  152. }
  153. that.setData({
  154. transList: res.data.data.rows,
  155. order:false,
  156. trans:true,
  157. adminTrans:false
  158. })
  159. }
  160. })
  161. }
  162. })
  163. }
  164. },
  165. fail: function (res) { },//接口调用失败的回调函数
  166. complete: function (res) { },//接口调用结束的回调函数(调用成功、失败都会执行)
  167. })
  168. },
  169. statusSuccess:function (options) {
  170. console.log(options)
  171. var that = this
  172. var item = options.target.dataset.item
  173. wx.showModal({
  174. title: '提现已发放',
  175. content: '金额已发放',
  176. showCancel: true,//是否显示取消按钮
  177. cancelText:"取消",//默认是“取消”
  178. confirmText:"确定",//默认是“确定”
  179. success: function (res) {
  180. if (res.cancel) {
  181. //点击取消,默认隐藏弹框
  182. } else {
  183. wx.request( {
  184. url: link + "/v1/forward/lhf",
  185. header: {
  186. "Content-Type": "application/json",
  187. "function":"/v1/user/trans/update"
  188. },
  189. method: "POST",
  190. 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 },
  191. success (res) {
  192. console.log(res)
  193. wx.request( {
  194. url: link + "/v1/forward/lhf",
  195. header: {
  196. "Content-Type": "application/json",
  197. "function":"/v1/user/trans/list"
  198. },
  199. method: "POST",
  200. data: { pageIndex:1,pageSize:999 },
  201. complete: function( res ) {
  202. console.log(res)
  203. if( res == null || res.data == null ) {
  204. console.error( '网络请求失败' );
  205. return;
  206. }
  207. that.setData({
  208. transList: res.data.data.rows,
  209. order:false,
  210. trans:true,
  211. adminTrans:false
  212. })
  213. }
  214. })
  215. }
  216. })
  217. }
  218. },
  219. fail: function (res) { },//接口调用失败的回调函数
  220. complete: function (res) { },//接口调用结束的回调函数(调用成功、失败都会执行)
  221. })
  222. },
  223. changeTabs:function(options){
  224. console.log(options)
  225. var that = this
  226. if (options.detail.activeKey == "one"){
  227. //查询数据
  228. that.setData({
  229. order:true,
  230. trans:false,
  231. adminTrans:false
  232. })
  233. } else if (options.detail.activeKey == "two"){
  234. //查询提现数据
  235. wx.request( {
  236. url: link + "/v1/forward/lhf",
  237. header: {
  238. "Content-Type": "application/json",
  239. "function":"/v1/user/trans/list"
  240. },
  241. method: "POST",
  242. data: { pageIndex:1,pageSize:999 },
  243. complete: function( res ) {
  244. console.log(res)
  245. if( res == null || res.data == null ) {
  246. console.error( '网络请求失败' );
  247. return;
  248. }
  249. that.setData({
  250. transList: res.data.data.rows,
  251. order:false,
  252. trans:true,
  253. adminTrans:false
  254. })
  255. }
  256. })
  257. } else if (options.detail.activeKey == "three"){
  258. wx.request( {
  259. url: link + "/v1/forward/lhf",
  260. header: {
  261. "Content-Type": "application/json",
  262. "function":"/v1/admin/amount/list"
  263. },
  264. method: "POST",
  265. data: { pageIndex:1,pageSize:999 },
  266. complete: function( res ) {
  267. console.log(res)
  268. if( res == null || res.data == null ) {
  269. console.error( '网络请求失败' );
  270. return;
  271. }
  272. that.setData({
  273. adminTransList: res.data.data.rows,
  274. order:false,
  275. trans:false,
  276. adminTrans:true
  277. })
  278. }
  279. })
  280. }
  281. },
  282. adminAmount:function (options) {
  283. var that = this
  284. wx.request( {
  285. url: link + "/v1/forward/lhf",
  286. header: {
  287. "Content-Type": "application/json",
  288. "function":"/v1/admin/amount"
  289. },
  290. method: "POST",
  291. data: { },
  292. success (res) {
  293. console.log(res)
  294. wx.request( {
  295. url: link + "/v1/forward/lhf",
  296. header: {
  297. "Content-Type": "application/json",
  298. "function":"/v1/admin/data"
  299. },
  300. method: "POST",
  301. data: { openId: "" },
  302. success (res) {
  303. console.log(res)
  304. that.setData({
  305. wallet: res.data.data,
  306. })
  307. }
  308. })
  309. }
  310. })
  311. },
  312. trans:function(){
  313. console.log('trans')
  314. },
  315. /**
  316. * 生命周期函数--监听页面初次渲染完成
  317. */
  318. onReady: function () {
  319. },
  320. /**
  321. * 生命周期函数--监听页面显示
  322. */
  323. onShow: function () {
  324. },
  325. /**
  326. * 生命周期函数--监听页面隐藏
  327. */
  328. onHide: function () {
  329. },
  330. /**
  331. * 生命周期函数--监听页面卸载
  332. */
  333. onUnload: function () {
  334. },
  335. /**
  336. * 页面相关事件处理函数--监听用户下拉动作
  337. */
  338. onPullDownRefresh: function () {
  339. },
  340. /**
  341. * 页面上拉触底事件的处理函数
  342. */
  343. onReachBottom: function () {
  344. //获取数据
  345. var that = this;
  346. if (that.page * that.pageSize >= that.count ){
  347. //提示页码到了
  348. that.setData({
  349. lType:"end"
  350. })
  351. return
  352. }
  353. that.page +=1
  354. wx.request( {
  355. url: link + "/v1/forward/lhf",
  356. header: {
  357. "Content-Type": "application/json",
  358. "function":"/v1/user/order/list"
  359. },
  360. method: "POST",
  361. data: { openId: "o0PAf400H9fbwDN6-a8ndU4di0JI",pageIndex:that.page,pageSize: that.pageSize,userStatus:that.userStatus},
  362. complete: function( res ) {
  363. wx.hideLoading();
  364. console.log(res)
  365. for (var i = 0; i < res.data.data.rows.orderInfo.length; i++) {
  366. that.data.goodsList.push( res.data.data.rows.orderInfo[i]);
  367. }
  368. that.setData({
  369. goodsList: that.data.goodsList,
  370. })
  371. console.log(res.data.data.goods_search_response)
  372. if( res == null || res.data == null ) {
  373. console.error( '网络请求失败' );
  374. return;
  375. }
  376. }
  377. })
  378. },
  379. /**
  380. * 用户点击右上角分享
  381. */
  382. onShareAppMessage: function () {
  383. }
  384. })