searchWeb.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. },
  7. onLoad: function () {
  8. wx.hideShareMenu();
  9. var that = this;
  10. that.setData({
  11. Containnerheight: main.getWindowHeight(),
  12. });
  13. },
  14. onShow:function(){
  15. var that = this;
  16. var arr = wx.getStorageSync("SearchWord");
  17. if (!arr)
  18. arr = [];
  19. that.setData({
  20. SelectList: arr,
  21. });
  22. },
  23. onSearch: function (e) {
  24. wx.navigateTo({
  25. url: './searchWeb1',
  26. })
  27. },
  28. onSearchHistory: function (e) {
  29. var search = e.currentTarget.dataset.search;
  30. var arr = wx.getStorageSync("SearchWord");
  31. if (!arr)
  32. arr = [];
  33. var obj = {};
  34. obj.Key = search;
  35. for (var i = 0; i < arr.length; i++) {
  36. if (arr[i].Key == search) {
  37. obj.Key = arr[i].Key;
  38. obj.Value = arr[i].Value;
  39. arr.splice(i, 1);
  40. break;
  41. }
  42. }
  43. arr.unshift(obj);
  44. wx.setStorageSync("SearchWord", arr);
  45. wx.navigateTo({
  46. url: './searchWeb2?back=2&search=' + search+'&type=1',
  47. });
  48. },
  49. deleteItem:function(e){
  50. var that=this;
  51. wx.showModal({
  52. title: '提醒',
  53. content: '删除这条搜索记录?',
  54. success(res) {
  55. if (res.confirm) {
  56. var index = e.currentTarget.dataset.id;
  57. that.data.SelectList.splice(index, 1);
  58. that.setData({
  59. SelectList: that.data.SelectList,
  60. });
  61. wx.setStorageSync("SearchWord", that.data.SelectList);
  62. }
  63. }
  64. });
  65. },
  66. onShareAppMessage: function () {
  67. return {
  68. title: app.globalData.ShareTitle,
  69. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  70. imageUrl: app.globalData.ShareImage,
  71. }
  72. },
  73. })