index.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. },
  8. onShow(){
  9. if(wx.getStorageSync('token')){
  10. this.getList()
  11. }else{
  12. wx.switchTab({
  13. url: '/pages/index/index',
  14. })
  15. }
  16. },
  17. toUrl(e){
  18. console.log(e)
  19. let deviceid = e.currentTarget.dataset.deviceid
  20. let roomName = e.currentTarget.dataset.roomname
  21. let deviceCode = e.currentTarget.dataset.devicecode
  22. let balance = e.currentTarget.dataset.balance
  23. wx.navigateTo({
  24. url: '/pages/bill/index?deviceid=' + deviceid + '&roomName=' + roomName + '&deviceCode=' + deviceCode + '&balance=' + balance
  25. })
  26. },
  27. getList(){
  28. let obj = {
  29. url: '/roomList',
  30. data: {
  31. phone: wx.getStorageSync('phone'),
  32. token: wx.getStorageSync('token'),
  33. }
  34. }
  35. httpUtils.request(obj).then(res=>{
  36. console.log(res)
  37. this.setData({
  38. list: res.data.data
  39. })
  40. }).catch(err=>{
  41. console.log('ERROR')
  42. });
  43. }
  44. })