You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.4 KiB

  1. const app = getApp()
  2. const config = require("../../config/config")
  3. const Http = require("../../utils/HttpBasics.js")
  4. const navigationBarHeight = (getApp().statusBarHeight + 44) + "px"
  5. Page({
  6. data: {
  7. imgHttps: app.globalData.imgHttps,
  8. navigationBarHeight,
  9. inputValue: '',
  10. pageNum: 1,
  11. list: [],
  12. showFlog:false,
  13. id:"",//选中id
  14. },
  15. setSearchValue(e) {
  16. let value = e.detail.value
  17. this.setData({
  18. inputValue: value
  19. })
  20. },
  21. searchBtn() {
  22. this.setData({
  23. list: [],
  24. pageNum: 1
  25. })
  26. this.search()
  27. },
  28. cancel(){
  29. Http.get({
  30. url:config.api.Fcollect,
  31. data:{
  32. id:this.data.id
  33. }
  34. }).then(res=>{{
  35. this.search()
  36. this.hie()
  37. tt.showToast({
  38. title: '已取消收藏', // 内容
  39. icon: "none"
  40. });
  41. }}).catch(err=>{
  42. tt.showToast({
  43. title: err.message, // 内容
  44. icon:"none"
  45. });
  46. })
  47. },
  48. hie(){
  49. this.setData({
  50. showFlog:false
  51. })
  52. },
  53. showHie(e){
  54. let id = e.currentTarget.dataset.id
  55. this.setData({
  56. showFlog:true,
  57. id:id
  58. })
  59. },
  60. search() {
  61. tt.showLoading({
  62. title: '加载中...', // 内容
  63. });
  64. Http.get({
  65. url: config.api.mainCollet,
  66. data: {
  67. title: this.data.inputValue,
  68. pageNum: this.data.pageNum,
  69. pageSize: 8
  70. }
  71. }).then(res => {
  72. console.log(res);
  73. let temp = this.data.list
  74. if (this.data.pageNum > 1) {
  75. temp.push(res.data.list)
  76. this.setData({
  77. list: temp
  78. })
  79. } else {
  80. this.setData({
  81. list: res.data.list
  82. })
  83. }
  84. tt.hideLoading();
  85. }).catch(err=>{
  86. tt.hideLoading();
  87. tt.showToast({
  88. title: err.message?err.message:err.data, // 内容
  89. icon:"none"
  90. });
  91. })
  92. },
  93. onLoad() {
  94. this.search()
  95. },
  96. onReachBottom: function() {
  97. this.setData({
  98. pageNum:this.data.pageNum+1
  99. })
  100. this.search()
  101. }
  102. })