文件
NHCshopro/pages/public/store/store.vue
可乐加冰 9d2488a631 chore: 纳入小程序完整源码
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-23 20:25:01 +08:00

169 行
4.0 KiB
Vue

<template>
<view class="store-container">
<view class="store-inner-container" v-for="(item,index) in storeList">
<view class="store-image-container">
<image :src="$IMG_URL+item.images" mode="aspectFill"
style="width: 100%;height: 100%;border-radius: 10rpx;"></image>
</view>
<view class="store-title-container"
@tap="chooseLocation(`${item.latitude}`,`${item.longitude}`,`${item.name}`)">
<view class="store-name-container">
{{item.name}}
</view>
<view class="store-name-container"
style="color: #9a9a9a;font-size: 24rpx;font-weight: 550;height: 40rpx;line-height: 40rpx;">
<image :src="$IMG_URL+'/uploads/20230725/ce77a35bae7f0aa1966bbe076294136a.png'"
style="width: 25rpx;height: 25rpx;margin-right: 15rpx;" mode=""></image>{{item.distance}}km
{{item.province_name+item.city_name+item.area_name+item.address}}
</view>
<view class="store-name-container"
style="color: #f00;font-size: 24rpx;font-weight: 550;height: 40rpx;line-height: 40rpx;">
<image :src="$IMG_URL+'/uploads/20230725/86825ad6519e7b66bc7a6f2c1e3ffd1e.png'" mode=""
style="width: 25rpx;height: 25rpx;margin-right: 15rpx;"></image>
{{item.openhours}}
</view>
<view class="store-name-container"
style="font-size: 26rpx;height: 40rpx;line-height: 40rpx;color: royalblue;" @tap.stop="callPhone(`${item.phone}`)">
<image :src="$IMG_URL+'/uploads/20230726/f0fc515cec33ebec52c3121edd795a40.png'" mode=""
style="width: 32rpx;height: 32rpx;margin-right: 15rpx;"></image>
{{item.realname}}({{item.phone}})
<view @tap.stop="copyMobile(`${item.phone}`)"
style="color: #9a9a9a;margin-left: 10rpx;">复制</view>
</view>
</view>
</view>
</view>
</template>
<script>
var that
export default {
data() {
return {
page: 1,
limit: 20,
storeList: []
}
},
created() {
that = this
that.getLocationInfo()
},
onReachBottom() {
that.getList()
},
methods: {
getLocationInfo() {
const that = this
uni.getLocation({
type: "wgs84",
success(res) {
uni.setStorageSync("lat", res.latitude)
uni.setStorageSync("lng", res.longitude)
that.getList()
},
fail(res) { // 拒绝授权
console.log(res);
}
});
},
copyMobile(mobile) {
uni.setClipboardData({
data: mobile
})
},
callPhone(phone){
console.log(phone)
uni.makePhoneCall({
phoneNumber:phone
})
},
chooseLocation(lat, lng, name) {
uni.openLocation({
latitude: Number(lat),
longitude: Number(lng),
name: name,
address: name,
complete(r) {
console.log(r)
}
})
},
getList() {
let param = {
page: this.page,
limit: this.limit,
lat: uni.getStorageSync("lat") || -1,
lng: uni.getStorageSync("lng") || -1
}
this.$http("store.allList", param, "加载中").then(res => {
if (res.code == 1) {
if (res.data.length > 0) {
let old_list = that.storeList
that.storeList = old_list.concat(res.data)
that.page = that.page + 1
}
} else {
uni.showToast({
title: "数据请求失败",
icon: "none"
})
return false
}
})
}
}
}
</script>
<style scoped>
.store-container {
width: 100%;
padding-left: 20rpx;
padding-right: 20rpx;
box-sizing: border-box;
margin-top: 20rpx;
}
.store-inner-container {
width: 100%;
height: 230rpx;
background-color: #fff;
border-radius: 10rpx;
margin-top: 20rpx;
padding: 10rpx;
box-sizing: border-box;
display: flex;
flex-wrap: wrap;
}
.store-image-container {
width: 150rpx;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.store-title-container {
width: calc(100% - 15rpx - 150rpx);
height: 100%;
display: flex;
flex-wrap: wrap;
margin-left: 15rpx;
}
.store-name-container {
width: 100%;
height: 50rpx;
line-height: 50rpx;
text-align: left;
overflow: hidden;
font-size: 32rpx;
font-weight: 550;
display: flex;
align-items: center;
justify-content: flex-start;
}
</style>