helpList.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // subpages/helpList/helpList.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. mCateList: []
  8. },
  9. /**
  10. * 生命周期函数--监听页面加载
  11. */
  12. onLoad(options) {
  13. this.getCateList();
  14. },
  15. onClickLeft() {
  16. wx.navigateBack();
  17. },
  18. /**
  19. * 生命周期函数--监听页面初次渲染完成
  20. */
  21. onReady() {
  22. },
  23. /**
  24. * 生命周期函数--监听页面显示
  25. */
  26. onShow() {
  27. },
  28. /**
  29. * 生命周期函数--监听页面隐藏
  30. */
  31. onHide() {
  32. },
  33. /**
  34. * 生命周期函数--监听页面卸载
  35. */
  36. onUnload() {
  37. },
  38. /**
  39. * 页面相关事件处理函数--监听用户下拉动作
  40. */
  41. onPullDownRefresh() {
  42. },
  43. /**
  44. * 页面上拉触底事件的处理函数
  45. */
  46. onReachBottom() {
  47. },
  48. /**
  49. * 用户点击右上角分享
  50. */
  51. onShareAppMessage() {
  52. },
  53. toDetails(e) {
  54. // "helpDetails/helpDetails"
  55. console.log(e.currentTarget.dataset.item);
  56. wx.navigateTo({
  57. url: `/subpages/helpDetails/helpDetails?id=` + e.currentTarget.dataset.item.arcid
  58. })
  59. },
  60. getCateList() {
  61. const that = this;
  62. wx.request({
  63. url: 'https://aipush.aidsleep.cn/allhelcatelist',
  64. method: 'POST',
  65. data: {
  66. tokens: "aa9ebf8360ec36bd0f6cc950b9e2f45e282ae1f93f5d3c56f2ffa6984cd22c66" || wx.getStorageSync('token'),
  67. udi: wx.getStorageSync('unionid')
  68. },
  69. success: async (res) => {
  70. console.log(res.data);
  71. // ""
  72. if (res.data) {
  73. var tempList = res.data || [];
  74. for (let i = 0; i < tempList.length; i++) {
  75. const element = tempList[i];
  76. element.icon = `https://aipush.aidsleep.cn/assets/helpics/${element.icon}`;
  77. that.getList(tempList, i, element.cid)
  78. }
  79. // [{"cid":11,"name":"房间控制","icon":"all_67362a14b131f.png","subList":"[]"}]
  80. // console.log("tempList=>", JSON.stringify(tempList));
  81. // console.log("tempList=>", tempList);
  82. setTimeout(() => {
  83. that.setData({
  84. mCateList: tempList
  85. })
  86. }, 250 * tempList.length);
  87. }
  88. },
  89. fail: () => {
  90. }
  91. });
  92. },
  93. getList(mList = [], index = 0, helcid) {
  94. const that = this;
  95. wx.request({
  96. url: 'https://aipush.aidsleep.cn/allhelarclist',
  97. method: 'POST',
  98. data: {
  99. tokens: "aa9ebf8360ec36bd0f6cc950b9e2f45e282ae1f93f5d3c56f2ffa6984cd22c66" || wx.getStorageSync('token'),
  100. udi: wx.getStorageSync('unionid'),
  101. helcid
  102. },
  103. success: (res) => {
  104. // console.log(res.data);
  105. mList[index]['subList'] = res.data || [];
  106. },
  107. fail: () => {
  108. }
  109. });
  110. },
  111. })