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

265 lines
6.2 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 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="$t('common.searchproduct_hint')" />
  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">{{$t('page.search')}}</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">{{$t('common.hotsearch')}}</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">{{$t('client.hotsearchhide')}}</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 ">{{$t('common.historysearch')}}</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. let _this = this;
  120. uni.showModal({
  121. title: _this.$t('common.notice_dialog_title'),
  122. content: '您确定要清空搜索记录吗?',
  123. confirmText: '确定清空',
  124. cancelText: '点错了',
  125. success: (res) => {
  126. if (res.confirm) {
  127. this.deleteAllSearch()
  128. } else if (res.cancel) {
  129. }
  130. }
  131. })
  132. },
  133. deleteAllSearch() {
  134. NET.request(API.DeleteAllSearch, {}, 'POST').then(res => {
  135. this.historyList = res.data
  136. }).catch(res => {
  137. })
  138. },
  139. historyDelOne(searchId) {
  140. let _this= this;
  141. uni.showModal({
  142. title: _this.$t('common.notice_dialog_title'),
  143. content: '您确定要删除这一条记录吗?',
  144. confirmText: '确定删除',
  145. cancelText: '点错了',
  146. success: (res) => {
  147. if (res.confirm) {
  148. NET.request(API.DeleteSearch, {
  149. searchId: searchId
  150. }, 'POST').then(res => {
  151. this.findSearchHistory()
  152. }).catch(res => {})
  153. } else if (res.cancel) {
  154. }
  155. }
  156. })
  157. }
  158. }
  159. }
  160. </script>
  161. <style lang='scss' scoped>
  162. input {
  163. padding-left: 80upx;
  164. }
  165. .searchImg-box{
  166. .searchImg {
  167. width: 36upx;
  168. height: 36upx;
  169. position: absolute;
  170. left: 60upx;
  171. }
  172. .search-box {
  173. background-color: #F1F1F1;
  174. width: 530upx;
  175. height: 66upx;
  176. }
  177. .searchboxPlace {
  178. font-size: 26upx;
  179. color: #A9A9A9;
  180. padding-right: 30upx;
  181. }
  182. .searchClose-icon {
  183. width: 30upx;
  184. height: 30upx;
  185. margin-left: -50upx;
  186. z-index: 99999;
  187. }
  188. }
  189. // 热门搜索
  190. .hotSearchBox{
  191. padding: 0 36upx;
  192. .historyText{
  193. flex: 1;
  194. }
  195. .hotSearchListSee-icon {
  196. height: 24upx;
  197. }
  198. .hotSearchListNotSee-icon {
  199. height: 36upx;
  200. }
  201. .seeIcon {
  202. width: 40upx;
  203. position: absolute;
  204. right: 30upx;
  205. }
  206. .notSeeContent {
  207. margin-top: 20upx;
  208. text-align: center;
  209. font-size: 24upx;
  210. color: #CCCCCC;
  211. }
  212. }
  213. .line{
  214. margin: 70upx 0;
  215. height: 2upx;
  216. background: #F3F4F5;
  217. }
  218. // 历史搜索
  219. .historyBox{
  220. padding: 0 36upx;
  221. .historySear-box{
  222. width: 100%;
  223. }
  224. .historyDel-icon {
  225. width: 30upx;
  226. height: 30upx;
  227. position: absolute;
  228. right: 30upx;
  229. }
  230. .historyIconBox{
  231. width: 50upx;
  232. .historySearDel-icon {
  233. position: relative;
  234. width: 16upx;
  235. height: 16upx;
  236. }
  237. }
  238. }
  239. .tipsBox{
  240. padding: 15rpx 24rpx;
  241. }
  242. .boxTitle{
  243. margin: 30rpx 0;
  244. }
  245. .historySearDel-box {
  246. height: 54upx;
  247. line-height: 54upx;
  248. margin: 15rpx 15rpx;
  249. background-color: #F1F1F1;
  250. text-align: center;
  251. overflow: hidden;
  252. .boxContent{
  253. font-size: 28rpx;
  254. padding: 0 30rpx;
  255. }
  256. }
  257. </style>