search-record.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <view class="flex-common-css iPhone-bottom box-border-box bgc-f">
  3. <image class="order-bg" src="@/static/img/order-food/ss-bg.png" mode=""></image>
  4. <newNav textName="搜索商品" class="mb-20" titleColor='#333' leftIconColor='#333'></newNav>
  5. <view class="plr-24 box-border-box">
  6. <view class="s-input box-border-box bgc-f align-items-center flex-justify-space b-rad-200 z-3">
  7. <view class="align-items-center flex-1 mr-16">
  8. <image class="wh36 mr-16 flex-shrink0" src="/static/img/order-food/ss-icon.png" mode=""></image>
  9. <input class="input-box fs-32" placeholder-class="fc-9" v-model="search" type="text"
  10. placeholder="请搜索商品" @input="clearInput">
  11. </view>
  12. <view class="align-items-center">
  13. <image v-if="showClearIcon" @click="clearIcon" class="qk-icon mr-24"
  14. src="@/static/img/order-food/qk-icon.png" mode="">
  15. </image>
  16. <view class="input-buttom fs-28 fc-f fw-500 b-rad-200 text-align-center" @click="toList()">搜索</view>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="scroll-view-css bgc-f seacrh-info box-border-box p-32" v-if="goodsList.length<=0">
  21. <view class="flex-justify-space mb-32">
  22. <view class="fs-32 fw-600 fc-3">搜索历史</view>
  23. <view class="align-items-center" v-if="list.length > 0">
  24. <view @click="isOpen=!isOpen" class="">{{!isOpen?'收起':'展开'}}</view>
  25. <view @click="isOpen=!isOpen" :class="!isOpen?'down':'up'">
  26. <uni-icons type="right" size="14" color="#999"></uni-icons>
  27. </view>
  28. <view class="view-x"></view>
  29. <uni-icons @click="delList()" type="trash" size="18" color="#999"></uni-icons>
  30. </view>
  31. </view>
  32. <view id='' :class="isOpen?'hide-h':''" class="flex-wrap-wrap mb-50 search-history" v-if="list.length > 0">
  33. <view class="fs-28 list-item text-overflow-ellipsis-one" @click="toList(item)" v-for="(item,i) in list"
  34. :key="i">{{item}}</view>
  35. </view>
  36. </view>
  37. <view class="scroll-view-css bgc-F5F4F9 p-32 box-border-box" v-else>
  38. <view class="menu-list flex-justify-space bgc-f p-24 box-border-box b-rad-20 mb-16"
  39. v-for="(info,k) in goodsList" :key="k" :id="'goods_id'+ info.goods_id">
  40. <image class="flex-shrink0 goods_img mr-20" :src="info.goods_image" mode="scaleToFill"></image>
  41. <view class="menu-list-right flex-direction flex-justify-space">
  42. <view class="mb-8">
  43. <view class="mb-4 goods-name text-overflow-ellipsis fs-32 fw-600">
  44. {{info.goods_name}}
  45. </view>
  46. <view class="text-overflow-ellipsis-one fw-400 fc-9 fs-24 mb-2 goods-name"
  47. v-if="info.spec_type == 1">
  48. {{info.goods_desc?info.goods_desc:''}}
  49. </view>
  50. </view>
  51. <view class="flex-justify-space align-items-flex-end">
  52. <view class="">
  53. <span class="fs-24 fw-400 fc-3">¥</span>
  54. <span class="fs-36 fw-b fc-3">{{info.seckill_money>0?info.seckill_money:info.price}}</span>
  55. <span class="fs-24 fc-9">/份起</span>
  56. </view>
  57. <view class="display-flex align-items-center" v-if="info.spec_type == 1">
  58. <image v-show="info.num > 0" class="wh-44" @click="addred(1,info)"
  59. src="@/static/img/order-food/reduce-img.png" mode=""></image>
  60. <view v-show="info.num > 0" class="right-only-right-2 text-align-center fs-28 fw-400">
  61. {{info.num}}
  62. </view>
  63. <image class="wh-44" src="@/static/img/order-food/add-img.png" @click="addred(2,info)"
  64. mode=""></image>
  65. </view>
  66. <view v-else class="right-only-right text-align-center b-rad-200" @click="addred(3,info)">
  67. <view class="fw-500 fs-28 fc-f">
  68. 选规格
  69. </view>
  70. <view class="selectedNum" v-if="info.num>0">
  71. {{info.num}}
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. <view v-if="goodsList.length>0" class="shop-buttom-money p-24 box-border-box bgc-F5F4F9" @click="openBuyCrad()">
  79. <view
  80. class="shop-buttom-money-1 bgc-f flex-justify-space align-items-center pl-24 box-border-box pr-8 b-rad-200">
  81. <view class="align-items-center">
  82. <image class="gwc-img mr-36" src="@/static/img/order-food/gwc-img.png" mode="scaleToFill"></image>
  83. <view class="shop-buttom-num bgc-FE6B2C fs-24 fc-f text-align-center">{{cartData.total_num || 0}}
  84. </view>
  85. <view class="align-items-baseline">
  86. <view class="fw-600 fs-28 fc-3 mr-4">¥</view>
  87. <view class="fw-600 fs-48 fc-3">{{cartData.total_price || 0}}</view>
  88. </view>
  89. </view>
  90. <view class="shop-buttom-money-2 text-align-center fc-f fs-32 fw-600 b-rad-200"
  91. :class="cartData.total_num>0?'':'opacity-4'" @click.stop="toConfirmOrder()">去结算
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. </template>
  97. <script>
  98. import tools from "@/service/tools";
  99. import {
  100. getSearch,
  101. getSearchList,
  102. delSearch
  103. } from '@/api/goods.js';
  104. export default {
  105. data() {
  106. return {
  107. search: '',
  108. isOpen: false,
  109. showClearIcon: false,
  110. list: [],
  111. goodsList: [],
  112. historyType: false,
  113. total: '',
  114. page: 1
  115. }
  116. },
  117. onLoad() {
  118. this.getList()
  119. },
  120. onShow() {},
  121. mounted() {},
  122. methods: {
  123. toList(name) {
  124. let search = '';
  125. if (name) {
  126. search = name;
  127. this.search = name
  128. } else {
  129. search = this.search;
  130. }
  131. this.page = 1
  132. this.goodsList = []
  133. this.getSearch(search)
  134. },
  135. getSearch(search) {
  136. // 搜索商品列表
  137. getSearch({
  138. search: search,
  139. page: this.page
  140. }).then((res) => {
  141. if (res.code * 1 === 1) {
  142. this.goodsList = [...this.goodsList, ...res.data.items]
  143. }
  144. })
  145. },
  146. clearIcon() {
  147. this.search = '';
  148. this.showClearIcon = false;
  149. },
  150. clearInput(event) {
  151. this.search = event.detail.value;
  152. if (event.detail.value.length > 0) {
  153. this.showClearIcon = true;
  154. } else {
  155. this.showClearIcon = false;
  156. }
  157. },
  158. history() {
  159. const query = uni.createSelectorQuery().in(this)
  160. query
  161. .select('.search-history')
  162. .boundingClientRect(data => {
  163. console.log(data.height)
  164. })
  165. .exec();
  166. },
  167. getList() {
  168. // 获取搜索历史内容
  169. getSearchList().then((res) => {
  170. if (res.code === 1) {
  171. this.list = res.data.my_search;
  172. }
  173. })
  174. },
  175. delList() {
  176. delSearch().then((res) => {
  177. if (res.code === 1) {
  178. tools.success('删除成功');
  179. this.list = [];
  180. }
  181. })
  182. },
  183. },
  184. }
  185. </script>
  186. <style scoped lang="scss">
  187. .qk-icon {
  188. width: 32rpx;
  189. height: 32rpx;
  190. }
  191. .shop-buttom-money {
  192. width: 100%;
  193. // height: 140rpx;
  194. }
  195. .shop-buttom-money-1 {
  196. width: 100%;
  197. height: 96rpx;
  198. position: relative;
  199. }
  200. .shop-buttom-money-2 {
  201. width: 200rpx;
  202. height: 80rpx;
  203. line-height: 80rpx;
  204. background: linear-gradient(270deg, #FF3333 0%, #FE6122 100%);
  205. }
  206. .gwc-img {
  207. width: 88rpx;
  208. height: 88rpx;
  209. }
  210. .shop-buttom-num {
  211. width: 32rpx;
  212. height: 32rpx;
  213. line-height: 32rpx;
  214. border-radius: 50%;
  215. position: absolute;
  216. top: 0rpx;
  217. left: 85rpx;
  218. border: 1rpx solid #FFFFFF;
  219. }
  220. .z-3 {
  221. position: relative;
  222. z-index: 3;
  223. }
  224. .order-bg {
  225. width: 100%;
  226. height: 17vh;
  227. position: fixed;
  228. left: 0;
  229. top: 0;
  230. }
  231. .hide-h {
  232. height: 232rpx !important;
  233. overflow: hidden !important;
  234. }
  235. .down {
  236. transform: rotate(-90deg);
  237. transition: all 0.5s;
  238. }
  239. .up {
  240. transform: rotate(90deg);
  241. transition: all 0.5s;
  242. }
  243. .view-x {
  244. width: 2rpx;
  245. height: 20rpx;
  246. background-color: #eee;
  247. margin: 0 24rpx;
  248. }
  249. .find-item {
  250. width: 48%;
  251. text-align: left;
  252. }
  253. .list-item {
  254. max-height: 688rpx;
  255. min-width: 10rpx;
  256. height: 56rpx;
  257. line-height: 56rpx;
  258. background: #F7F8FC;
  259. border-radius: 200rpx;
  260. margin: 0 8rpx 32rpx 0;
  261. box-sizing: border-box;
  262. padding: 0 24rpx;
  263. }
  264. .seacrh-bg {
  265. position: absolute;
  266. top: 0;
  267. left: 0;
  268. width: 100%;
  269. height: 376rpx;
  270. filter: blur(80rpx);
  271. background-image: linear-gradient(to right, #C9F7FC, #F9F6E0, #F6F5F3);
  272. z-index: -1;
  273. }
  274. .wh36 {
  275. width: 36rpx;
  276. height: 36rpx;
  277. }
  278. .input-box {
  279. width: 100%;
  280. }
  281. .input-buttom {
  282. width: 120rpx;
  283. height: 60rpx;
  284. background: linear-gradient(270deg, #FF3333 0%, #FE6122 100%);
  285. line-height: 60rpx;
  286. }
  287. .s-input {
  288. width: 100%;
  289. height: 72rpx;
  290. padding: 6rpx 6rpx 6rpx 24rpx;
  291. }
  292. .seacrh-info {
  293. margin-top: 20rpx;
  294. border-radius: 24rpx 24rpx 0rpx 0rpx;
  295. }
  296. .seacrh-record-index {
  297. position: relative;
  298. }
  299. .wh-44 {
  300. width: 44rpx;
  301. height: 44rpx;
  302. }
  303. .menu-list {
  304. width: 100%;
  305. .goods_img {
  306. width: 168rpx;
  307. height: 168rpx;
  308. border-radius: 12rpx;
  309. }
  310. .menu-list-right {
  311. flex: 1;
  312. .right-only-right {
  313. width: 116rpx;
  314. height: 44rpx;
  315. background: linear-gradient(270deg, #FF3333 0%, #FE6122 100%);
  316. line-height: 44rpx;
  317. position: relative;
  318. .selectedNum {
  319. position: absolute;
  320. right: 2rpx;
  321. top: -22rpx;
  322. font-size: 24rpx;
  323. color: #fff;
  324. width: 32rpx;
  325. height: 32rpx;
  326. line-height: 32rpx;
  327. background: #FB3D03;
  328. border-radius: 50%;
  329. }
  330. }
  331. .right-only-right-red {
  332. width: 44rpx;
  333. height: 44rpx;
  334. line-height: 40rpx;
  335. border-radius: 12rpx;
  336. border: 1rpx solid #41ABF5;
  337. color: #41ABF5;
  338. }
  339. .right-only-right-add {
  340. width: 44rpx;
  341. height: 44rpx;
  342. line-height: 40rpx;
  343. background: linear-gradient(117deg, #57CAFF 0%, #41ABF5 100%);
  344. border-radius: 12rpx;
  345. }
  346. .right-only-right-2 {
  347. min-width: 50rpx;
  348. }
  349. }
  350. }
  351. </style>