You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
2.5 KiB

1 year ago
1 year ago
  1. // index.js
  2. const WXAPI = require('../../utils/request')
  3. // 获取应用实例
  4. const app = getApp()
  5. Page({
  6. data: {
  7. show: false,
  8. signKey: '',
  9. commonKey: '',
  10. list: [],
  11. searchValue: '',
  12. userInfo: {},
  13. pageNum: 1,
  14. pageSize: 20,
  15. stoppull: false,
  16. zNodes: [],
  17. index: 0,
  18. array: [],
  19. index1: 0,
  20. array1: [],
  21. ces: 0,
  22. ces1: '',
  23. ces2: '',
  24. dataList: [],
  25. selectKey: '', //选中的节点id
  26. selectRoomName: '选择房间',
  27. pid:'',
  28. treeList:[]
  29. },
  30. onLoad() {
  31. wx.getStorage({
  32. key: "deviceinfoList",
  33. success: (res) => {
  34. console.log(res);
  35. this.setData({
  36. list:res.data,
  37. deviceList:res.data
  38. })
  39. },
  40. fail: (res) => {
  41. wx.redirectTo({
  42. url: "/pages/login/login"
  43. })
  44. }
  45. })
  46. },
  47. onChange(event) {
  48. this.setData({
  49. searchValue: event.detail
  50. })
  51. },
  52. changePassword(){
  53. wx.navigateTo({
  54. url: '/pages/updateWord/updateWord?role=2',
  55. })
  56. },
  57. // 退出登录
  58. loginOut(){
  59. console.log(1111)
  60. wx.showModal({
  61. cancelColor: '退出',
  62. title:"是否退出",
  63. success:function(res){
  64. console.log(res)
  65. wx.removeStorage({
  66. key:"signature"
  67. })
  68. wx.redirectTo({
  69. url:"/pages/login/login"
  70. })
  71. }
  72. })
  73. },
  74. godetail(e) {
  75. var IMEI = e.currentTarget.dataset.item
  76. if (IMEI.imei) {
  77. wx.setStorage({
  78. key: "deviceinfo",
  79. data: IMEI
  80. })
  81. wx.navigateTo({
  82. url: "/pages/userbluetoothUnlock/userbluetoothUnlock"
  83. })
  84. } else {
  85. wx.showToast({
  86. title: "还未绑定门锁",
  87. duration: 2000,
  88. icon: 'none'
  89. })
  90. }
  91. // } else if (this.data.userInfo.type == 3) {
  92. // wx.setStorage({
  93. // key: "deviceinfo",
  94. // data: this.data.list[0]
  95. // })
  96. // wx.navigateTo({
  97. // url: "/pages/roomDetail/roomDetail"
  98. // })
  99. // }
  100. },
  101. // 搜索
  102. onClick(e) {
  103. var arr=[]
  104. console.log(1111)
  105. if(this.data.searchValue==""){
  106. this.setData({
  107. list:this.data.deviceList
  108. })
  109. }else{
  110. this.data.deviceList.map(li=>{
  111. var result=li.roomName.indexOf(this.data.searchValue)
  112. if(result){
  113. arr.push(li)
  114. }else{
  115. arr=[]
  116. }
  117. })
  118. console.log(arr)
  119. this.setData({
  120. list:arr
  121. })
  122. }
  123. },
  124. onShow: function () {
  125. },
  126. getUserProfile(e) {},
  127. onShareAppMessage() {}
  128. })