feat: 周边商家迁移
This commit is contained in:
parent
8eb0a3a4dc
commit
958bf98663
@ -6,6 +6,6 @@ export const apiArr = {
|
|||||||
createServerOrder: '/wechat/appoint-orders/create', //创建上门服务订单
|
createServerOrder: '/wechat/appoint-orders/create', //创建上门服务订单
|
||||||
getCurrentShopMsg: '/wechat/water/device/shop-info', //获取店铺支付信息
|
getCurrentShopMsg: '/wechat/water/device/shop-info', //获取店铺支付信息
|
||||||
getBanner: '/wechat/banner-list ', //banner图
|
getBanner: '/wechat/banner-list ', //banner图
|
||||||
getGoodsList: '/wechat/appoints/get-shop-list', //获取商家列表
|
getGoodsList: '/wechat/get-shop-list', //获取商家列表
|
||||||
getGoodsDesc:"/wechat/shop/shop_info", //商家详情
|
getGoodsDesc:"/wechat/shop/shop_info", //商家详情
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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;
|
||||||
|
}
|
||||||
@ -1,24 +1,153 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="">
|
<view class="merchantList">
|
||||||
123
|
<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>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {
|
||||||
import { request } from '../../../utils';
|
apiArr
|
||||||
|
} from '../../../api/doorToDoor';
|
||||||
|
import {
|
||||||
|
picUrl,
|
||||||
|
request
|
||||||
|
} from '../../../utils';
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
list: [], //商家列表
|
||||||
|
page_num: 1,
|
||||||
|
page_size: 10,
|
||||||
|
flag: false,
|
||||||
|
lat: 0,
|
||||||
|
log: 0,
|
||||||
|
ToArr: [],
|
||||||
|
shopList: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
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>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -455,6 +455,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 周边商家跳转时需获取当前经纬度坐标
|
||||||
|
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('选择城市');
|
console.log('选择城市');
|
||||||
NavgateTo( `${e.currentTarget.dataset.url}`)
|
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
@ -19694,7 +19694,7 @@ var apiArr = {
|
|||||||
//获取店铺支付信息
|
//获取店铺支付信息
|
||||||
getBanner: '/wechat/banner-list ',
|
getBanner: '/wechat/banner-list ',
|
||||||
//banner图
|
//banner图
|
||||||
getGoodsList: '/wechat/appoints/get-shop-list',
|
getGoodsList: '/wechat/get-shop-list',
|
||||||
//获取商家列表
|
//获取商家列表
|
||||||
getGoodsDesc: "/wechat/shop/shop_info" //商家详情
|
getGoodsDesc: "/wechat/shop/shop_info" //商家详情
|
||||||
};
|
};
|
||||||
|
|||||||
@ -492,6 +492,18 @@ var _default = {
|
|||||||
return;
|
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('选择城市');
|
console.log('选择城市');
|
||||||
(0, _index.NavgateTo)("".concat(e.currentTarget.dataset.url));
|
(0, _index.NavgateTo)("".concat(e.currentTarget.dataset.url));
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user