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.

93 lines
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. 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. Http.get({
  62. url: config.api.mainCollet,
  63. data: {
  64. title: this.data.inputValue,
  65. pageNum: this.data.pageNum,
  66. pageSize: 8
  67. }
  68. }).then(res => {
  69. console.log(res);
  70. let temp = this.data.list
  71. if (this.data.pageNum > 1) {
  72. temp.push(res.data.list)
  73. this.setData({
  74. list: temp
  75. })
  76. } else {
  77. this.setData({
  78. list: res.data.list
  79. })
  80. }
  81. })
  82. },
  83. onLoad() {
  84. this.search()
  85. },
  86. onReachBottom: function() {
  87. this.setData({
  88. pageNum:this.data.pageNum+1
  89. })
  90. this.search()
  91. }
  92. })