feat: 周边商家迁移

This commit is contained in:
mayubo@gmail.com 2025-05-12 10:37:11 +08:00
parent 8eb0a3a4dc
commit 958bf98663
8 changed files with 252 additions and 12 deletions

View File

@ -6,6 +6,6 @@ export const apiArr = {
createServerOrder: '/wechat/appoint-orders/create', //创建上门服务订单
getCurrentShopMsg: '/wechat/water/device/shop-info', //获取店铺支付信息
getBanner: '/wechat/banner-list ', //banner图
getGoodsList: '/wechat/appoints/get-shop-list', //获取商家列表
getGoodsList: '/wechat/get-shop-list', //获取商家列表
getGoodsDesc:"/wechat/shop/shop_info", //商家详情
}

View File

@ -0,0 +1,86 @@
.merchantList {
padding: 30rpx 20rpx;
}
.merchantItem {
width: 720rpx;
display: flex;
align-items: center;
justify-content: space-between;
padding: 30rpx 0;
border-bottom: 1rpx solid #E6E6E6;
box-sizing: border-box;
}
/*
.merchantItem_left {
display: flex;
align-items: center;
} */
.left_pic {
width: 180rpx;
height: 180rpx;
border-radius: 20rpx;
overflow: hidden;
margin-right: 20rpx;
}
.merchantItem_right {
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
}
.lat {
margin-bottom: 60rpx;
}
.tel {
font-weight: 400;
font-size: 26rpx;
color: #FFFFFF;
width: 150rpx;
height: 50rpx;
background: #D5AC66;
border-radius: 100rpx 100rpx 100rpx 100rpx;
display: flex;
align-items: center;
justify-content: center;
}
.merchantItem_left_msg_tit {
font-weight: 400;
font-size: 32rpx;
color: #000000;
}
.merchantItem_left_msg {
flex: 1;
overflow: hidden;
}
.merchantItem_left_msg_add {
font-weight: 400;
font-size: 24rpx;
color: #999999;
margin-top: 14rpx;
/* flex: 1; */
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
/* width: 400rpx; */
}
.merchantItem_left_msg_msg {
font-weight: 400;
font-size: 22rpx;
color: #FF512A;
background: #FFF0ED;
padding: 2rpx;
margin-top: 16rpx;
}
.merchantItem_left_msg_tag {
font-weight: 400;
font-size: 24rpx;
color: #999999;
margin-top: 18rpx;
}

View File

@ -1,24 +1,153 @@
<template>
<view class="">
123
<view class="merchantList">
<view class="merchantItem" v-for="(item, index ) in shopList" :key="index" :data-id="item.shop_id"
@click="headerNavClick">
<view class="merchantItem_left">
<image class="left_pic" :src="item.logo" mode="" />
</view>
<view class="merchantItem_left_msg">
<view class="merchantItem_left_msg_tit">{{item.shop_name}}</view>
<view class="merchantItem_left_msg_add">{{item.addr}}</view>
<!-- <view class="merchantItem_left_msg_msg">中国领先的高科技医疗设备研...</view> -->
<view class="merchantItem_left_msg_tag">{{item.tags}}</view>
</view>
<view class="merchantItem_right">
<view class="lat">{{item.distance ? item.distance + 'km' : '暂无定位'}}</view>
<view class="tel" @click.stop="call" :data-phone="item.tel">电话询价</view>
</view>
</view>
</view>
</template>
<script>
import { request } from '../../../utils';
import {
apiArr
} from '../../../api/doorToDoor';
import {
picUrl,
request
} from '../../../utils';
export default {
data() {
return {
list: [], //
page_num: 1,
page_size: 10,
flag: false,
lat: 0,
log: 0,
ToArr: [],
shopList: [],
}
},
methods: {
async init() {
const res = await request(apiArr.getGoodsList, "POST", {
page_num: this.page_num,
page_size: this.page_size
});
if (res.list) {
let flag = false
if (res.list.length == this.page_size) {
flag = true
} else {
flag = false
}
const newRes = res.list.map(item => {
return {
...item,
photo: picUrl + item.photo,
logo: picUrl + item.logo,
}
});
let ToArr = this.formatCoordinates(res.list)
console.log('newRes', newRes);
this.list = this.list.concat(newRes || []);
this.flag = flag;
this.page_num = this.page_num + 1;
this.ToArr = ToArr;
this.caculate();
}
},
call(e) {
wx.makePhoneCall({
phoneNumber: e.currentTarget.dataset.phone,
})
},
headerNavClick(e) {
wx.navigateTo({
url: `/packages/roundMechant/pages/mechantDesc/mechantDesc?id=${e.currentTarget.dataset.id}`,
})
},
//
formatCoordinates(data) {
if (!Array.isArray(data)) return "";
const validData = data.filter(item => {
//  lat  lng
if (!item || typeof item !== "object") return false;
//  lat  lng
const lat = item.lat;
const lng = item.lng;
return (
lat !== undefined && lat !== null && lat !== "" && !isNaN(lat) &&
lng !== undefined && lng !== null && lng !== "" && !isNaN(lng)
);
});
// 
return validData
.map(item => `${Number(item.lat)},${Number(item.lng)}`)
.join(';');
},
//
caculate() {
let that = this
let from = this.lat + ',' + this.log
uni.request({
url: "https://apis.map.qq.com/ws/distance/v1/matrix?mode=driving",
method: "POST",
header: "Content-Type:application/json",
data: {
"key": "55NBZ-MUQYW-EAJRL-YIWPA-ZXCR6-4NBPP",
"from": from,
"to": that.ToArr
},
success(res) {
console.log(res, 'sdad');
wx.hideLoading();
if (res.data.status == 0) {
let shopList = that.list;
shopList.forEach((item, index) => {
if (res.data.result.rows[0].elements[index] && res.data.result.rows[0].elements[index]
.distance) {
item.distance = Number(res.data.result.rows[0].elements[index].distance / 1000).toFixed(2);
}
})
shopList.sort((a, b) => a.distance - b.distance);
that.shopList = shopList
}
}
})
},
},
onLoad() {
}
onLoad(options) {
this.lat = Number(options.lat);
this.log = Number(options.log);
this.init()
},
onReachBottom() {
if (this.flag) {
this.init()
}
},
}
</script>

View File

@ -454,6 +454,19 @@
return
}
}
//
if(e.currentTarget.dataset.url == '/packages/aroundShop/index/index'){
uni.getLocation({
type:"gcj02",
success(res){
console.log('1231231', res);
NavgateTo(`${e.currentTarget.dataset.url}?lat=${res.latitude}&log=${res.longitude}`)
}
})
return;
}
console.log('选择城市');
NavgateTo( `${e.currentTarget.dataset.url}`)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -19694,7 +19694,7 @@ var apiArr = {
//获取店铺支付信息
getBanner: '/wechat/banner-list ',
//banner图
getGoodsList: '/wechat/appoints/get-shop-list',
getGoodsList: '/wechat/get-shop-list',
//获取商家列表
getGoodsDesc: "/wechat/shop/shop_info" //商家详情
};

View File

@ -492,6 +492,18 @@ var _default = {
return;
}
}
// 周边商家跳转时需获取当前经纬度坐标
if (e.currentTarget.dataset.url == '/packages/aroundShop/index/index') {
uni.getLocation({
type: "gcj02",
success: function success(res) {
console.log('1231231', res);
(0, _index.NavgateTo)("".concat(e.currentTarget.dataset.url, "?lat=").concat(res.latitude, "&log=").concat(res.longitude));
}
});
return;
}
console.log('选择城市');
(0, _index.NavgateTo)("".concat(e.currentTarget.dataset.url));
},