powerbank/page_user/ditu.vue
2024-05-15 18:01:50 +08:00

393 lines
9.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="page">
<u-navbar title="附近门店" :border-bottom="false" :background="bgc" title-color='#000' title-size='36' height='38'></u-navbar>
<view class="dtxs">
<map class='map' :latitude="latitude" :longitude="longitude" @markertap="handleMarkerClick" :markers="covers" :show-location="true"/>
</view>
<!-- <view class="listbox">
<view class="moshi">
<image src="https://api.ccttiot.com/smartmeter/img/static/u7HPhEwbIJqbLRpImBON" mode="" @click="btndt(1)"></image>
<image src="https://api.ccttiot.com/smartmeter/img/static/uGVN2tOaCq2hiWKy1cYl" mode="" @click="btndt(2)" v-if="isMch"></image>
</view>
</view> -->
<view class="list_item">
<view class="list">
<view class="pic">
<image :src="listobj.picture" mode="aspectFill"></image>
</view>
<view class="cen">
<view class="cena" style="font-weight: 600;">
{{listobj.name}}
</view>
<view class="cenb">
{{listobj.address}}
</view>
<view class="cenc">
营业时间{{listobj.businessTimeStart}}-{{listobj.businessTimeEnd}}
</view>
</view>
</view>
<view class="chakan">
<view class="wz" style="color: #109F64;" v-if="listobj.availableDeviceCount > 0">可租借</view>
<view class="wz" style="color: #109F64;" v-if="num > 0">可归还</view>
<view class="wz" style="background-color: #FFEFEF;color: #FF4444;" v-if="num == 0">已还满</view>
</view>
<view class="anniu">
<view class="" @click="mapFun">
到这去
</view>
<view class="" style="color: #fff;background-color: #25CE88;" @click="scanQRCode">
扫码充电
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
latitude: 31.02, // 初始纬度
longitude: 112.12, // 初始经度
covers: [], // 覆盖物数组
index:1,
falga:true,
falgb:false,
storeId:'',
listobj:{},
mapname:'',
mapaddress:'',
isMch:'',
num:0
}
},
onLoad(option) {
this.storeId = option.markerId
if(option.markerId){
this.falga = false
this.falgb = true
}
this.getxq()
},
methods: {
scanQRCode() {
uni.navigateTo({
url: '/page_user/yajin/index'
})
// uni.scanCode({
// onlyFromCamera: true,
// scanType: ['qrCode'],
// success: res => {
// console.log('扫描结果:', res);
// },
// fail: err => {
// console.error('扫描失败:', err);
// uni.showToast({
// title: '扫描失败',
// icon: 'none'
// });
// }
// });
},
getxq(){
this.$u.get("/app/store/" + this.storeId).then(res => {
if (res.code == 200) {
this.listobj = res.data
this.num = this.listobj.slotCount - this.listobj.deviceCount
}
})
},
mapFun() {
uni.openLocation({
latitude: this.listobj.lat,
longitude: this.listobj.lng,
name:this.mapname,
address: this.mapaddress
});
},
getMyLocation() {
uni.getLocation({
type: 'wgs84',
success: (res) => {
console.log('我的位置:', res);
this.latitude = res.latitude;
this.longitude = res.longitude;
this.jinweidu = this.longitude + ',' + this.latitude;
// 请求附近的店铺
this.$u.get("/app/store/listNearBy?center=" + this.jinweidu + '&radius=' + 1000).then(res => {
if (res.code == 200) {
// 假设返回的店铺数据在res.rows中并且每个店铺有latitude和longitude字段
res.data.forEach(item => {
const shopCover = {
id:parseFloat(item.storeId),
latitude: item.lat,
longitude: item.lng,
width: 25,
height: 30,
iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uI3B6yPwtiUBD3vafLtw'
};
this.covers.push(shopCover);
});
}
});
},
fail: (err) => {
console.error('获取位置失败:', err);
}
});
},
handleMarkerClick(e){
this.$u.get("/app/store/" + e.markerId).then(res => {
if (res.code == 200) {
this.listobj = res.data
this.mapname = res.data.city
this.mapaddress = res.data.address
}
})
this.falga = false
this.falgb = true
},
btntab(num){
this.index = num
},
btndt(num){
if(num == 1){
uni.navigateBack()
}
},
btnitem(){
this.falga = false
this.falgb = true
}
},
mounted() {
this.getMyLocation();
}
}
</script>
<style lang="scss">
/deep/ .map{
width: 100%;
height: 100%;
}
page {
// background-color: ;
background: linear-gradient(180deg, #25CE88 0%, rgba(255, 255, 255, 0) 100%);
border-radius: 0rpx 0rpx 0rpx 0rpx;
}
.page {
width: 750rpx;
position: fixed;
top: 0;
left: 0;
.list_item{
position: fixed;
bottom: 84rpx;
left: 50%;
transform: translateX(-50%);
width: 706rpx;
height: 400rpx;
background: #FFFFFF;
box-shadow: 0rpx 10rpx 64rpx 0rpx rgba(0,0,0,0.08);
border-radius: 20rpx;
margin: auto;
padding: 46rpx 40rpx;
box-sizing: border-box;
.chakan{
display: flex;
margin-bottom: 10rpx;
// justify-content: space-between;
padding-left: 145rpx;
width: 625rpx;
box-sizing: border-box;
border-radius: 8rpx 8rpx 8rpx 8rpx;
.wz{
font-size: 20rpx;
// width: 96rpx;
// height: 34rpx;
background: #B7FFE1;
border-radius: 16rpx 16rpx 16rpx 16rpx;
padding: 4rpx 16rpx;
box-sizing: border-box;
margin-left: 10rpx;
}
}
.anniu{
display: flex;
justify-content: space-between;
margin-top: 10rpx;
view{
width: 300rpx;
height: 82rpx;
line-height: 82rpx;
border-radius: 45rpx 45rpx 45rpx 45rpx;
border: 2rpx solid #25CE88;
text-align: center;
font-weight: 500;
font-size: 36rpx;
color: #25CE88;;
}
}
.list{
display: flex;
// margin-top: 44rpx;
padding-bottom: 16rpx;
.pic{
width: 150rpx;
height: 134rpx;
// background-color: #D9D8FF;
border-radius: 10rpx;
// margin-right: 28rpx;
image{
width: 100%;
height: 100%;
mode: "aspectFill";
margin-top: 10rpx;
}
}
.cen{
// margin-right: 140rpx;
margin-left: 20rpx;
.cena{
font-weight: 500;
font-size: 28rpx;
color: #3D3D3D;
line-height: 38rpx;
}
.cenb{
font-weight: 400;
font-size: 24rpx;
color: #3D3D3D;
line-height: 32rpx;
margin-top: 14rpx;
}
.cenc{
font-weight: 400;
font-size: 24rpx;
color: #3D3D3D;
line-height: 32rpx;
margin-top: 14rpx;
text{
display: inline-block;
padding: 4rpx 18rpx;
box-sizing: border-box;
// border: 1px solid #ccc;
border-radius: 20rpx;
}
.bu{
margin-left: 10rpx;
background:#D9D8FF;
color: #25CE88;
}
}
}
.right{
padding-top: 40rpx;
image{
width: 40rpx;
height: 40rpx;
}
text{
display: block;
font-weight: 400;
font-size: 20rpx;
color: #808080;
line-height: 28rpx;
}
}
}
}
.dtxs{
width: 100%;
height: 100vh;
position: fixed;
top: 0;
left: 0;
z-index: -1;
}
.listbox{
background: #FFFFFF;
border-radius: 64rpx 64rpx 0 0;
box-shadow: 0rpx 10rpx 64rpx 0rpx rgba(0,0,0,0.08);
height:186rpx;
width: 100%;
overflow-y: scroll;
position: fixed;
bottom: 0;
left: 0;
.saoyisao{
margin-top: 44rpx;
view{
border-radius: 54rpx 54rpx 54rpx 54rpx;
text-align: center;
width: 676rpx;
height: 102rpx;
background: linear-gradient( 90deg, #25CE88 0%, #25CE88 100%);
line-height: 102rpx;
margin: auto;
image{
width: 56rpx;
height: 56rpx;
vertical-align: middle;
display: inline-block;
margin-bottom: 12rpx;
margin-right: 10rpx;
}
text{
font-weight: 500;
font-size: 40rpx;
color: #FFFFFF;
}
}
}
.moshi{
position: fixed;
bottom:210rpx;
left: 30rpx;
z-index: 99;
image{
width: 210rpx;
height: 62rpx;
}
}
.title{
border-radius: 64rpx 64rpx 0 0;
display: flex;
justify-content: space-between;
font-weight: 500;
font-size: 36rpx;
color: #3D3D3D;
line-height: 160rpx;
padding: 0 76rpx;
width: 100%;
background-color: #fff;
position: fixed;
height: 160rpx;
top: 40vh;
left: 0;
padding-bottom: 20rpx;
}
}
}
.active{
border-bottom: 10rpx solid #D9D8FF;
border-radius: 7rpx;
padding-bottom: 10rpx;
font-weight: 700;
}
</style>