多租户商城-商户小程序端
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.

263 lines
6.1 KiB

4 years ago
3 years ago
4 years ago
  1. <template>
  2. <view>
  3. <!-- 搜索商品 -->
  4. <view>
  5. <view class="flex-items-plus flex-row mar-top-20">
  6. <view class="searchImg-box flex-items-plus">
  7. <image class="searchImg" src="https://ceres.zkthink.com/static/img/searchImg.png"></image>
  8. <input class="search-box" v-model="keyWord" maxlength="20" placeholder-class="searchboxPlace"
  9. placeholder="请输入您想要的宝贝" />
  10. <!-- <image class="searchClose-icon" @click="searchTextDel"
  11. src="https://ceres.zkthink.com/static/img/index/searchClose_icon.png"></image>-->
  12. </view>
  13. <view class="mar-left-40 fs26" @click="getList">搜索</view>
  14. </view>
  15. </view>
  16. <!-- 热门搜索 -->
  17. <view class="hotSearchBox tipsBox">
  18. <view class="boxTitle mar-leftgetList-30" v-if="hotSearchList.length>0">
  19. <label class="fs30 font-color-999 fs-weight-300">热门搜索</label>
  20. <image class="seeIcon hotSearchListSee-icon" v-if="isSee" @click="changeHotSearchListIsSee"
  21. src="https://ceres.zkthink.com/static/img/see.png"></image>
  22. <image class="seeIcon hotSearchListNotSee-icon" v-else @click="changeHotSearchListIsSee"
  23. src="https://ceres.zkthink.com/static/img/notSee.png"></image>
  24. </view>
  25. <view>
  26. <view class="flex-wrap-1 flex-row" v-if="isSee">
  27. <view v-for="(item, index) in hotSearchList" :key="index"
  28. class="historySearDel-box flex-items-plus mar-right-30">
  29. <view class="boxContent" @click="historyKeyword(item)">{{item}}</view>
  30. </view>
  31. </view>
  32. <view v-else class="notSeeContent">当前热门搜索已隐藏</view>
  33. </view>
  34. </view>
  35. <view class="line" color="#F3F4F5" />
  36. <!-- 历史搜索 -->
  37. <view class="historyBox tipsBox">
  38. <view class="boxTitle mar-leftgetList-30" v-if="historyList.length>0">
  39. <label class="fs30 font-color-999 fs-weight-300 ">历史搜索</label>
  40. <image class="historyDel-icon" @click="historyDelAll" src="https://ceres.zkthink.com/static/img/index/historyDel_icon.png">
  41. </image>
  42. </view>
  43. <view class="historySear-box flex-wrap-1 flex-row">
  44. <view
  45. v-for="(item, index) in historyList"
  46. :key="item.searchId"
  47. class="historySearDel-box flex-items-plus flex-sp-between mar-right-30"
  48. >
  49. <view class="boxContent historyText line1" @click="historyKeyword(item.search)">{{item.search}}</view>
  50. <label class="font-color-DDD fs22 pad-topbot-10 text-align">|</label>
  51. <view class="historyIconBox" @click="historyDelOne(item.searchId)">
  52. <image class="historySearDel-icon text-align"
  53. src="https://ceres.zkthink.com/static/img/index/historySearDel_icon.png"></image>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. const NET = require('../../../utils/request')
  63. const API = require('../../../config/api')
  64. export default {
  65. data() {
  66. return {
  67. keyWord: '',
  68. historyList: [],
  69. hotSearchList: [],
  70. list: [],
  71. isSee: true
  72. }
  73. },
  74. onLoad() {
  75. },
  76. onShow() {
  77. this.findSearchHistory()
  78. this.findHotSearch()
  79. },
  80. methods: {
  81. searchTextDel() {
  82. this.keyWord = ''
  83. },
  84. getList() {
  85. if (!this.keyWord) {
  86. uni.showToast({
  87. title: '请输入要搜索内容!',
  88. duration: 2000,
  89. icon: 'none'
  90. });
  91. } else {
  92. uni.navigateTo({
  93. url: '../../goodsModule/goodsList?keyWord=' + this.keyWord,
  94. })
  95. }
  96. },
  97. historyKeyword(keyWord) {
  98. uni.navigateTo({
  99. url: '../../goodsModule/goodsList?keyWord=' + keyWord,
  100. })
  101. },
  102. //热门搜索
  103. findHotSearch() {
  104. NET.request(API.SelectHotSearch, {}, 'GET').then(res => {
  105. this.hotSearchList = res.data
  106. })
  107. },
  108. changeHotSearchListIsSee() {
  109. this.isSee = !this.isSee
  110. },
  111. //历史记录
  112. findSearchHistory() {
  113. NET.request(API.SearchHistory, {}, 'GET').then(res => {
  114. this.historyList = res.data
  115. }).catch(res => {
  116. })
  117. },
  118. historyDelAll() {
  119. uni.showModal({
  120. title: '温馨提示',
  121. content: '您确定要清空搜索记录吗?',
  122. confirmText: '确定清空',
  123. cancelText: '点错了',
  124. success: (res) => {
  125. if (res.confirm) {
  126. this.deleteAllSearch()
  127. } else if (res.cancel) {
  128. }
  129. }
  130. })
  131. },
  132. deleteAllSearch() {
  133. NET.request(API.DeleteAllSearch, {}, 'POST').then(res => {
  134. this.historyList = res.data
  135. }).catch(res => {
  136. })
  137. },
  138. historyDelOne(searchId) {
  139. uni.showModal({
  140. title: '温馨提示',
  141. content: '您确定要删除这一条记录吗?',
  142. confirmText: '确定删除',
  143. cancelText: '点错了',
  144. success: (res) => {
  145. if (res.confirm) {
  146. NET.request(API.DeleteSearch, {
  147. searchId: searchId
  148. }, 'POST').then(res => {
  149. this.findSearchHistory()
  150. }).catch(res => {})
  151. } else if (res.cancel) {
  152. }
  153. }
  154. })
  155. }
  156. }
  157. }
  158. </script>
  159. <style lang='scss' scoped>
  160. input {
  161. padding-left: 80upx;
  162. }
  163. .searchImg-box{
  164. .searchImg {
  165. width: 36upx;
  166. height: 36upx;
  167. position: absolute;
  168. left: 60upx;
  169. }
  170. .search-box {
  171. background-color: #F1F1F1;
  172. width: 530upx;
  173. height: 66upx;
  174. }
  175. .searchboxPlace {
  176. font-size: 26upx;
  177. color: #A9A9A9;
  178. padding-right: 30upx;
  179. }
  180. .searchClose-icon {
  181. width: 30upx;
  182. height: 30upx;
  183. margin-left: -50upx;
  184. z-index: 99999;
  185. }
  186. }
  187. // 热门搜索
  188. .hotSearchBox{
  189. padding: 0 36upx;
  190. .historyText{
  191. flex: 1;
  192. }
  193. .hotSearchListSee-icon {
  194. height: 24upx;
  195. }
  196. .hotSearchListNotSee-icon {
  197. height: 36upx;
  198. }
  199. .seeIcon {
  200. width: 40upx;
  201. position: absolute;
  202. right: 30upx;
  203. }
  204. .notSeeContent {
  205. margin-top: 20upx;
  206. text-align: center;
  207. font-size: 24upx;
  208. color: #CCCCCC;
  209. }
  210. }
  211. .line{
  212. margin: 70upx 0;
  213. height: 2upx;
  214. background: #F3F4F5;
  215. }
  216. // 历史搜索
  217. .historyBox{
  218. padding: 0 36upx;
  219. .historySear-box{
  220. width: 100%;
  221. }
  222. .historyDel-icon {
  223. width: 30upx;
  224. height: 30upx;
  225. position: absolute;
  226. right: 30upx;
  227. }
  228. .historyIconBox{
  229. width: 50upx;
  230. .historySearDel-icon {
  231. position: relative;
  232. width: 16upx;
  233. height: 16upx;
  234. }
  235. }
  236. }
  237. .tipsBox{
  238. padding: 15rpx 24rpx;
  239. }
  240. .boxTitle{
  241. margin: 30rpx 0;
  242. }
  243. .historySearDel-box {
  244. height: 54upx;
  245. line-height: 54upx;
  246. margin: 15rpx 15rpx;
  247. background-color: #F1F1F1;
  248. text-align: center;
  249. overflow: hidden;
  250. .boxContent{
  251. font-size: 28rpx;
  252. padding: 0 30rpx;
  253. }
  254. }
  255. </style>