detail.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. const util = require('../../utils/util.js');
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. deviceId:'',
  9. deviceInfo:{
  10. deviceDetail:{
  11. // gridNum:'',
  12. // productGrid:'',
  13. mgVmDevice:{},
  14. stockGrid:''
  15. },
  16. gridList:[]
  17. },
  18. productId:'',
  19. isStock:''
  20. },
  21. /**
  22. * 生命周期函数--监听页面加载
  23. */
  24. onLoad: function (options) {
  25. this.setData({
  26. deviceId: options.deviceId
  27. })
  28. this.bindDevice()
  29. },
  30. /**
  31. * 生命周期函数--监听页面初次渲染完成
  32. */
  33. onReady: function () {
  34. },
  35. /**
  36. * 生命周期函数--监听页面显示
  37. */
  38. onShow: function () {
  39. },
  40. /**
  41. * 生命周期函数--监听页面隐藏
  42. */
  43. onHide: function () {
  44. },
  45. /**
  46. * 生命周期函数--监听页面卸载
  47. */
  48. onUnload: function () {
  49. },
  50. /**
  51. * 页面相关事件处理函数--监听用户下拉动作
  52. */
  53. onPullDownRefresh: function () {
  54. },
  55. /**
  56. * 页面上拉触底事件的处理函数
  57. */
  58. onReachBottom: function () {
  59. },
  60. /**
  61. * 用户点击右上角分享
  62. */
  63. onShareAppMessage: function () {
  64. },
  65. bindDevice(){
  66. var that = this
  67. util.request(util.api.queryByDeviceId, {id:that.data.deviceId}, "GET", true, true,app.globalData.token).then((res)=>{
  68. if (res.code == 200) {
  69. console.log( res.result)
  70. that.setData({
  71. deviceInfo: res.result,
  72. })
  73. }
  74. }).catch((res) => {})
  75. },
  76. updateIsStock(e){
  77. var that = this
  78. that.data.productId = e.currentTarget.dataset.id
  79. that.data.isStock = e.currentTarget.dataset.as
  80. util.request(util.api.editMgVmDeviceGridProduct, {deviceId:that.data.deviceId, gridId:e.currentTarget.dataset.id, isStock:that.data.isStock}, "POST", true, true,app.globalData.token).then((res)=>{
  81. if (res.code == 200) {
  82. that.bindDevice()
  83. }
  84. }).catch((res) => {})
  85. }
  86. })