index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. <template>
  2. <view class="container flex-col" :data-theme="theme" :style="{height: winHeight + 'px'}">
  3. <!-- #ifdef MP -->
  4. <view class="cart_nav">
  5. <nav-bar iconColor='#fff' ref="navBarRef" :navTitle="navTitle" backgroundColor="#FF6702" :isBackgroundColor="false">
  6. </nav-bar>
  7. </view>
  8. <!-- #endif -->
  9. <view class='searchGood'>
  10. <view class='search-box acea-row row-between-wrapper'>
  11. <view class="flex-y-center">
  12. <text class='iconfont icon-sousuo2'></text>
  13. <input type='text' :value='searchValue' :focus="focus" placeholder='点击搜索外卖商家' confirm-type='search' @confirm="searchBut"
  14. placeholder-class='placeholder' @input="setValue" maxlength="20"></input>
  15. <view class='bnt flex-center' @tap='searchBut'>搜索</view>
  16. </view>
  17. </view>
  18. <scroll-view :scroll-x="true" scroll-with-animation style="white-space: nowrap;margin: 20rpx 0rpx;padding: 0 20rpx;">
  19. <view :class="optionIndex == item.id ? 'active-option' : ''" style="color: #141414;display: inline-block;margin-right: 30rpx;width: 96rpx;"
  20. v-for="(item, index) in optionData" :key="index" @tap="onOptionClick(item)">
  21. <view class="flex-col flex-center">
  22. <image style="width: 100%;height: 96rpx;" :src="item.icon"></image>
  23. <view style="font-size: 21rpx;margin-top: 10rpx;">{{item.name}}</view>
  24. </view>
  25. </view>
  26. </scroll-view>
  27. </view>
  28. <view style="padding: 0 20rpx;flex: 1;overflow: hidden;" class="flex-col">
  29. <!-- 销量排行 -->
  30. <view class="tab-list" style="margin-top: 10rpx;">
  31. <view :class=" item.checked ? 'tab-item2' : 'tab-item2-false' " v-for="item in labelList" :key="item.id" @click="item2Click(item)">{{item.label}}</view>
  32. </view>
  33. <view class="flex-center flex-col noCommodity" v-if="noDataTip">
  34. <view class='pictrue'>
  35. <image :src="urlDomain+'crmebimage/presets/noSearch.png'"></image>
  36. </view>
  37. <text class="text-ccc">{{noDataTip}}</text>
  38. </view>
  39. <scroll-view scroll-y scroll-with-animation @scrolltolower="onScrollBottom" style="flex: 1;overflow: hidden;">
  40. <view class="content-goods2" v-for="item in merchantList" :key="item.id" @click="merchantTab(item)">
  41. <view>
  42. <image :src="item.avatar" style="width: 230rpx;height: 230rpx;"></image>
  43. </view>
  44. <view style="margin-left: 20rpx;flex: 1;">
  45. <view class="">
  46. <text class="goods-title">{{item.name}}</text>
  47. </view>
  48. <view style="margin-top: 10rpx;">
  49. <text class="goods-score">{{item.score}}</text>
  50. <text class="goods-info" style="margin-left: 10rpx;">月销 {{item.salesVolume}}</text>
  51. <text class="goods-info" style="margin-left: 25rpx;">人均 ¥ {{item.perCapita}}</text>
  52. </view>
  53. <view style="margin-top: 10rpx;display: flex;align-items: center;">
  54. <text class="goods-info">起送 ¥ {{item.perCapita}}</text>
  55. <text v-if="!item.isfreeDeliverfee" class="goods-info" style="color: #E5AD21;margin-left: 18rpx;">免配送费</text>
  56. <view v-if="!item.isfreeDeliverfee && item.freeDeliverFee > 0" style="color: #999999;font-size: 21rpx;margin-left: 10rpx;text-decoration: line-through;">¥
  57. {{item.freeDeliverFee}}</view>
  58. <text v-if="item.isfreeDeliverfee" style="color: #999999;font-size: 21rpx;margin-left: 10rpx;">配送费¥
  59. {{item.distCosts}}</text>
  60. <text class="goods-info" style="margin-left: 38rpx;">10分钟</text>
  61. <text class="goods-info" style="margin-left: 10rpx;">{{item.distance}}</text>
  62. </view>
  63. <view style="margin-top: 22rpx;"><text class="goods-sales">已售卖{{item.salesVolume}}件</text></view>
  64. <view style="margin-top: 14rpx;">
  65. <swiper :indicator-dots="false" :autoplay="true" :circular="true" :display-multiple-items="3" style="height: 43rpx;">
  66. <swiper-item v-for="(item2,index2) in item.discountLabel" :key="index2">
  67. <text class="goods-labels">{{item2}}</text>
  68. </swiper-item>
  69. </swiper>
  70. <!-- <text class="goods-labels" v-for="(item2,index2) in item.discountLabel" :key="index2">{{item2}}</text> -->
  71. </view>
  72. </view>
  73. </view>
  74. <view class='loadingicon flex-center' :hidden='!loading'>
  75. <text class='loading iconfont icon-jiazai' style="width: auto;"></text>加载更多
  76. </view>
  77. <view class="flex-center no-data-tip" v-if="loadTitle">{{loadTitle}}</view>
  78. </scroll-view>
  79. </view>
  80. </view>
  81. </template>
  82. <script>
  83. // +----------------------------------------------------------------------
  84. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  85. // +----------------------------------------------------------------------
  86. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  87. // +----------------------------------------------------------------------
  88. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  89. // +----------------------------------------------------------------------
  90. // | Author: CRMEB Team <admin@crmeb.com>
  91. // +----------------------------------------------------------------------
  92. import {
  93. getSearchKeyword,
  94. } from '@/api/product.js';
  95. // #ifdef MP
  96. import navBar from '@/components/navBar';
  97. // #endif
  98. import {
  99. getMerchantSearchList,
  100. getHomeInfo
  101. } from '@/api/home.js';
  102. import {
  103. getProduct
  104. } from '@/api/takeout.js';
  105. import tags from '../../mixins/tags';
  106. let app = getApp();
  107. export default {
  108. components: {
  109. // #ifdef MP
  110. navBar
  111. // #endif
  112. },
  113. mixins:[tags],
  114. data() {
  115. return {
  116. optionData: [],
  117. optionIndex: 0,
  118. winHeight: 0,
  119. navTitle: '搜索外卖商家',
  120. hostProduct: [],
  121. searchValue: '',
  122. focus: false,
  123. bastList: [],
  124. hotSearchList: [],
  125. theme: app.globalData.theme,
  126. page: 1,
  127. // labelList: [{
  128. // id: 1,
  129. // label: "销量排行",
  130. // checked: true
  131. // }, {
  132. // id: 2,
  133. // label: "满减大促",
  134. // checked: false
  135. // }, {
  136. // id: 3,
  137. // label: "首单立减",
  138. // checked: false
  139. // }, {
  140. // id: 4,
  141. // label: "减配送费",
  142. // checked: false
  143. // }],
  144. urlDomain: this.$Cache.get("imgHost"),
  145. merchantList: [],
  146. noDataTip: '',
  147. loadTitle: '',
  148. loading: false,
  149. cateId: 0
  150. };
  151. },
  152. // 滚动监听
  153. onPageScroll(e) {
  154. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  155. uni.$emit('scroll');
  156. },
  157. onShow: function() {
  158. this.getRoutineHotSearch();
  159. },
  160. onLoad(e) {
  161. let that = this
  162. uni.getSystemInfo({
  163. success: function(res) {
  164. that.winHeight = res.windowHeight
  165. },
  166. });
  167. if (e.searchVal) that.searchValue = e.searchVal;
  168. e.navTitle ? that.navTitle = e.navTitle : ''
  169. e.id ? that.cateId = e.id : ''
  170. const allData = {
  171. name : '全部',
  172. id : 0,
  173. icon : '/static/img/quanbu.png',
  174. };
  175. getProduct(that.cateId).then(res => {
  176. const data = res.data;
  177. if (data.length !== 0) {
  178. that.optionIndex =0;
  179. that.optionData.push(allData)
  180. data.forEach(function(item) {
  181. that.optionData.push(item);
  182. });
  183. }
  184. that.getMatchedData()
  185. })
  186. },
  187. methods: {
  188. // getTag(){
  189. // return this.labelList.filter((ite => ite.checked)).map(ite => ite.id).join(',')
  190. // },
  191. getMatchedData() {
  192. if (this.loading) return;
  193. this.loading = true
  194. getMerchantSearchList({
  195. latitude: uni.getStorageSync('user_latitude'),
  196. longitude: uni.getStorageSync('user_longitude'),
  197. productType: this.cateId,
  198. keywords: this.searchValue,
  199. typeIds: this.optionIndex==0?"":this.optionIndex,
  200. page: this.page,
  201. limit: 10,
  202. queryLabels: this.getTag()
  203. }).then(res => {
  204. let list = res.data.list || [];
  205. this.merchantList = this.$util.SplitArray(list, this.merchantList);
  206. if (this.merchantList.length == 0) {
  207. this.loadTitle = ''
  208. this.noDataTip = ' 暂无外卖商家 ';
  209. } else {
  210. this.noDataTip = ''
  211. this.loadTitle = list.length < 10 ? "我也是有底线的~" : '';
  212. }
  213. this.loading = false
  214. console.log('商品信息:', this.merchantList);
  215. this.page += 1;
  216. }).catch(err => {
  217. this.loading = false
  218. console.log(err)
  219. });
  220. },
  221. item2Click(item) {
  222. item.checked = !item.checked;
  223. this.merchantList = []
  224. this.page = 1
  225. this.getMatchedData()
  226. },
  227. onOptionClick(item) {
  228. if (this.optionIndex === item.id) return
  229. this.page = 1;
  230. this.merchantList = [];
  231. this.optionIndex = item.id;
  232. this.getMatchedData()
  233. },
  234. getRoutineHotSearch: function() {
  235. let that = this;
  236. getSearchKeyword().then(res => {
  237. that.$set(that, 'hotSearchList', res.data);
  238. });
  239. },
  240. setHotSearchValue: function(event) {
  241. this.$set(this, 'searchValue', event);
  242. this.page = 1;
  243. this.merchantList = [];
  244. this.$set(this, 'bastList', []);
  245. this.getMatchedData()
  246. // uni.navigateTo({
  247. // url: `/pages/goods/goods_list/index?searchValue=${this.searchValue}`
  248. // })
  249. },
  250. setValue: function(event) {
  251. this.$set(this, 'searchValue', event.detail.value);
  252. },
  253. searchBut: function(e) {
  254. let that = this;
  255. let val = '';
  256. that.focus = false;
  257. if (e.detail.value) {
  258. val = e.detail.value
  259. }
  260. if (that.searchValue.length > 0 || val) {
  261. this.page = 1;
  262. this.merchantList = [];
  263. this.getMatchedData()
  264. } else {
  265. return this.$util.Tips({
  266. title: '请输入要搜索的外卖商家',
  267. icon: 'none',
  268. duration: 1000,
  269. mask: true,
  270. });
  271. }
  272. },
  273. merchantTab(item) {
  274. // 修改跳转
  275. uni.navigateTo({
  276. url: `/pages/merchant/home/index?merId=${item.id}`
  277. // url: `/pages/goods_cate/index?id=${item.id}`
  278. })
  279. },
  280. onScrollBottom() {
  281. if (!this.loadTitle) {
  282. this.getMatchedData()
  283. }
  284. }
  285. }
  286. }
  287. </script>
  288. <style lang="scss" scoped>
  289. .container {
  290. overflow: hidden;
  291. position: relative;
  292. }
  293. .no-data-tip {
  294. color: #CCC;
  295. }
  296. page {
  297. background-color: #f5f5f5 !important;
  298. }
  299. .searchGood .search {
  300. padding-left: 30rpx;
  301. background-color: #fff !important;
  302. }
  303. .searchGood .search {
  304. /* #ifndef MP */
  305. padding-top: 20rpx;
  306. padding-bottom: 20rpx;
  307. /* #endif */
  308. /* #ifdef MP */
  309. position: fixed;
  310. width: 100%;
  311. z-index: 9999;
  312. top: 0;
  313. /* #endif */
  314. }
  315. .searchGood .search .input {
  316. width: 598rpx;
  317. background-color: #f7f7f7;
  318. border-radius: 33rpx;
  319. padding: 0 35rpx;
  320. box-sizing: border-box;
  321. height: 66rpx;
  322. }
  323. .searchGood .search .input input {
  324. width: 472rpx;
  325. font-size: 26rpx;
  326. }
  327. .searchGood .search .input .placeholder {
  328. color: #bbb;
  329. }
  330. .searchGood .search .input .iconfont {
  331. color: #000;
  332. font-size: 35rpx;
  333. }
  334. .searchGood .search .bnt {
  335. width: 120rpx;
  336. text-align: center;
  337. height: 66rpx;
  338. line-height: 66rpx;
  339. font-size: 30rpx;
  340. color: #282828;
  341. }
  342. .searchGood .title {
  343. font-weight: 500;
  344. font-family: PingFang SC, PingFang SC;
  345. font-size: 28rpx;
  346. color: #333;
  347. margin: 50rpx 30rpx 25rpx 30rpx;
  348. }
  349. .searchGood .list {
  350. padding-left: 10rpx;
  351. }
  352. .searchGood .list .item {
  353. font-size: 26rpx;
  354. color: #454545;
  355. padding: 0 21rpx;
  356. height: 60rpx;
  357. border-radius: 30rpx;
  358. line-height: 60rpx;
  359. border: 1rpx solid #aaa;
  360. margin: 0 0 20rpx 20rpx;
  361. }
  362. .searchGood .line {
  363. margin: 20rpx 30rpx 0 30rpx;
  364. }
  365. .searchBox {
  366. width: 100%;
  367. }
  368. .search-box {
  369. background-color: #fff;
  370. padding: 0 39rpx;
  371. margin-top: 10rpx;
  372. box-sizing: border-box;
  373. height: 96rpx;
  374. .flex-y-center {
  375. width: 100%;
  376. height: 69rpx;
  377. padding-left: 29rpx;
  378. border-radius: 35rpx;
  379. border: 2rpx solid #FF6702;
  380. }
  381. .bnt {
  382. background: #FF6702;
  383. border-radius: 35rpx;
  384. width: 115rpx;
  385. height: 100%;
  386. font-weight: 500;
  387. font-size: 35rpx;
  388. color: #FFFFFF;
  389. }
  390. }
  391. .icon-fanhui2 {
  392. // line-height: 66rpx;
  393. }
  394. .search-box input {
  395. width: 90%;
  396. font-size: 26rpx;
  397. }
  398. .search-box .placeholder {
  399. color: #bbb;
  400. }
  401. .search-box .iconfont {
  402. color: #000;
  403. font-size: 35rpx;
  404. }
  405. .tab-list {
  406. display: flex;
  407. /* 启用弹性布局 */
  408. flex-direction: row;
  409. /* 横向排列 */
  410. justify-content: space-between;
  411. /* 均匀分布子项 */
  412. flex-wrap: wrap;
  413. /* 允许换行(适用于屏幕宽度不足时) */
  414. .tab-item2 {
  415. width: 23%;
  416. /* 5个元素平分宽度,留2%作为间隙 */
  417. text-align: center;
  418. background-color: #FFC127;
  419. border-radius: 8rpx;
  420. font-size: 23rpx;
  421. padding: 6rpx;
  422. font-weight: 400;
  423. }
  424. .tab-item2-false {
  425. width: 23%;
  426. /* 5个元素平分宽度,留2%作为间隙 */
  427. text-align: center;
  428. background-color: #fff;
  429. border-radius: 8rpx;
  430. font-size: 23rpx;
  431. padding: 6rpx;
  432. font-weight: 400;
  433. }
  434. }
  435. .content-goods2 {
  436. background: #FFFFFF;
  437. border-radius: 23rpx;
  438. margin-top: 10rpx;
  439. padding: 20rpx;
  440. display: flex;
  441. }
  442. .goods-title {
  443. color: #141414;
  444. font-size: 26rpx;
  445. font-weight: 600;
  446. }
  447. .goods-desc {
  448. color: #646464;
  449. font-size: 21rpx;
  450. margin-top: 10rpx;
  451. }
  452. .goods-price {
  453. color: #FF9805;
  454. font-size: 34rpx;
  455. font-weight: 600;
  456. }
  457. .goods-score {
  458. color: $bg-color-primary;
  459. font-size: 27rpx;
  460. }
  461. .goods-info {
  462. color: #999999;
  463. font-size: 21rpx;
  464. }
  465. .goods-info3 {
  466. color: #999999;
  467. font-size: 21rpx;
  468. margin-left: 10rpx;
  469. text-decoration: line-through;
  470. }
  471. .goods-sales {
  472. background-color: #FEEFE5;
  473. color: #FF6702;
  474. border-radius: 8rpx;
  475. font-size: 21rpx;
  476. padding: 4rpx 20rpx;
  477. }
  478. .goods-labels {
  479. background-color: #FFF6F6;
  480. color: #FF4B4B;
  481. border: 2rpx solid #FF4B4B;
  482. border-radius: 8rpx;
  483. font-size: 21rpx;
  484. padding: 4rpx 16rpx;
  485. margin-right: 20rpx;
  486. }
  487. .active-option {
  488. color: $bg-color-primary !important;
  489. }
  490. </style>