123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425 |
- <template>
- <view class="container flex-col" :style="{height: winHeight + 'px'}">
- <!-- #ifdef MP -->
- <view class="cart_nav">
- <nav-bar iconColor='#fff' ref="navBarRef" navTitle="美食" backgroundColor="#FF6702" :isBackgroundColor="false">
- </nav-bar>
- </view>
- <!-- #endif -->
- <view class='search-box acea-row row-between-wrapper'>
- <view class="flex-y-center">
- <text class='iconfont icon-sousuo2'></text>
- <input type='text' confirm-type='search' name="search" placeholder='点击搜索外卖商家' placeholder-class='placeholder'
- maxlength="20" @tap="goMerchant"></input>
- </view>
- </view>
- <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>
- <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 {
- takeoutId: null,
- winHeight: 0,
- recommendObj: {},
- optionData: [],
- optionIndex: 0,
- 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;
- 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 = 0;
- that.optionData = data || []
- console.log(that.optionData, '12312321321312321321312312')
- })
- that.getMatchedData()
- getTakeoutList({
- latitude: uni.getStorageSync('user_latitude'),
- longitude: uni.getStorageSync('user_longitude'),
- cateId: that.optionIndex
- }).then(recommendRes => {
- that.recommendObj = recommendRes.data
- console.log(that.recommendObj, '00000000000000000000000000')
- })
- },
- methods: {
- 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;
- console.log('商品信息:', this.merchantList);
- });
- },
- onOptionClick(item) {
- if (this.optionIndex === item.id) return
- this.optionIndex = item.id;
- getMatchedData()
- },
- merchantTab(item) {
- let opitem = JSON.stringify(item)
- let cid = item.cid
- uni.setStorageSync('merId', JSON.parse(JSON.stringify(item.id)))
- // 修改跳转
- uni.navigateTo({
- url: '/pages/merchant/home/index'
- // url: `/pages/goods_cate/index?id=${item.id}`
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .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;
- }
- </style>
|