index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. let app = getApp();
  2. const getReq = require('./../../config.js').getReq;
  3. Page({
  4. data: {
  5. tabs: [],
  6. special_datas: {},
  7. summery: []
  8. },
  9. onShow: function() {
  10. if (app.globalData.backLogin) {
  11. app.globalData.backLogin = false;
  12. wx.reLaunch({
  13. url: "/pages/index/index"
  14. });
  15. }
  16. },
  17. onLoad: function () {
  18. this.req_tabs();
  19. },
  20. req_tabs(){
  21. let self = this
  22. getReq({
  23. act: 'index',
  24. op: 'tabs'
  25. }, function (res) {
  26. if (res.code == 200) {
  27. self.getDatas(res.datas.tabs[0].special_id);
  28. self.setData({
  29. tabs: res.datas.tabs
  30. });
  31. }
  32. })
  33. },
  34. onMyEvent: function (e) {
  35. this.setData({
  36. special_datas: {},
  37. summery: []
  38. });
  39. this.getDatas(e.detail.item.special_id)
  40. },
  41. getDatas(special_id) {
  42. wx.showLoading({
  43. title: '加载中'
  44. });
  45. let self = this;
  46. getReq({
  47. act: 'special',
  48. op: 'index',
  49. special_id,
  50. page: 10,
  51. curpage: 1
  52. }, function (res) {
  53. console.log(res);
  54. if (res.code == 200) {
  55. self.setData({
  56. special_datas: res.datas,
  57. summery: res.datas.summary
  58. });
  59. }
  60. setTimeout(function () {
  61. wx.hideLoading()
  62. }, 1000)
  63. })
  64. }
  65. })