category.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. Page({
  2. data: {
  3. category: [
  4. {name:'果味',id:'guowei'},
  5. {name:'蔬菜',id:'shucai'},
  6. {name:'炒货',id:'chaohuo'},
  7. {name:'点心',id:'dianxin'},
  8. {name:'粗茶',id:'cucha'},
  9. {name:'淡饭',id:'danfan'}
  10. ],
  11. detail:[],
  12. curIndex: 0,
  13. isScroll: false,
  14. toView: 'guowei'
  15. },
  16. onReady(){
  17. var self = this;
  18. wx.request({
  19. url:'http://www.gdfengshuo.com/api/wx/cate-detail.txt',
  20. success(res){
  21. self.setData({
  22. detail : res.data
  23. })
  24. }
  25. });
  26. },
  27. switchTab(e){
  28. const self = this;
  29. this.setData({
  30. isScroll: true
  31. })
  32. setTimeout(function(){
  33. self.setData({
  34. toView: e.target.dataset.id,
  35. curIndex: e.target.dataset.index
  36. })
  37. },0)
  38. setTimeout(function () {
  39. self.setData({
  40. isScroll: false
  41. })
  42. },1)
  43. }
  44. })