childsCard.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. Component({
  2. properties: {
  3. list:{
  4. type:Object,
  5. observer:function(list){
  6. this.setData({ list });
  7. }
  8. },
  9. share:{
  10. type:Boolean,
  11. observer: function (share){
  12. this.setData({ share });
  13. }
  14. },
  15. showMedal:{
  16. type:Boolean,
  17. observer:function(newVal){
  18. console.log(newVal)
  19. this.setData({ showMedal:newVal });
  20. }
  21. },
  22. },
  23. data: {
  24. list:[],
  25. showMedal:false,
  26. share:false,
  27. scrollLeft:0,
  28. current:0,
  29. cardWidth:wx.getSystemInfoSync().windowWidth,
  30. disable:true,
  31. left:0,
  32. current:0
  33. },
  34. methods: {
  35. bindchange(e){
  36. let current = e.detail.current;
  37. this.setData({current})
  38. this.triggerEvent('getChildIndex', current );
  39. },
  40. rightScroll(){
  41. if (this.data.list.length>1) {
  42. this.setData({current:this.data.current>=this.data.list.length-1?0:this.data.current+1})
  43. }
  44. },
  45. leftScroll(){
  46. if (this.data.list.length>1) {
  47. this.setData({current:this.data.current<=0?this.data.list.length-1:this.data.current-1})
  48. }
  49. }
  50. }
  51. })