小程序首页优化

This commit is contained in:
赵毅 2025-08-09 17:08:11 +08:00
parent 3f35b67705
commit 87a645078b
4 changed files with 896 additions and 42 deletions

View File

@ -1,5 +1,6 @@
export const apiArr = {
getCateList: "/api/v2/wechat/merchant-cate-crud/list", //小区房源列表
getCateList: "/api/v2/wechat/merchant-cate-crud/list", //商家分类列表
getMerchantList: "/api/v2/wechat/merchant-info-crud/page", //商家列表
getHomeBanner: "/api/v2/wechat/home-banner-region-crud/page", //获取首页banner及其广告
getButtonNum:"/api/v2/wechat/nav-display-crud/info",//获取首页button的行数 数量
getHomeButton:"/api/v2/wechat/home-button-region-crud/page", //获取首页button

View File

@ -95,13 +95,13 @@
class="merchangtItem_tag"
v-if="item.refund_property_fee_ratio"
>
买单物业费
买单物业费
</div>
<div
class="merchangtItem_tag"
v-if="item.refund_user_points_ratio"
>
买单积分
买单积分
</div>
</div>
<div class="merchantItem_right_con_right" @click="toJump(item)">

View File

@ -1,4 +1,3 @@
.container {
background-color: #f9f9f9;
}
@ -101,8 +100,8 @@ page {
}
.icon-box image {
width: 70rpx;
height: 70rpx;
width: 90rpx;
height: 90rpx;
}
.function-item text {
@ -204,6 +203,57 @@ page {
height: 100%;
}
/* 广告横幅 */
.serverList1 {
width: 100%;
height: 450rpx;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
background-color: #fff;
margin-top: 20rpx;
padding: 15rpx;
}
.serverList1_left {
display: block;
width: 330rpx;
height: 450rpx;
margin-right: 17rpx;
}
.serverList1_left image {
height: 450rpx;
width: 330rpx;
object-fit: cover;
border-radius: 20rpx;
}
.serverList1_right {
width: 400rpx;
height: 450rpx;
}
.serverItemRight1 {
width: 365rpx;
height: 220rpx;
}
.serverItemRight1 image {
border-radius: 20rpx;
}
.serverItemRight2 {
width: 365rpx;
height: 220rpx;
margin-top: 10rpx;
}
.serverItemRight2 image {
border-radius: 20rpx;
}
.Tit {
display: flex;
align-items: center;
@ -385,3 +435,372 @@ page {
margin: 65rpx auto;
text-align: center;
}
/* 分类标签栏样式 */
.category-tabs {
background-color: #fff;
border-radius: 10rpx;
margin-top: 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
overflow: hidden;
position: relative;
}
.tabs-container {
display: flex;
padding: 0 20rpx;
position: relative;
align-items: center;
}
.tabs-scroll {
height: 50rpx;
display: flex;
overflow-x: auto;
padding: 20rpx 0;
scrollbar-width: none;
-ms-overflow-style: none;
}
.tabs-scroll::-webkit-scrollbar {
display: none;
}
.tab-item {
padding: 0 20rpx;
margin-right: 20rpx;
font-size: 20rpx;
color: #333;
background-color: #ededed;
height: 50rpx;
line-height: 50rpx;
white-space: nowrap;
border-radius: 10rpx;
}
.tab-item.activeTab {
color: #ff6700;
background-color: #fff3e0;
}
.dropdown-btn {
width: 50rpx;
height: 50rpx;
display: flex;
align-items: center;
justify-content: center;
margin-left: 10rpx;
}
.dropdown-icon {
width: 50rpx;
height: 50rpx;
align-items: center;
transition: transform 0.3s ease;
}
.dropdown-icon.active {
transform: rotate(180deg);
}
/* 下拉分类列表样式 */
.category-dropdown {
background-color: #fff;
border-radius: 0 0 10rpx 10rpx;
box-shadow: 0 5rpx 15rpx rgba(0, 0, 0, 0.1);
padding: 20rpx;
/* position: absolute; */
z-index: 99;
width: 95%;
left: 0;
top: 88rpx;
}
.dropdown-title {
font-size: 28rpx;
font-weight: bold;
color: #333;
margin-bottom: 20rpx;
padding-bottom: 15rpx;
border-bottom: 1rpx solid #eee;
}
.review-btn {
width: 80rpx;
height: 50rpx;
background-color: #ff6700;
color: #fff;
font-size: 26rpx;
text-align: center;
line-height: 50rpx;
border-radius: 8rpx;
margin-right: 10rpx;
align-self: center;
}
.category-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 20rpx;
}
.category-grid-item {
padding: 20rpx;
text-align: center;
font-size: 24rpx;
color: #666;
background-color: #f5f5f5;
border-radius: 8rpx;
}
.category-grid-item.activeTab {
color: #ff6700;
background-color: #fff3e0;
font-weight: bold;
}
/* 店铺列表样式 */
.store-list-container {
background-color: #fff;
border-radius: 10rpx;
padding: 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
position: relative;
}
.overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 98;
}
.store-item {
display: flex;
padding: 20rpx 0;
border-bottom: 1rpx solid #f0f0f0;
}
.store-item:last-child {
border-bottom: none;
}
.store-image {
width: 180rpx;
height: 180rpx;
border-radius: 10rpx;
margin-right: 20rpx;
overflow: hidden;
}
.store-image image {
width: 100%;
height: 100%;
object-fit: cover;
}
.store-info {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.store-name {
font-size: 32rpx;
color: #333;
font-weight: bold;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.store-rating {
display: flex;
align-items: center;
margin: 10rpx 0;
}
.star-icon {
width: 24rpx;
height: 24rpx;
margin-right: 5rpx;
}
.rating-text {
font-size: 26rpx;
color: #ffb400;
margin-left: 5rpx;
}
.store-tags {
display: flex;
flex-wrap: wrap;
margin-bottom: 10rpx;
}
.tag {
background-color: #f5f5f5;
color: #666;
font-size: 24rpx;
padding: 5rpx 15rpx;
border-radius: 15rpx;
margin-right: 10rpx;
margin-bottom: 10rpx;
}
.store-address {
font-size: 26rpx;
color: #999;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
display: flex;
align-items: center;
}
.address-icon {
width: 24rpx;
height: 24rpx;
margin-right: 5rpx;
}
.store-distance {
font-size: 26rpx;
color: #999;
margin-top: 5rpx;
display: flex;
align-items: center;
}
.distance-icon {
width: 24rpx;
height: 24rpx;
margin-right: 5rpx;
}
.merchantList {
padding: 0 20rpx;
width: 100%;
box-sizing: border-box;
}
.merchantItem {
display: flex;
padding-top: 30px;
padding-bottom: 30rpx;
border-bottom: 1rpx solid #EBEBEB;
;
}
.merchantItem_left {
width: 180rpx;
height: 180rpx;
border-radius: 20rpx 20rpx 20rpx 20rpx;
overflow: hidden;
margin-right: 24rpx;
}
.merchantItem_left image {
width: 100%;
height: 100%;
}
.merchantItem_right {
flex: 1;
}
.merchantItem_right_tit {
display: flex;
align-items: center;
justify-content: space-between;
}
.merchantItem_right_tit_left {
font-size: 30rpx;
color: #222222;
}
.merchantItem_right_tit_right {
font-size: 24rpx;
color: #555555;
}
.merchantItem_right_con {
margin-top: 14rpx;
display: flex;
align-items: center;
justify-content: space-between;
}
.merchangtItem_tag {
font-size: 22rpx;
color: #555555;
padding: 5rpx 12rpx;
white-space: nowrap;
background: rgba(255, 81, 42, 0.1);
border-radius: 100rpx 100rpx 100rpx 100rpx;
display: inline-block;
margin-top: 20rpx;
margin-right: 10rpx;
}
.startList {
display: flex;
align-items: center;
}
.startList image {
width: 22rpx;
height: 22rpx;
margin-right: 3rpx;
}
.merchantItem_right_con_right {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: 26rpx;
color: #000000;
}
.merchantItem_right_con_right image {
width: 32rpx;
height: 28.59rpx;
margin-bottom: 6rpx;
}
.merchantItem_right_add {
font-size: 24rpx;
color: #999999;
margin-top: 14rpx;
}
/* 加载更多样式 */
.loading {
display: inline-block;
width: 30rpx;
height: 30rpx;
border: 3rpx solid #f3f3f3;
border-top: 3rpx solid #3498db;
border-radius: 50%;
animation: spin 1s linear infinite;
margin-right: 10rpx;
vertical-align: middle;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}

View File

@ -10,24 +10,23 @@
</view>
</view>
</view>
<!-- -->
<!-- 功能导航区 -->
<view class="function-nav">
<view class="function-item">
<view class="function-item" @click="goToShop">
<div class="icon-box">
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/Index_add.png" mode="widthFix" />
<image class="iconImg" src="http://localhost:8080/index_shop.png" mode="widthFix" />
</div>
<text>店铺管理</text>
</view>
<view class="function-item">
<view class="function-item" @click="goToOrder">
<div class="icon-box">
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/Index_add.png" mode="widthFix" />
<image class="iconImg" src="http://localhost:8080/index_order.png" mode="widthFix" />
</div>
<text>供应商订单</text>
</view>
<view class="function-item" @click="goToWuye">
<div class="icon-box">
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/Index_add.png" mode="widthFix" />
<image class="iconImg" src="http://localhost:8080/index_wuye.png" mode="widthFix" />
</div>
<text>物业管理</text>
</view>
@ -72,6 +71,20 @@
</view>
</view>
<!-- 广告横幅 -->
<view class="serverList1">
<view class="serverList1_left">
<!-- <image src="http://localhost:8080/index_ad_left.jpg" mode="aspectFit" /> -->
<image :src="serverLeft" mode="aspectFit" />
</view>
<view class="serverList1_right">
<view :class="['serverItemRight', `serverItemRight${index + 1}`]" @tap="headerServerClick(item)"
v-for="(item, index) in serverRightList" :key="index">
<image :src="item.pic_src" mode="" />
</view>
</view>
</view>
<view class="white_container margin_top20 padding_bottom32">
<view v-if="!currentCity.district" class="Tit">定位错误 未知区域</view>
<view v-else class="Tit">
@ -79,7 +92,6 @@
<view class="Tit_desc">公积金补贴商户</view>
</view>
<view class="serverList">
<view class="serverList_left">
<swiper>
<swiper-item v-for="(item, index) in homeLeftList" :key="index">
@ -88,8 +100,6 @@
</swiper>
</view>
<view class="serverList_right">
<view :class="['serverItem', `serverItem${index + 1}`]" @tap="headerServerClick(item)"
v-for="(item, index) in homeRightList" :key="index">
@ -98,13 +108,124 @@
</view>
</view>
</view>
<view class="merchant" @click="headershopEnterClick">商户申请入驻</view>
<!-- <view class="merchant" @click="headershopEnterClick">商户申请入驻</view> -->
</view>
<view class="white_container margin_top20 main padding_bottom32">
<!-- <view class="white_container margin_top20 main padding_bottom32">
<image v-for="(item, index) in bottomList" :key="index" class="list_pic" :src="item.pic_src" mode="">
</image>
</view> -->
<!-- 分类标签栏 -->
<view class="category-tabs">
<view class="tabs-container">
<scroll-view scroll-x enable-flex class="tabs-scroll" :scroll-into-view="activeCategoryId">
<view class="tab-item" v-for="item in categoryList1" :key="item.id" :id="'category-' + item.id"
:class="{ activeTab: currentCategoryId === item.id }" @click="switchCategory(item.id)">
{{ item.cate_name }}
</view>
</scroll-view>
<view class="dropdown-btn" :class="{ active: showDropdown }" @click="toggleDropdown">
<u-icon v-if="!showDropdown" name="arrow-down" class="dropdown-icon"></u-icon>
<u-icon v-else name="arrow-up" class="dropdown-icon active"></u-icon>
</view>
</view>
<!-- 分类下拉列表 -->
<view class="category-dropdown" v-if="showDropdown">
<view class="dropdown-title">商品分类</view>
<view class="category-grid">
<view class="category-grid-item" v-for="item in categoryList" :key="item.id"
:class="{ activeTab: currentCategoryId === item.id }" @click="selectCategoryFromDropdown(item.id)">
{{ item.cate_name }}
</view>
</view>
</view>
<!-- 商家列表展示 -->
<!-- <view class="store-list-container">
<view class="overlay" v-if="showDropdown"></view>
<view class="store-item" v-for="(store, index) in merchantList" :key="index">
<view class="store-image">
<image :src="store.cate_image" mode="aspectFill"></image>
</view>
<view class="store-info">
<view class="store-name">{{ store.merchant_name }}</view>
<view class="startList">
<image
v-for="index in 5"
:key="index"
:src="
index < item.rating
? 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/local_start1.png'
: 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/local_start2.png'
"
mode="aspectFill"
></image>
</view>
<view class="store-tags">
<text class="tag" v-for="(tag, idx) in store.tags" :key="idx">{{ tag }}</text>
</view>
<view class="store-address">
<image class="address-icon"
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/address.png"
mode="aspectFit">
</image>
<text>{{ store.address }}</text>
</view>
<view class="store-distance">
<image class="distance-icon"
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/distance.png"
mode="aspectFit">
</image>
<text>{{ store.distance }}km</text>
</view>
</view>
<view class="review-btn" @click="gotoReview(store.id)">点评</view>
</view>
</view> -->
<div class="merchantList">
<div class="merchantItem" v-for="item in merchatList" :key="item.id" @click="Info(item)">
<div class="merchantItem_left">
<image :src="item.showImg" mode="aspectFill"></image>
</div>
<div class="merchantItem_right">
<div class="merchantItem_right_tit">
<div class="merchantItem_right_tit_left">
{{ item.merchant_name }}
</div>
<div class="merchantItem_right_tit_right">
{{ item.distances }}
</div>
</div>
<div class="merchantItem_right_con">
<div class="merchantItem_right_con_left">
<div class="startList">
<image v-for="index in 5" :key="index" :src="index < item.rating
? 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/local_start1.png'
: 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/local_start2.png'
" mode="aspectFill"></image>
</div>
<div class="merchangtItem_tag" v-if="item.refund_property_fee_ratio">
买单返物业费
</div>
<div class="merchangtItem_tag" v-if="item.refund_user_points_ratio">
买单返积分
</div>
</div>
<div class="merchantItem_right_con_right" @click="toJump(item)">
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/local_review.png"
mode="aspectFill"></image>
点评
</div>
</div>
<div class="merchantItem_right_add">
{{ item.comAddress }}
</div>
</div>
</div>
</div>
</view>
<view class="more" v-if="flag">下拉加载后续10条共计{{ bottomTotal }}</view>
<nav-footer />
</view>
@ -114,7 +235,8 @@
<script>
import {
NavgateTo
NavgateTo,
calculateDistance,
} from '../../utils/index';
import {
@ -179,10 +301,50 @@ export default {
scrollPosition: 0, //
scrollInterval: null, //
itemHeight: 40, //
// 1广
serverLeft: '',
// 1广
serverRightList: [],
//
categoryList1: [],
categoryList: [],
currentCategoryId: null,
showDropdown: false,
activeCategoryId: '',
merchatList: [], //
}
},
methods: {
goToShop() {
uni.showModal({
title: '提示',
content: '此功能暂未开通!',
showCancel: false,
complete: (res) => {
if (res.cancel) {
}
}
})
},
goToOrder() {
uni.showModal({
title: '提示',
content: '此功能暂未开通!',
showCancel: false,
complete: (res) => {
if (res.cancel) {
}
}
})
},
goToWuye() {
uni.navigateTo({
@ -294,19 +456,38 @@ export default {
uni.setStorageSync('location', preciseLocation);
uni.setStorageSync('ad_code', ad_info.adcode);
// TODO: ad_code
const [bannerList, homeLeftList, homeRightList, bottomList, buttonList] = await Promise.all([
const [bannerList, serverLeft, serverRightList, homeLeftList, homeRightList, bottomList, buttonList, categoryList] = await Promise.all([
this.getHomeBanner(),//
this.getServerLeft(), // 1广
this.getServerRight(), // 1广
this.getHomeMidLeft(), //
this.getHomeMidRight(), //
this.getHomeMidRight(), //
// this.getHomeCenterTop(), // -
// this.getHomeCenter(), // -
// this.getHomeCenterBottom(), // -
// this.getHomeRightTop(), // -
// this.getHomeRightCenter(), // -
// this.getHomeRightBottom(), // -
// this.getHomePop()
this.getHomeBottom(true), // 广
this.getButtonNum(), //
this.getCateList(), //
]);
this.bannerList = bannerList;
this.serverLeft = serverLeft;
this.serverRightList = serverRightList;
this.homeLeftList = homeLeftList;
this.homeRightList = homeRightList;
that.bottomList = bottomList;
this.tabList = buttonList;
this.categoryList = categoryList;
this.categoryList1 = categoryList.slice(0, 5);
this.loading = true;
uni.hideLoading();
},
@ -422,7 +603,7 @@ export default {
}
},
async getHomeMidLeft() {
async getServerLeft() {
const res = await request(apiArr2.getHomeBanner, "POST", {
ad_code: uni.getStorageSync('ad_code'),
ad_position: 2,
@ -431,6 +612,50 @@ export default {
page_num: 1,
page_size: 10
}, { silent: false });
if (res.rows.length) {
let filterRes = this.filterShowList(res?.rows, 1);
filterRes.forEach(item => {
item.pic_src = picUrl + item.pic_src
})
const itemUrl = filterRes[0].pic_src
return itemUrl
} else {
return []
}
},
async getServerRight() {
const rightList = []
for (let i = 4; i < 6; i++) {
const res = await request(apiArr2.getHomeBanner, "POST", {
ad_code: uni.getStorageSync('ad_code'),
ad_position: i,
longitude: uni.getStorageSync('location').lng,
latitude: uni.getStorageSync('location').lat,
page_num: 1,
page_size: 10
}, { silent: false });
if (res.rows.length) {
let filterRes = this.filterShowList(res?.rows, 1);
filterRes.forEach(item => {
item.pic_src = picUrl + item.pic_src
})
rightList.push(...filterRes)
}
}
return rightList
},
async getHomeMidLeft() {
const res = await request(apiArr2.getHomeBanner, "POST", {
ad_code: uni.getStorageSync('ad_code'),
ad_position: 5,
longitude: uni.getStorageSync('location').lng,
latitude: uni.getStorageSync('location').lat,
page_num: 1,
page_size: 10
}, { silent: false });
if (res.rows.length) {
let filterRes = this.filterShowList(res?.rows, 1);
filterRes.forEach(item => {
@ -443,9 +668,11 @@ export default {
},
async getHomeMidRight() {
const rightList = []
for (let i = 6; i < 12; i++) {
const res = await request(apiArr2.getHomeBanner, "POST", {
ad_code: uni.getStorageSync('ad_code'),
ad_position: 3,
ad_position: i,
longitude: uni.getStorageSync('location').lng,
latitude: uni.getStorageSync('location').lat,
page_num: 1,
@ -456,17 +683,137 @@ export default {
filterRes.forEach(item => {
item.pic_src = picUrl + item.pic_src
})
return filterRes.slice(0, 6)
} else {
return []
rightList.push(...filterRes)
}
}
return rightList
},
// async getHomeCenterTop() {
// const res = await request(apiArr2.getHomeBanner, "POST", {
// ad_code: uni.getStorageSync('ad_code'),
// ad_position: 6,
// longitude: uni.getStorageSync('location').lng,
// latitude: uni.getStorageSync('location').lat,
// page_num: 1,
// page_size: 10
// }, { silent: false });
// if (res.rows.length) {
// let filterRes = this.filterShowList(res?.rows, 1);
// filterRes.forEach(item => {
// item.pic_src = picUrl + item.pic_src
// })
// return filterRes.slice(0, 6)
// } else {
// return []
// }
// },
// async getHomeCenter() {
// const res = await request(apiArr2.getHomeBanner, "POST", {
// ad_code: uni.getStorageSync('ad_code'),
// ad_position: 7,
// longitude: uni.getStorageSync('location').lng,
// latitude: uni.getStorageSync('location').lat,
// page_num: 1,
// page_size: 10
// }, { silent: false });
// if (res.rows.length) {
// let filterRes = this.filterShowList(res?.rows, 1);
// filterRes.forEach(item => {
// item.pic_src = picUrl + item.pic_src
// })
// return filterRes.slice(0, 6)
// } else {
// return []
// }
// },
// async getHomeCenterBottom() {
// const res = await request(apiArr2.getHomeBanner, "POST", {
// ad_code: uni.getStorageSync('ad_code'),
// ad_position: 8,
// longitude: uni.getStorageSync('location').lng,
// latitude: uni.getStorageSync('location').lat,
// page_num: 1,
// page_size: 10
// }, { silent: false });
// if (res.rows.length) {
// let filterRes = this.filterShowList(res?.rows, 1);
// filterRes.forEach(item => {
// item.pic_src = picUrl + item.pic_src
// })
// return filterRes.slice(0, 6)
// } else {
// return []
// }
// },
// async getHomeRightTop() {
// const res = await request(apiArr2.getHomeBanner, "POST", {
// ad_code: uni.getStorageSync('ad_code'),
// ad_position: 9,
// longitude: uni.getStorageSync('location').lng,
// latitude: uni.getStorageSync('location').lat,
// page_num: 1,
// page_size: 10
// }, { silent: false });
// if (res.rows.length) {
// let filterRes = this.filterShowList(res?.rows, 1);
// filterRes.forEach(item => {
// item.pic_src = picUrl + item.pic_src
// })
// return filterRes.slice(0, 6)
// } else {
// return []
// }
// },
// async getHomeRightCenter() {
// const res = await request(apiArr2.getHomeBanner, "POST", {
// ad_code: uni.getStorageSync('ad_code'),
// ad_position: 10,
// longitude: uni.getStorageSync('location').lng,
// latitude: uni.getStorageSync('location').lat,
// page_num: 1,
// page_size: 10
// }, { silent: false });
// if (res.rows.length) {
// let filterRes = this.filterShowList(res?.rows, 1);
// filterRes.forEach(item => {
// item.pic_src = picUrl + item.pic_src
// })
// return filterRes.slice(0, 6)
// } else {
// return []
// }
// },
// async getHomeRightBottom() {
// const res = await request(apiArr2.getHomeBanner, "POST", {
// ad_code: uni.getStorageSync('ad_code'),
// ad_position: 11,
// longitude: uni.getStorageSync('location').lng,
// latitude: uni.getStorageSync('location').lat,
// page_num: 1,
// page_size: 10
// }, { silent: false });
// if (res.rows.length) {
// let filterRes = this.filterShowList(res?.rows, 1);
// filterRes.forEach(item => {
// item.pic_src = picUrl + item.pic_src
// })
// return filterRes.slice(0, 6)
// } else {
// return []
// }
// },
//
async getHomePop() {
await request(apiArr2.getHomeBanner, "POST", {
ad_code: uni.getStorageSync('ad_code'),
ad_position: 4,
ad_position: 12,
longitude: uni.getStorageSync('location').lng,
latitude: uni.getStorageSync('location').lat,
page_num: 1,
@ -503,8 +850,6 @@ export default {
return filterRes
},
async getButtonNum() {
const res = await request(apiArr2.getButtonNum, "POST", {}, { slice: false });
this.rowNum = res.nav_row_num
@ -533,6 +878,80 @@ export default {
}
},
//
async getCateList() {
const res = await request(apiArr2.getCateList, "POST", {
}, { slice: false });
if (res.rows.length) {
this.currentCategoryId = res.rows[0].id
this.activeCategoryId = `category-${this.currentCategoryId}`
this.getMechantList()
return res.rows
} else {
return []
}
},
//
async getMechantList() {
let that = this;
await request(apiArr2.getMerchantList, "POST", {
merchant_cate_id: that.currentCategoryId,
page_num: that.page_num,
page_size: that.page_size,
}).then((res) => {
let latitude = uni.getStorageSync("location").lat;
let longitude = uni.getStorageSync("location").lng;
res.rows.forEach((item) => {
item.bigImg = item.album_images.split(",");
item.showImg = picUrl + item.album_images.split(",")[0];
const distanceInKm = calculateDistance(
latitude,
longitude,
item.latitude,
item.longitude
);
item.distances =
distanceInKm >= 1
? `${distanceInKm.toFixed(1)}km`
: `${(distanceInKm * 1000).toFixed(1)}m`;
if (item.ad) {
item.comAddress = item.ad.ad_name.replace(/,/g, "") + item.address;
} else {
item.comAddress = item.address;
}
});
res.rows.sort((a, b) => {
const valueA =
parseFloat(a.distances.replace("km", "").replace("m", "")) *
(a.distances.includes("km") ? 1000 : 1);
const valueB =
parseFloat(b.distances.replace("km", "").replace("m", "")) *
(b.distances.includes("km") ? 1000 : 1);
return valueA - valueB;
});
if (res.rows.length == this.page_size) {
this.page_num = this.page_num + 1;
this.flag = true;
} else {
this.flag = false;
}
this.merchatList = res.rows;
});
},
//
Info(e) {
uni.setStorageSync("merchantInfo", e);
NavgateTo("/packages/localLife/detail/index");
},
//
toJump(e){
NavgateTo('/packages/localLife/comment/index');
},
/**
* 首页过滤方法
* @param {Array} list 请求地址
@ -553,9 +972,24 @@ export default {
const res = await request(apiArr.hotWord, "POST", {}, { slice: false });
//
this.hotWord = res.search_hot_word.split(/[,]/)
console.log("🚀 ~ getSearchVal ~ res:", this.hotWord)
}
},
switchCategory(id) {
this.currentCategoryId = id;
this.activeCategoryId = `category-${id}`;
this.getMechantList()
this.showDropdown = false;
},
toggleDropdown() {
this.showDropdown = !this.showDropdown;
},
selectCategoryFromDropdown(id) {
this.switchCategory(id);
this.showDropdown = false;
}
},
onLoad(options) {
this.init()