search-record.vue 10 KB

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