index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. const app = getApp()
  2. const httpUtils = require('../../utils/http.js')
  3. const ui = require('../../utils/ui.js')
  4. Page({
  5. data: {
  6. list: [],
  7. deviceid: '',
  8. roomName: '',
  9. deviceCode: ''
  10. },
  11. deviceid: '',
  12. roomName: '',
  13. deviceCode: '',
  14. balance: '',
  15. onLoad(options) {
  16. this.deviceid = options.deviceid
  17. this.roomName = options.roomName
  18. this.deviceCode = options.deviceCode
  19. this.balance = options.balance
  20. this.setData({
  21. deviceid: options.deviceid,
  22. roomName: options.roomName,
  23. deviceCode: options.deviceCode,
  24. balance: options.balance
  25. })
  26. this.getList(options.deviceid)
  27. },
  28. historyUrl(){
  29. console.log(this)
  30. wx.navigateTo({
  31. url: '/pages/record/index?deviceid=' + this.deviceid + '&roomName=' + this.roomName + '&deviceCode=' + this.deviceCode
  32. })
  33. },
  34. toRecharge(){
  35. wx.navigateTo({
  36. url: '/pages/recharge/index?deviceid=' + this.deviceid + '&roomName=' + this.roomName + '&deviceCode=' + this.deviceCode + '&balance=' + this.balance
  37. })
  38. },
  39. getList(id){
  40. let obj = {
  41. url: '/monthBill',
  42. data: {
  43. deviceId: id,
  44. token: wx.getStorageSync('token'),
  45. }
  46. }
  47. httpUtils.request(obj).then(res=>{
  48. console.log(res)
  49. this.setData({
  50. list: res.data.data
  51. })
  52. }).catch(err=>{
  53. console.log('ERROR')
  54. });
  55. }
  56. })