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.

91 line
2.1 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. tt.showToast({
  36. title: '已取消收藏', // 内容
  37. icon: "none"
  38. });
  39. }}).catch(err=>{
  40. tt.showToast({
  41. title: err.message, // 内容
  42. icon:"none"
  43. });
  44. })
  45. },
  46. hie(){
  47. this.setData({
  48. showFlog:false
  49. })
  50. },
  51. showHie(e){
  52. let id = e.currentTarget.dataset.id
  53. this.setData({
  54. showFlog:true,
  55. id:id
  56. })
  57. },
  58. search() {
  59. Http.get({
  60. url: config.api.mainCollet,
  61. data: {
  62. title: this.data.inputValue,
  63. pageNum: this.data.pageNum,
  64. pageSize: 8
  65. }
  66. }).then(res => {
  67. console.log(res);
  68. let temp = this.data.list
  69. if (this.data.pageNum > 1) {
  70. temp.push(res.data.list)
  71. this.setData({
  72. list: temp
  73. })
  74. } else {
  75. this.setData({
  76. list: res.data.list
  77. })
  78. }
  79. })
  80. },
  81. onLoad() {
  82. this.search()
  83. },
  84. onReachBottom: function() {
  85. this.setData({
  86. pageNum:this.data.pageNum+1
  87. })
  88. this.search()
  89. }
  90. })