本地商家添加商品搜索

This commit is contained in:
wangxiaowei 2024-10-08 17:40:59 +08:00
parent 44d3ea99e3
commit 9f153d3704

@ -1,7 +1,25 @@
<template>
<mescroll-uni ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
:down="downOption" :up="upOption">
<mescroll-uni ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption"
:up="upOption">
<view class="content">
<u-sticky offset-top="0" h5-nav-height="0" bg-color="transparent">
<view class="index-bg" style="background-color: #fff; box-shadow: 0px 3px 10px rgb(202 198 198 / 50%)">
<u-navbar :is-fixed="false" :border-bottom="false" :background="{ background: 'transparent', }"
:is-back="true">
<view class="flex-1 flex row" style="position: relative;">
<view class="flex-1">
<view class="flex row">
<u-search wrap-bg-color="transparent" :hideRight="true" :show-action="true"
action-text="取消" :animation="true"
@focus="hideRight=false" @blur="hideRight=true" @custom="handleCancel"
placeholder="搜索商品名称" height="64" @search="search" v-model="keyword"></u-search>
</view>
</view>
</view>
</u-navbar>
</view>
</u-sticky>
<view class="info">
<view class="head flex">
<u-image :src="info.shopLogo" :width="width" :height="width" :border-radius="10"></u-image>
@ -17,13 +35,13 @@
</view>
</view>
<view class="distance">
<u-icon name="map" size="32" class="m-r-10"></u-icon>
<u-icon name="map" size="32" class="m-r-10"></u-icon>
<text>{{info.distance}}</text>
</view>
</view>
</view>
<view class="info m-t-20 flex row-between">
<view class="info m-t-20 flex row-between" v-if="info.show_bill">
<view>
<view class="bold">买单</view>
<view class="tips m-t-10">手机买单更便捷</view>
@ -36,20 +54,22 @@
</router-link>
</view>
</view>
<view class="list">
<view class="list-block m-t-20" v-for="(item, index) in list" :key="index" style="width: 346rpx;height: 100%;">
<router-link :to="{path: '/bundle_b/pages/local_shop/local_shop_buy', query: {id: item.id, lstore_id: item.lstore_id}}">
<view class="list-block m-t-20" v-for="(item, index) in list" :key="index"
style="width: 346rpx;height: 100%;">
<router-link
:to="{path: '/bundle_b/pages/local_shop/local_shop_buy', query: {id: item.id, lstore_id: item.lstore_id}}">
<view class="goods-image">
<u-image :width="shopWidth" :height="shopWidth" :border-radius="10" :src="item.pic[0].url"></u-image>
<u-image :width="shopWidth" :height="shopWidth" :border-radius="10"
:src="item.pic[0].url"></u-image>
</view>
<view class="shop-name line-1">
{{item.title}}
</view>
<view class="p-l-10 p-t-10 p-b-10">
<price-format :color="colorConfig.primary" class="m-r-10" :first-size="34" :second-size="26"
:subscript-size="26" :price="item.price"
:weight="500"></price-format>
:subscript-size="26" :price="item.price" :weight="500"></price-format>
</view>
</router-link>
</view>
@ -71,7 +91,7 @@
import {
getLocalGoodsList
} from '@/api/store.js';
export default {
mixins: [MescrollMixin],
data() {
@ -79,7 +99,7 @@
width: '160rpx',
id: 0,
info: [],
list:[],
list: [],
upOption: {
empty: {
icon: 'https://zjeloong.oss-cn-hangzhou.aliyuncs.com/uniapp/order_null.png',
@ -87,7 +107,9 @@
fixed: false
}
},
shopWidth: '346rpx'
shopWidth: '346rpx',
keyword: '',
background: 'transparent'
}
},
async onLoad(options) {
@ -97,35 +119,46 @@
methods: {
...mapActions(['initLocationFunc']),
...mapMutations(['setCityInfo']),
handleCancel() {
this.keyword = '';
this.mescroll.resetUpScroll()
},
// 位置
async reLocationFunc() {
await this.initLocationFunc();
},
// 获取商家详情
async getLocalShopByIdFunc() {
getLocalShopById({id: this.id, longitude: this.cityInfo.gcj02_lng, latitude: this.cityInfo.gcj02_lat, type: 1}).then((res) => {
getLocalShopById({
id: this.id,
longitude: this.cityInfo.gcj02_lng,
latitude: this.cityInfo.gcj02_lat,
type: 1
}).then((res) => {
if (res.code == 1) {
this.info = res.data
}
})
},
callPhone(phone) {
uni.makePhoneCall({
phoneNumber: phone
});
},
upCallback(page) {
let pageNum = page.num; // 页码, 默认从1开始
let pageSize = page.size; // 页长, 默认每页10条
getLocalGoodsList({
keyword: this.keyword,
page_size: pageSize,
page_no: pageNum,
type: 1, // 上架中的产品
lstore_id: this.id
lstore_id: this.id
}).then(({
data
}) => {
@ -136,6 +169,10 @@
this.list = this.list.concat(curPageData);
this.mescroll.endSuccess(curPageLen, hasNext);
})
},
search() {
this.mescroll.resetUpScroll()
}
},
computed: {
@ -155,33 +192,33 @@
padding: 20rpx;
background-color: #fff;
border-radius: 20rpx;
.name {
width: calc(10%% - 180rpx);
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.address {
width: calc(10%% - 50rpx);
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.distance {
margin-top: 20rpx;
font-size: 24rpx;
color: #a5a5a5;
}
.tips {
font-size: 24rpx;
color: #929191;
}
}
.list {
display: flex;
flex-wrap: wrap;
@ -190,29 +227,29 @@
align-items: stretch;
margin-top: 20rpx;
padding: 0 20rpx 20rpx 20rpx;
.list-block {
background-color: #fff;
.shop-name {
padding: 20rpx 0 2rpx 10rpx;
}
}
.info {
background-color: #fff;
padding: 0 20rpx;
margin-bottom: 20rpx;
.info-header {
padding: 20rpx 0;
}
.shop-info {
width: 100%;
overflow: hidden;
margin-left: 16rpx;
.address {
margin-top: 8rpx;
overflow: hidden;
@ -220,7 +257,7 @@
white-space: nowrap;
}
}
.goods-wrap {
.goods-item {
margin-top: 20rpx;