index.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // components/spacecard/spacecard.js
  2. import utils from "../../utils/util";
  3. import icons from "../../utils/icon"
  4. const app = getApp();
  5. Component({
  6. /**
  7. * 组件的属性列表
  8. */
  9. properties: {
  10. isCheckbox:{
  11. type:Boolean,
  12. value:false
  13. },
  14. cardDate:{
  15. type:Object,
  16. value:{}
  17. },
  18. canvashidden:{
  19. type:Boolean,
  20. value:true
  21. }
  22. },
  23. /**
  24. * 组件的初始数据
  25. */
  26. data: {
  27. imgbaseUrl:app.globalData.imgbaseUrl,
  28. picInitUrl:app.globalData.picInitUrl,
  29. unit:"°C",
  30. imgShow:false,
  31. statusList: icons.cardstatusList,
  32. },
  33. attached: function(){
  34. if(!this.data.cardDate.picInit){
  35. let list = JSON.parse(JSON.stringify(this.data.cardDate));
  36. list.picInit=utils.picInit(list.roomFuncType);
  37. this.setData({cardDate:list})
  38. }
  39. },
  40. observers: {
  41. // 'cardDate.roomFuncType': function(rate) {
  42. // // 在 rate被设置时,执行这个函数
  43. // let list = JSON.parse(JSON.stringify(this.data.cardDate));
  44. // list.picInit=utils.picInit(list.roomFuncType);
  45. // this.setData({cardDate:list})
  46. // }
  47. },
  48. ready:function(){
  49. },
  50. /**
  51. * 组件的方法列表
  52. */
  53. methods: {
  54. changeStar(e){
  55. console.log(e);
  56. let checked=!e.currentTarget.dataset.checked;
  57. this.setData({"cardDate.subscribe":checked});
  58. this.triggerEvent("starClick",{checked:checked,spaceId:this.data.cardDate.id});
  59. },
  60. goHome(){
  61. let cardDate=this.data.cardDate;
  62. this.triggerEvent('listClick', {cardDate});
  63. },
  64. imageLoad(ev){
  65. this.setData({imgShow:true});
  66. let src = ev.currentTarget.dataset.src,
  67. width = ev.detail.width,
  68. height = ev.detail.height;
  69. }
  70. }
  71. })