search.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const sheep_index = require("../../sheep/index.js");
  4. require("../../sheep/api/index.js");
  5. require("../../sheep/api/distri/score.js");
  6. require("../../sheep/request/index.js");
  7. require("../../sheep/config/index.js");
  8. require("../../sheep/store/index.js");
  9. require("../../sheep/store/app.js");
  10. require("../../sheep/api/promotion/diy.js");
  11. require("../../sheep/platform/index.js");
  12. require("../../sheep/platform/provider/wechat/index.js");
  13. require("../../sheep/platform/provider/wechat/miniProgram.js");
  14. require("../../sheep/api/member/auth.js");
  15. require("../../sheep/api/member/social.js");
  16. require("../../sheep/api/member/user.js");
  17. require("../../sheep/platform/provider/apple/index.js");
  18. require("../../sheep/platform/share.js");
  19. require("../../sheep/router/index.js");
  20. require("../../sheep/hooks/useModal.js");
  21. require("../../sheep/helper/index.js");
  22. require("../../sheep/helper/test.js");
  23. require("../../sheep/helper/digit.js");
  24. require("../../sheep/api/member/signin.js");
  25. require("../../sheep/helper/throttle.js");
  26. require("../../sheep/url/index.js");
  27. require("../../sheep/platform/pay.js");
  28. require("../../sheep/api/pay/order.js");
  29. require("../../sheep/store/user.js");
  30. require("../../sheep/store/cart.js");
  31. require("../../sheep/api/trade/cart.js");
  32. require("../../sheep/api/pay/wallet.js");
  33. require("../../sheep/api/trade/order.js");
  34. require("../../sheep/api/promotion/coupon.js");
  35. require("../../sheep/store/sys.js");
  36. require("../../sheep/store/modal.js");
  37. require("../../sheep/api/distri/share.js");
  38. require("../../sheep/api/distri/team.js");
  39. require("../../sheep/api/infra/file.js");
  40. require("../../sheep/api/member/address.js");
  41. require("../../sheep/api/member/point.js");
  42. require("../../sheep/api/migration/app.js");
  43. require("../../sheep/api/migration/chat.js");
  44. require("../../sheep/api/migration/index.js");
  45. require("../../sheep/api/migration/third.js");
  46. require("../../sheep/api/pay/channel.js");
  47. require("../../sheep/api/product/category.js");
  48. require("../../sheep/api/product/comment.js");
  49. require("../../sheep/api/product/favorite.js");
  50. require("../../sheep/api/product/history.js");
  51. require("../../sheep/api/product/spu.js");
  52. require("../../sheep/api/promotion/activity.js");
  53. require("../../sheep/api/promotion/article.js");
  54. require("../../sheep/api/promotion/bargain.js");
  55. require("../../sheep/api/promotion/combination.js");
  56. require("../../sheep/api/promotion/rewardActivity.js");
  57. require("../../sheep/api/promotion/seckill.js");
  58. require("../../sheep/api/system/area.js");
  59. require("../../sheep/api/system/voice.js");
  60. require("../../sheep/api/trade/afterSale.js");
  61. require("../../sheep/api/trade/brokerage.js");
  62. require("../../sheep/api/trade/config.js");
  63. require("../../sheep/api/trade/delivery.js");
  64. require("../../sheep/config/zIndex.js");
  65. if (!Array) {
  66. const _easycom_uni_search_bar2 = common_vendor.resolveComponent("uni-search-bar");
  67. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  68. (_easycom_uni_search_bar2 + _easycom_s_layout2)();
  69. }
  70. const _easycom_uni_search_bar = () => "../../uni_modules/uni-search-bar/components/uni-search-bar/uni-search-bar.js";
  71. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  72. if (!Math) {
  73. (_easycom_uni_search_bar + _easycom_s_layout)();
  74. }
  75. const _sfc_main = {
  76. __name: "search",
  77. setup(__props) {
  78. const state = common_vendor.reactive({
  79. historyList: []
  80. });
  81. function onSearch(keyword) {
  82. if (!keyword) {
  83. return;
  84. }
  85. saveSearchHistory(keyword);
  86. sheep_index.sheep.$router.go("/pages/goods/list", { keyword });
  87. }
  88. function saveSearchHistory(keyword) {
  89. if (state.historyList.includes(keyword)) {
  90. state.historyList.splice(state.historyList.indexOf(keyword), 1);
  91. }
  92. state.historyList.unshift(keyword);
  93. if (state.historyList.length >= 10) {
  94. state.historyList.length = 10;
  95. }
  96. common_vendor.index.setStorageSync("searchHistory", state.historyList);
  97. }
  98. function onDelete() {
  99. common_vendor.index.showModal({
  100. title: "提示",
  101. content: "确认清除搜索历史吗?",
  102. success: function(res) {
  103. if (res.confirm) {
  104. state.historyTag = [];
  105. common_vendor.index.removeStorageSync("searchHistory");
  106. }
  107. }
  108. });
  109. }
  110. common_vendor.onLoad(() => {
  111. state.historyList = common_vendor.index.getStorageSync("searchHistory") || [];
  112. });
  113. return (_ctx, _cache) => {
  114. return {
  115. a: common_vendor.o(($event) => onSearch($event.value)),
  116. b: common_vendor.p({
  117. radius: "33",
  118. placeholder: "请输入关键字",
  119. cancelButton: "none",
  120. focus: true
  121. }),
  122. c: common_vendor.o(onDelete),
  123. d: common_vendor.f(state.historyList, (item, index, i0) => {
  124. return {
  125. a: common_vendor.t(item),
  126. b: common_vendor.o(($event) => onSearch(item), index),
  127. c: index
  128. };
  129. }),
  130. e: common_vendor.p({
  131. title: "搜索",
  132. bgStyle: {
  133. color: "#FFF"
  134. }
  135. })
  136. };
  137. };
  138. }
  139. };
  140. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-5aac7367"], ["__file", "D:/zx/mall-front-app/pages/index/search.vue"]]);
  141. wx.createPage(MiniProgramPage);