123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446 |
- <template>
- <view class="container flex-col" :data-theme="theme" :style="{height: winHeight + 'px'}">
- <!-- #ifdef MP -->
- <view class="cart_nav">
- <nav-bar iconColor='#fff' ref="navBarRef" :navTitle="navTitle" backgroundColor="#FF6702" :isBackgroundColor="false">
- </nav-bar>
- </view>
- <!-- #endif -->
- <view class='searchGood'>
- <view class='search-box acea-row row-between-wrapper'>
- <view class="flex-y-center">
- <text class='iconfont icon-sousuo2'></text>
- <input type='text' :value='searchValue' :focus="focus" placeholder='点击搜索外卖商家' confirm-type='search' @confirm="searchBut"
- placeholder-class='placeholder' @input="setValue" maxlength="20"></input>
- <view class='bnt flex-center' @tap='searchBut'>搜索</view>
- </view>
- </view>
- <!-- #ifdef MP -->
- <view class='title'>热门搜索</view>
- <!-- #endif -->
- <!-- #ifndef MP -->
- <view class='title'>热门搜索</view>
- <!-- #endif -->
- <view class='list acea-row'>
- <block v-for="(item,index) in hotSearchList" :key="index">
- <view class='item' @tap='setHotSearchValue(item.title)'>{{item.title}}</view>
- </block>
- </view>
- <view class='line'></view>
- </view>
- <view style="padding: 0 20rpx;flex: 1;overflow: hidden;" class="flex-col">
- <!-- 销量排行 -->
- <view class="tab-list" style="margin-top: 10rpx;">
- <view :class=" item.checked ? 'tab-item2' : 'tab-item2-false' " v-for="item in labelList" :key="item.id" @click="item2Click(item)">{{item.label}}</view>
- </view>
- <scroll-view scroll-y scroll-with-animation style="flex: 1;overflow: hidden;">
- <view class="content-goods2" v-for="item in merchantList" :key="item.id" @click="merchantTab(item)">
- <view>
- <image :src="item.avatar" style="width: 230rpx;height: 230rpx;"></image>
- </view>
- <view style="margin-left: 20rpx;flex: 1;">
- <view class="">
- <text class="goods-title">{{item.name}}</text>
- </view>
- <view style="margin-top: 10rpx;">
- <text class="goods-score">{{item.score}}</text>
- <text class="goods-info" style="margin-left: 10rpx;">月销 {{item.salesVolume}}</text>
- <text class="goods-info" style="margin-left: 25rpx;">人均 ¥ {{item.perCapita}}</text>
- </view>
- <view style="margin-top: 10rpx;display: flex;align-items: center;">
- <text class="goods-info">起送 ¥ {{item.perCapita}}</text>
- <text v-if="!item.isfreeDeliverfee" class="goods-info" style="color: #E5AD21;margin-left: 18rpx;">免配送费</text>
- <view v-if="!item.isfreeDeliverfee && item.freeDeliverFee > 0" style="color: #999999;font-size: 21rpx;margin-left: 10rpx;text-decoration: line-through;">¥
- {{item.freeDeliverFee}}</view>
- <text v-if="item.isfreeDeliverfee" style="color: #999999;font-size: 21rpx;margin-left: 10rpx;">配送费¥
- {{item.distCosts}}</text>
- <text class="goods-info" style="margin-left: 38rpx;">10分钟</text>
- <text class="goods-info" style="margin-left: 10rpx;">{{item.distance}}</text>
- </view>
- <view style="margin-top: 22rpx;"><text class="goods-sales">已售卖{{item.salesVolume}}件</text></view>
- <view style="margin-top: 14rpx;">
- <text class="goods-labels" v-for="(item2,index2) in item.discountLabel" :key="index2">{{item2}}</text>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- </template>
- <script>
- // +----------------------------------------------------------------------
- // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
- // +----------------------------------------------------------------------
- // | Author: CRMEB Team <admin@crmeb.com>
- // +----------------------------------------------------------------------
- import {
- getSearchKeyword,
- } from '@/api/product.js';
- // #ifdef MP
- import navBar from '@/components/navBar';
- // #endif
- import {
- getMerchantList,
- getHomeInfo
- } from '@/api/home.js';
- let app = getApp();
- export default {
- components: {
- // #ifdef MP
- navBar
- // #endif
- },
- data() {
- return {
- winHeight: 0,
- navTitle: '搜索外卖商家',
- hostProduct: [],
- searchValue: '',
- focus: false,
- bastList: [],
- hotSearchList: [],
- theme: app.globalData.theme,
- labelList: [{
- id: 1,
- label: "销量排行",
- checked: true
- }, {
- id: 2,
- label: "满减大促",
- checked: false
- }, {
- id: 3,
- label: "首单立减",
- checked: false
- }, {
- id: 4,
- label: "减配送费",
- checked: false
- }],
- merchantList: [],
- cateId: 0
- };
- },
- // 滚动监听
- onPageScroll(e) {
- // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
- uni.$emit('scroll');
- },
- onShow: function() {
- this.getRoutineHotSearch();
- },
- onLoad(e) {
- let that = this
- uni.getSystemInfo({
- success: function(res) {
- that.winHeight = res.windowHeight
- },
- });
- if (e.searchVal) that.searchValue = e.searchVal;
- e.navTitle ? that.navTitle = e.navTitle : ''
- e.cateId ? that.cateId = e.cateId : ''
- that.getMatchedData()
- },
- methods: {
- getMatchedData() {
- getMerchantList({
- latitude: uni.getStorageSync('user_latitude'),
- longitude: uni.getStorageSync('user_longitude'),
- cateId: this.cateId
- }).then(res => {
- // this.merchantList = res.data.list;
- this.merchantList.push(res.data.list[0])
- this.merchantList.push(res.data.list[0])
- this.merchantList.push(res.data.list[0])
- this.merchantList.push(res.data.list[0])
- this.merchantList.push(res.data.list[0])
- this.merchantList.push(res.data.list[0])
- this.merchantList.push(res.data.list[0])
- this.merchantList.push(res.data.list[0])
- console.log('商品信息:', this.merchantList);
- });
- },
- getRoutineHotSearch: function() {
- let that = this;
- getSearchKeyword().then(res => {
- that.$set(that, 'hotSearchList', res.data);
- });
- },
- setHotSearchValue: function(event) {
- this.$set(this, 'searchValue', event);
- this.page = 1;
- this.$set(this, 'bastList', []);
- this.getMatchedData()
- // uni.navigateTo({
- // url: `/pages/goods/goods_list/index?searchValue=${this.searchValue}`
- // })
- },
- setValue: function(event) {
- this.$set(this, 'searchValue', event.detail.value);
- },
- searchBut: function(e) {
- let that = this;
- let val = '';
- that.focus = false;
- if (e.detail.value) {
- val = e.detail.value
- }
- if (that.searchValue.length > 0 || val) {
- this.getMatchedData()
- // uni.navigateTo({
- // url: `/pages/goods/goods_list/index?searchValue=${val?val:that.searchValue}`
- // })
- } else {
- return this.$util.Tips({
- title: '请输入要搜索的商品',
- icon: 'none',
- duration: 1000,
- mask: true,
- });
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- overflow: hidden;
- position: relative;
- }
- page {
- background-color: #f5f5f5 !important;
- }
- .searchGood .search {
- padding-left: 30rpx;
- background-color: #fff !important;
- }
- .searchGood .search {
- /* #ifndef MP */
- padding-top: 20rpx;
- padding-bottom: 20rpx;
- /* #endif */
- /* #ifdef MP */
- position: fixed;
- width: 100%;
- z-index: 9999;
- top: 0;
- /* #endif */
- }
- .searchGood .search .input {
- width: 598rpx;
- background-color: #f7f7f7;
- border-radius: 33rpx;
- padding: 0 35rpx;
- box-sizing: border-box;
- height: 66rpx;
- }
- .searchGood .search .input input {
- width: 472rpx;
- font-size: 26rpx;
- }
- .searchGood .search .input .placeholder {
- color: #bbb;
- }
- .searchGood .search .input .iconfont {
- color: #000;
- font-size: 35rpx;
- }
- .searchGood .search .bnt {
- width: 120rpx;
- text-align: center;
- height: 66rpx;
- line-height: 66rpx;
- font-size: 30rpx;
- color: #282828;
- }
- .searchGood .title {
- font-weight: 500;
- font-family: PingFang SC, PingFang SC;
- font-size: 28rpx;
- color: #333;
- margin: 50rpx 30rpx 25rpx 30rpx;
- }
- .searchGood .list {
- padding-left: 10rpx;
- }
- .searchGood .list .item {
- font-size: 26rpx;
- color: #454545;
- padding: 0 21rpx;
- height: 60rpx;
- border-radius: 30rpx;
- line-height: 60rpx;
- border: 1rpx solid #aaa;
- margin: 0 0 20rpx 20rpx;
- }
- .searchGood .line {
- margin: 20rpx 30rpx 0 30rpx;
- }
- .searchBox {
- width: 100%;
- }
- .search-box {
- background-color: #fff;
- padding: 0 39rpx;
- margin-top: 10rpx;
- box-sizing: border-box;
- height: 96rpx;
- .flex-y-center {
- width: 100%;
- height: 69rpx;
- padding-left: 29rpx;
- border-radius: 35rpx;
- border: 2rpx solid #FF6702;
- }
- .bnt {
- background: #FF6702;
- border-radius: 35rpx;
- width: 115rpx;
- height: 100%;
- font-weight: 500;
- font-size: 35rpx;
- color: #FFFFFF;
- }
- }
- .icon-fanhui2 {
- // line-height: 66rpx;
- }
- .search-box input {
- width: 90%;
- font-size: 26rpx;
- }
- .search-box .placeholder {
- color: #bbb;
- }
- .search-box .iconfont {
- color: #000;
- font-size: 35rpx;
- }
- .tab-list {
- display: flex;
- /* 启用弹性布局 */
- flex-direction: row;
- /* 横向排列 */
- justify-content: space-between;
- /* 均匀分布子项 */
- flex-wrap: wrap;
- /* 允许换行(适用于屏幕宽度不足时) */
- .tab-item2 {
- width: 23%;
- /* 5个元素平分宽度,留2%作为间隙 */
- text-align: center;
- background-color: #FFC127;
- border-radius: 8rpx;
- font-size: 23rpx;
- padding: 6rpx;
- font-weight: 400;
- }
- .tab-item2-false {
- width: 23%;
- /* 5个元素平分宽度,留2%作为间隙 */
- text-align: center;
- background-color: #fff;
- border-radius: 8rpx;
- font-size: 23rpx;
- padding: 6rpx;
- font-weight: 400;
- }
- }
- .content-goods2 {
- background: #FFFFFF;
- border-radius: 23rpx;
- margin-top: 10rpx;
- padding: 20rpx;
- display: flex;
- }
- .goods-title {
- color: #141414;
- font-size: 26rpx;
- font-weight: 600;
- }
- .goods-desc {
- color: #646464;
- font-size: 21rpx;
- margin-top: 10rpx;
- }
- .goods-price {
- color: #FF9805;
- font-size: 34rpx;
- font-weight: 600;
- }
- .goods-score {
- color: $bg-color-primary;
- font-size: 27rpx;
- }
- .goods-info {
- color: #999999;
- font-size: 21rpx;
- }
- .goods-info3 {
- color: #999999;
- font-size: 21rpx;
- margin-left: 10rpx;
- text-decoration: line-through;
- }
- .goods-sales {
- background-color: #FEEFE5;
- color: #FF6702;
- border-radius: 8rpx;
- font-size: 21rpx;
- padding: 4rpx 20rpx;
- }
- .goods-labels {
- background-color: #FFF6F6;
- color: #FF4B4B;
- border: 2rpx solid #FF4B4B;
- border-radius: 8rpx;
- font-size: 21rpx;
- padding: 4rpx 16rpx;
- margin-right: 20rpx;
- }
- </style>
|