<template> <view class="container flex-col" :style="{height: winHeight + 'px'}"> <!-- #ifdef MP --> <!-- 状态栏高度 --> <view :style="{ height: `${statusBarHeight}px` }"></view> <!-- 导航栏 --> <view class="navigationbar flex-center" :style="{ height: `${navigationBarHeight}px` }"> <view class="back-button" @tap="handBack()"></view> <navigator :url="`/pages/merchant_search/index?id=${takeoutId}`" class="input tui-skeleton-rect searchIpt flex-center" hover-class="none"><text class="iconfont icon-xiazai5"></text> 点击搜索外卖商家</navigator> </view> <!-- #endif --> <view class="box-merchant flex-col"> <view class="top-merchant"> <view class="flex-y-center"> <image style="width: 96rpx; height: 96rpx;border-radius: 6rpx;" :src="recommendObj.avatar"></image> <view style="margin-left: 20rpx; flex: 1;"> <view class="mer-name flex-between-center"> <view>{{recommendObj.name}}</view> <view class='iconfont icon-jiantou' style="font-size: 30rpx;" @tap="merchantTab(recommendObj)"></view> </view> <view class="flex-between-center" style="padding-right: 53rpx;"> <text class="mer-tj">今日推荐</text> <text class="goods-score">{{recommendObj.score}}</text> <text class="goods-info">销量{{recommendObj.salesVolume}}</text> <text v-if="!recommendObj.isfreeDeliverfee" class="goods-info" style="color: #E5AD21;margin-left: 18rpx;">免配送费</text> <view v-if="!recommendObj.isfreeDeliverfee && recommendObj.freeDeliverFee > 0" style="color: #999999;font-size: 21rpx;margin-left: 10rpx;text-decoration: line-through;">¥ {{recommendObj.freeDeliverFee}}</view> <text v-if="recommendObj.isfreeDeliverfee" style="color: #999999;font-size: 21rpx;margin-left: 10rpx;">配送费¥ {{recommendObj.distCosts}}</text> <text class="goods-info" style="margin-left: 10rpx;">{{recommendObj.distance}}</text> </view> </view> </view> <view class="flex-y-center" style="margin: 15rpx 0;"> <view class="cert-box" v-for="(item, index) in recommendObj.discountLabel" :key="index">{{item}}</view> </view> <scroll-view :scroll-x="true" scroll-with-animation style="white-space: nowrap;"> <view class="top-box-item" v-for="(item, index) in recommendObj.proList" :key="index"> <image style="width: 100%; height: 131rpx;border-radius: 10rpx;" :src="item.image"></image> <view class="name">{{item.name}}</view> <view style="padding-right: 23rpx"> <text style="color: #FF6702;">¥</text><text class="bg-color">{{item.price}}</text> <!-- <text class="goods-info" style="text-decoration: line-through;">¥6</text> --> </view> </view> </scroll-view> </view> <scroll-view :scroll-x="true" scroll-with-animation style="white-space: nowrap;margin: 20rpx 0rpx;"> <view :class="optionIndex == item.id ? 'active-option' : ''" style="color: #141414;display: inline-block;margin-right: 30rpx;width: 96rpx;" v-for="(item, index) in optionData" :key="index" @tap="onOptionClick(item)"> <view class="flex-col flex-center"> <image style="width: 100%;height: 96rpx;" :src="item.icon"></image> <view style="font-size: 21rpx;margin-top: 10rpx;">{{item.name}}</view> </view> </view> </scroll-view> <!-- 销量排行 --> <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> <view class="flex-center flex-col" v-if="noDataTip"> <image :src="urlDomain+'crmebimage/presets/noSearch.png'"></image> <text class="no-data-tip">{{noDataTip}}</text> </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 navBar from '@/components/navBar'; import { getMerchantList, getHomeInfo } from '@/api/home.js'; import { getTakeoutList, getProduct } from '@/api/takeout.js'; let app = getApp(); var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'rpx'; export default { components: { navBar }, data() { return { statusBarHeight: app.globalData.statusBarHeight, navigationBarHeight: 0, takeoutId: null, winHeight: 0, recommendObj: {}, optionData: [], optionIndex: 0, noDataTip: '', urlDomain: this.$Cache.get("imgHost"), labelList: [{ id: 1, label: "销量排行", checked: true }, { id: 2, label: "满减大促", checked: false }, { id: 3, label: "首单立减", checked: false }, { id: 4, label: "减配送费", checked: false }], merchantList: [], } }, onLoad(options) { let that = this; const custom = wx.getMenuButtonBoundingClientRect() // 导航栏高度(标题栏高度) = 胶囊高度 + (顶部距离 - 状态栏高度) * 2 that.navigationBarHeight = custom.height + (custom.top - that.statusBarHeight) * 2 that.takeoutId = options.id; uni.getSystemInfo({ success: function(res) { that.winHeight = res.windowHeight }, }); getProduct(that.takeoutId).then(res => { const data = res.data; // data[0].id = 0; data[0].name = '全部'; data[0].icon = '/static/img/quanbu.png'; that.optionIndex = data[0].id; that.optionData = data || [] that.getMatchedData() console.log(that.optionData, '12312321321312321321312312') }) getTakeoutList({ latitude: uni.getStorageSync('user_latitude'), longitude: uni.getStorageSync('user_longitude'), cateId: that.takeoutId }).then(recommendRes => { that.recommendObj = recommendRes.data console.log(that.recommendObj, '00000000000000000000000000') }) }, methods: { handBack() { uni.navigateBack({ delta: 1 }) }, goMerchant() { this.$util.navigateTo('/pages/merchant_search/index'); }, item2Click(item) { item.checked = !item.checked; }, getMatchedData() { getMerchantList({ latitude: uni.getStorageSync('user_latitude'), longitude: uni.getStorageSync('user_longitude'), cateId: this.optionIndex }).then(res => { this.merchantList = res.data.list; this.noDataTip = this.merchantList.length ? '' : ' 暂无外卖商家 '; console.log('商品信息:', this.merchantList); }); }, onOptionClick(item) { if (this.optionIndex === item.id) return this.optionIndex = item.id; this.getMatchedData() }, merchantTab(item) { // 修改跳转 uni.navigateTo({ url: `/pages/merchant/home/index?merId=${item.id}` // url: `/pages/goods_cate/index?id=${item.id}` }) }, } } </script> <style lang="scss" scoped> .searchIpt { width: 350rpx !important; height: 75%; background-color: #fff; border-radius: 35rpx; padding-left: 20rpx; justify-content: flex-start; } .no-data-tip { color: #CCC; } .container { overflow: hidden; position: relative; } .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; } } .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; } .box-merchant { background-color: #F5F5F5; border-radius: 30rpx 30rpx 0 0; padding: 20rpx 20rpx 0 20rpx; // margin-top: 30rpx; overflow: hidden; flex: 1; } .top-merchant { background-color: #fff; position: relative; padding: 20rpx; border-radius: 20rpx; .mer-name { font-weight: 600; font-size: 27rpx; color: #141414; margin-bottom: 10rpx; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .mer-tj { background: #FAFAFA; border-radius: 19rpx; font-weight: 400; font-size: 17rpx; color: #646464; padding: 6rpx 10rpx; } .cert-box { font-size: 21rpx; color: #FF6702; background: #FEEFE5; border-radius: 8rpx; padding: 4rpx 20rpx; margin-right: 10rpx; } .top-box-item { width: 173rpx; margin-right: 20rpx; display: inline-block; .name { font-weight: 400; font-size: 21rpx; color: #141414; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } } } .bg-color { color: $bg-color-primary; font-weight: 600; font-size: 31rpx; } .active-option { color: $bg-color-primary !important; } .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; } .back-button { width: 25rpx; height: 25rpx; border-right: 4rpx solid #fff; border-bottom: 4rpx solid #fff; transform: rotate(135deg); margin-left: 10rpx; display: inline-block; } .navigationbar { position: relative; background-color: $bg-color-primary; .back-button { position: absolute; left: 40rpx; } } </style>